How to Configure Constrained VBR in FFmpeg

Constrained Variable Bitrate (CVBR) is an encoding method that allows bitrate flexibility to maintain video quality during complex scenes while enforcing a strict maximum limit to prevent streaming spikes. This article provides a quick guide on how to configure CVBR in FFmpeg using the Video Buffering Verifier (VBV) system. You will learn the essential commands and parameters needed to set target bitrates, maximum bitrates, and buffer sizes for optimal video delivery.

Understanding CVBR in FFmpeg

To achieve constrained variable bitrate in FFmpeg, you must use the VBV model. This model is activated by defining three key parameters:

Without setting these parameters together, FFmpeg will default to standard variable bitrate (VBR) or constant bitrate (CBR), which may lead to unexpected bandwidth spikes.

The Basic CVBR Command

Below is the standard template for encoding a video with CVBR using the widely compatible H.264 (libx264) codec:

ffmpeg -i input.mp4 -c:v libx264 -b:v 2M -maxrate 3M -bufsize 6M -c:a copy output.mp4

Parameter Breakdown:

Choosing the Right Buffer Size (-bufsize)

The -bufsize parameter is critical for successful CVBR configuration. It determines how strictly the maximum limit is enforced:

For general streaming, setting the -bufsize to double the maximum rate is recommended as a starting point. For low-latency live streaming, setting the -bufsize equal to the maximum rate is preferred.