Set Min and Max Quantizer for libvpx in FFmpeg

This article explains how to configure the minimum and maximum quantizer limits when using the libvpx (VP8) and libvpx-vp9 (VP9) encoders in FFmpeg. Controlling these parameters allows you to restrict the quality range of your output video, preventing the encoder from producing excessively high-bitrate peaks or dropping the quality below an acceptable threshold.

To configure the minimum and maximum quantizers in FFmpeg, you use the -qmin and -qmax flags. For both VP8 and VP9, the quantizer scale ranges from 0 to 63, where 0 represents lossless/best quality (largest file size) and 63 represents the lowest quality (smallest file size).

Basic Command Syntax

You can apply these limits by adding the -qmin and -qmax options directly to your FFmpeg command.

For VP9 (libvpx-vp9):

ffmpeg -i input.mp4 -c:v libvpx-vp9 -qmin 10 -qmax 42 output.webm

For VP8 (libvpx):

ffmpeg -i input.mp4 -c:v libvpx -qmin 10 -qmax 42 output.webm

Parameter Breakdown

Using Quantizer Limits with Constant Quality (CRF) Mode

When using the Constant Rate Factor (-crf) mode, the quantizer bounds act as safety thresholds. For example, if you target a quality level of 30, you can use -qmin and -qmax to ensure the encoder never goes outside your desired quality boundaries:

ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -qmin 15 -qmax 40 output.webm

In this setup, FFmpeg targets a quality level of 30 but is strictly forbidden from using a quantizer lower than 15 (preventing wasted bandwidth on static scenes) or higher than 40 (preventing excessive compression artifacts in highly dynamic scenes).