Configure VP9 Undershoot and Overshoot in FFmpeg
This article explains how to configure the
undershoot-pct and overshoot-pct parameters in
the FFmpeg libvpx-vp9 encoder. You will learn what these
bitrate control settings do, how they affect video quality and file size
during encoding, and the exact FFmpeg commands required to implement
them.
Understanding VP9 Undershoot and Overshoot
When encoding video with the VP9 codec (libvpx-vp9) in
Variable Bitrate (VBR) or Constrained Quality (CQ) modes, the encoder
dynamically adjusts the bitrate based on the complexity of the video
scenes. The undershoot-pct and overshoot-pct
parameters define the limits of this variation.
undershoot-pct(Undershoot Percentage): This parameter sets the percentage limit for the bitrate to drop below the target bitrate during simple scenes. The value ranges from0to100. For example, a value of50means the encoder can drop the bitrate to a minimum of 50% of the target bitrate.overshoot-pct(Overshoot Percentage): This parameter sets the percentage limit for the bitrate to exceed the target bitrate during complex scenes. The value ranges from0to100. For example, a value of15means the encoder can spike up to a maximum of 115% of the target bitrate.
Configuring these parameters helps you maintain a balance between consistent visual quality and strict file size/bandwidth limitations.
How to Configure the Parameters in FFmpeg
In FFmpeg, these parameters are passed as private options to the
libvpx-vp9 encoder. The syntax uses the flags
-undershoot-pct and -overshoot-pct followed by
an integer value.
Recommended Values for Streaming and VBR
For typical streaming workflows where you want to prevent massive buffer spikes but still save bits on simple scenes, the following configurations are recommended:
- Set
undershoot-pctto a high value (like50or100) to allow the encoder to aggressively drop the bitrate on static or simple scenes, saving storage space. - Set
overshoot-pctto a low value (like15or20) to prevent bitrate spikes from causing buffering issues on the client side.
Example FFmpeg Command
The following command demonstrates how to apply these settings during a two-pass VP9 encoding process:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -undershoot-pct 50 -overshoot-pct 15 -an output.webmIn this command: * -c:v libvpx-vp9 selects the VP9
encoder. * -b:v 2M sets the target video bitrate to 2 Mbps.
* -undershoot-pct 50 allows the bitrate to drop down to 1
Mbps (50% of target) for easy-to-encode frames. *
-overshoot-pct 15 limits the maximum bitrate to 2.3 Mbps
(115% of target) for complex frames.