Set Ogg Theora Video and Audio Quality in FFmpeg
This article provides a quick guide on how to configure the video and
audio quality parameters when encoding to the Ogg Theora format using
FFmpeg. You will learn how to use the correct encoder libraries, set
quality-based variable bitrates (VBR) using scale parameters, and define
specific target bitrates for both video (libtheora) and
audio (libvorbis).
Encoding Ogg Theora with FFmpeg
To encode video to the Ogg Theora format, FFmpeg uses the
libtheora video encoder and typically pairs it with the
libvorbis audio encoder. The output container is usually
.ogv or .ogg.
Setting Video Quality
You can control the video quality using either a quality-based scale (recommended) or by specifying a target bitrate.
1. Quality-Based (VBR)
Using the quality scale allows the encoder to maintain a consistent
visual quality throughout the video. Use the -qscale:v (or
-q:v) option. * Range: 0 to 10 (where 10
is the highest quality and 0 is the lowest). * Recommended
range: 5 to 7 offers a good balance between file size and
visual quality.
ffmpeg -i input.mp4 -c:v libtheora -qscale:v 6 output.ogv2. Bitrate-Based (CBR)
If you need to target a specific file size, you can set a constant
bitrate using the -b:v option.
ffmpeg -i input.mp4 -c:v libtheora -b:v 1.5M output.ogvSetting Audio Quality
Ogg Theora videos almost always use Vorbis audio. Like the video encoder, you can set the audio quality using a quality scale or a specific bitrate.
1. Quality-Based (VBR)
Use the -qscale:a (or -q:a) option to set
the quality level for the libvorbis encoder. *
Range: -1 to 10 (where 10 is the highest quality). *
Recommended range: 3 to 5 (3 is roughly 112kbps, 5 is
roughly 160kbps).
ffmpeg -i input.mp4 -c:v libtheora -qscale:v 6 -c:a libvorbis -qscale:a 4 output.ogv2. Bitrate-Based
To force a specific audio bitrate, use the -b:a
option.
ffmpeg -i input.mp4 -c:v libtheora -qscale:v 6 -c:a libvorbis -b:a 128k output.ogvComplete Command Example
Here is a complete, optimized command that encodes an input file to Ogg Theora using high-quality variable bitrate settings for both video and audio:
ffmpeg -i input.mp4 -c:v libtheora -qscale:v 7 -c:a libvorbis -qscale:a 5 output.ogv