Configure Libtheora Quality in FFmpeg

This article provides a quick and direct guide on how to configure the video quality parameter for the libtheora encoder in FFmpeg. You will learn the specific command-line options used to control output quality, the range of valid quality values, and see practical examples of how to apply these settings to your video transcodings.

The libtheora encoder in FFmpeg uses a quality-based variable bitrate (VBR) scale to control video compression. The primary parameter used to adjust this quality is -qscale:v (which can also be written as -q:v or simply -q).

The Quality Scale Range

Basic Command Syntax

To set the video quality with libtheora, pass the -q:v option followed by your desired value between 0 and 10. Here is a basic command example:

ffmpeg -i input.mp4 -c:v libtheora -q:v 6 output.ogv

In this command: * -i input.mp4 specifies the input video file. * -c:v libtheora selects the Theora video encoder. * -q:v 6 sets the video quality level to 6. * output.ogv is the resulting Ogg Video file.

Adding Audio Quality

Because Theora video is almost always multiplexed with Vorbis audio in an Ogg container, you should also configure the audio quality using the -q:a parameter (which also ranges from -1 to 10 with 10 being the highest quality):

ffmpeg -i input.mp4 -c:v libtheora -q:v 6 -c:a libvorbis -q:a 4 output.ogv

By utilizing the -q:v scale, FFmpeg dynamically allocates bitrate to maintain consistent visual quality throughout the duration of the video.