How should you change the recording format in OBS Websocket?

LexianDEV

New Member
Hello, I hope this is the right place to ask — I’m currently stuck on something and could use some help.
I’m building software that uses **OBS** through its **WebSocket server** (with the `obsws-python` library) to automatically record videos. Everything works fine in terms of recording — the videos are captured from start to finish exactly as intended.
The issue comes afterward: my app uses **FFmpeg** to re-encode and trim the recordings, but I’ve noticed that FFmpeg freezes whenever it tries to process `.mkv` files.
Because of that, I’d like to have OBS record directly in **MP4 format** instead of MKV.
Here’s the relevant part of my current code (showing where I attempt to change the recording format):
\
Python:
            self.cl.callback.register(self.on_record_state_changed)
            self.ws.create_profile(name=f"{helpers.get_config('APP_NAME')} - Profile")
            self.ws.create_scene(name=f"{helpers.get_config('APP_NAME')} - Scene")
            if self.ws.get_studio_mode_enabled().studio_mode_enabled:
                self.ws.set_current_preview_scene(name=f"{helpers.get_config('APP_NAME')} - Scene")
            self.ws.set_current_program_scene(name=f"{helpers.get_config('APP_NAME')} - Scene")
            self.ws.set_video_settings(
                base_width=width,
                base_height=height,
                out_width=width,
                out_height=height,
                denominator=1,
                numerator=helpers.get_config("OBS_FPS")
            )
            self.ws.set_input_mute(name="Desktop Audio", muted=True)
            self.ws.set_input_mute(name="Mic/Aux", muted=True)
            self.ws.create_input(
                sceneName=f"{helpers.get_config('APP_NAME')} - Scene",
                inputName=f"{helpers.get_config('APP_NAME')} - Capture",
                inputKind="window_capture",
                inputSettings={
                    "window": "GoExport Viewer:Chrome_WidgetWin_1:chrome.exe",
                    "cursor": False,
                    "capture_audio": True,
                    "client_area": True
                },
                sceneItemEnabled=True
            )
            self.ws.set_profile_parameter(category="Output", name="RecFormat2", value="mp4")
\
As you can see at the bottom, I tried calling:
\
Python:
self.ws.set_profile_parameter(category="Output", name="RecFormat2", value="mp4")
\
…but OBS still saves the recordings as `.mkv`.
**My question is:**
How do I properly configure OBS (via WebSocket and `obsws-python`) to record in **MP4 format instead of MKV**?
Any guidance would be really appreciated — thanks in advance!

Note: I used ChatGPT to help make my post more readable, that's why there's strange formatting, sorry about that!
 
Top