How to Remux OBS Recordings via Command Line
This article explains how to automate the process of converting OBS Studio recordings from MKV to MP4 using command-line scripting. Because OBS Studio does not feature a native, standalone command-line argument specifically for its GUI remuxing tool, this guide covers the two most efficient workarounds: using FFmpeg (the engine powering OBS’s remuxer) to batch-remux via scripts, and triggering OBS’s auto-remux feature using command-line arguments.
Method 1: Command-Line Remuxing with FFmpeg (Recommended)
OBS Studio performs remuxing internally using the FFmpeg library. To
automate this process without opening the OBS GUI, you can call FFmpeg
directly via a command-line script. This allows you to copy the video
and audio streams instantly from .mkv to .mp4
without re-encoding.
Step 1: Install FFmpeg
Ensure you have FFmpeg installed and added to your system’s PATH variable.
Step 2: The Remux Command
To remux a single file, open your terminal or command prompt and run:
ffmpeg -i input.mkv -c copy output.mp4-i input.mkv: Specifies the source file.-c copy: Tells FFmpeg to copy the video and audio streams directly without re-encoding, preserving original quality and finishing the process in seconds.
Step 3: Automated Batch Scripting
For Windows (Batch Script -
.bat):
Create a text file named batch_remux.bat in your
recording directory and paste the following code to convert all MKV
files to MP4 automatically:
@echo off
for %%i in (*.mkv) do (
ffmpeg -i "%%i" -c copy "%%~ni.mp4"
)
pause
For Linux / macOS (Bash
Script - .sh):
Create a script named batch_remux.sh, make it executable
(chmod +x batch_remux.sh), and run it:
#!/bin/bash
for file in *.mkv; do
ffmpeg -i "$file" -c copy "${file%.mkv}.mp4"
doneMethod 2: Triggering OBS Auto-Remux via Command Line
If you want OBS Studio to handle the remuxing automatically upon finishing a recording session initiated from the command line, you can leverage OBS’s built-in “Auto-Remux” feature alongside OBS command-line launch arguments.
Step 1: Enable Auto-Remux in OBS
- Open OBS Studio.
- Go to Settings > Advanced.
- Under the Recording section, check the box for Automatically remux to mp4.
- Click Apply and close OBS.
Step 2: Command-Line Automation
You can now script the startup and shutdown of OBS recordings. When OBS is commanded to stop recording via CLI or hotkey, it will automatically execute the remux function before closing.
Windows Command Prompt:
start "" "C:\Program Files\obs-studio\bin\64bit\obs64.exe" --startrecording --headlessLinux Terminal:
obs --startrecording --headless--startrecording: Launches OBS and immediately begins recording.--headless: Runs OBS without bringing up the main user interface (available in OBS Studio v29.1 and newer), allowing for seamless background scripting.
Once the recording is stopped (either by killing the process safely
or using an OBS WebSocket script), the software will automatically
generate the corresponding .mp4 file in your designated
recording folder.