How to change recording format with OBS Websocket #12530
-
|
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 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 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): def prep(self, output: str, width: int, height: int):
try:
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")
helpers.wait(4, "Waiting for OBS to set up the scene and sources...")
self.prepared = True
except Exception as e:
logger.error(f"Failed to prepare OBS: {e}")
self.prepared = FalseAs you can see at the bottom, I tried calling: self.ws.set_profile_parameter(category="Output", name="RecFormat2", value="mp4")…but OBS still saves the recordings as My question is: Any guidance would be really appreciated — thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hi the issue is that set_profile_parameter doesn’t actually change the recording format in OBS, so it keeps saving as .mkv. The correct way is to use SetRecordSettings, for example: await ws.set_record_settings({ (or the sync version with obswebsocket.requests.SetRecordSettings). |
Beta Was this translation helpful? Give feedback.
Hi the issue is that set_profile_parameter doesn’t actually change the recording format in OBS, so it keeps saving as .mkv.
The correct way is to use SetRecordSettings, for example:
await ws.set_record_settings({
"rec_format": "mp4"
})
(or the sync version with obswebsocket.requests.SetRecordSettings).