Multiplex Theora and Vorbis into Ogg Using FFmpeg
This guide demonstrates how to combine (multiplex) a pre-encoded Theora video track and a Vorbis audio track into a single Ogg container using FFmpeg. You will learn the exact command-line syntax to merge these streams quickly without losing quality through re-encoding, as well as how to handle the process if you need to transcode the source files.
Muxing Existing Theora and Vorbis Streams
If your video file is already encoded in Theora and your audio file
is already encoded in Vorbis, you can multiplex them into an Ogg
container (typically using the .ogv extension for video)
without re-encoding. This process is instant and preserves the original
quality of both streams.
Run the following command in your terminal:
ffmpeg -i input_video.theora -i input_audio.vorbis -c:v copy -c:a copy output.ogvCommand Breakdown
-i input_video.theora: Specifies the path to the input video file containing the Theora stream.-i input_audio.vorbis: Specifies the path to the input audio file containing the Vorbis stream.-c:v copy: Instructs FFmpeg to stream copy the video. This bypasses the decoding and encoding process for the video track.-c:a copy: Instructs FFmpeg to stream copy the audio, bypassing the decoding and encoding process for the audio track.output.ogv: The name of the resulting multiplexed file. The.ogvextension tells FFmpeg to use the Ogg video container format.
Encoding and Muxing in One Step
If your source video and audio files are in different formats (such as an MP4 video and a WAV audio file) and you need to encode them to Theora and Vorbis while multiplexing them into an Ogg container, use this command:
ffmpeg -i input_video.mp4 -i input_audio.wav -c:v libtheora -q:v 6 -c:a libvorbis -q:a 5 output.ogvEncoding Command Breakdown
-c:v libtheora: Uses the Libtheora encoder to compress the video track.-q:v 6: Sets the video quality scale. Range is 0–10 (higher is better). A value of 6 offers a good balance between quality and file size.-c:a libvorbis: Uses the Libvorbis encoder to compress the audio track.-q:a 5: Sets the audio quality scale. Range is -1 to 10. A value of 5 is roughly equivalent to 160 kbps, providing high-quality stereo audio.