Configure Libtheora Bitrate in FFmpeg
This guide explains how to configure the target bit rate for the
libtheora video encoder using FFmpeg. You will learn the
specific command-line arguments required to control the bitrate, how to
apply constant bitrate (CBR) limits, and how to use quality-based
variable bitrate (VBR) targeting to achieve the best balance between
file size and visual fidelity.
Setting a Target Bitrate (ABR/CBR)
To set a specific target bitrate for the libtheora
encoder, use the -b:v (or -b) flag followed by
your desired bitrate value (e.g., 1M for 1 Megabit per
second, or 500k for 500 Kilobits per second). This method
uses Average Bitrate (ABR) encoding.
Here is the basic command structure:
ffmpeg -i input.mp4 -c:v libtheora -b:v 1M output.ogvIn this command: * -c:v libtheora selects the Theora
video encoder. * -b:v 1M sets the target video bitrate to 1
Mbps.
Quality-Based Encoding (VBR)
For most scenarios, utilizing quality-based variable bitrate (VBR) is recommended over a strict target bitrate. This allows the encoder to allocate more data to complex scenes and save space on simple ones.
To enable quality-based encoding, use the -qscale:v (or
-q:v) option. For libtheora, the quality scale
ranges from 0 (lowest quality, smallest file size) to
10 (highest quality, largest file size). A value of
5 to 7 is generally recommended for a good
balance.
ffmpeg -i input.mp4 -c:v libtheora -q:v 6 output.ogvNote: If you specify both -b:v and
-q:v, the quality setting (-q:v) will take
precedence, and the target bitrate setting will be ignored.
Two-Pass Encoding for Strict Bitrate Targets
If you need to hit a highly precise target file size or bitrate limit, you should use two-pass encoding. This process analyzes the video in the first pass and encodes it in the second pass.
Run the following two commands in sequence:
Pass 1:
ffmpeg -i input.mp4 -c:v libtheora -b:v 1M -pass 1 -f null /dev/null(Windows users should replace /dev/null with
NUL)
Pass 2:
ffmpeg -i input.mp4 -c:v libtheora -b:v 1M -pass 2 output.ogv