Configure vp9_qsv Rate Control and Quality in FFmpeg

This article explains how to configure the rate control modes and quality settings for the Intel Quick Sync Video (QSV) accelerated VP9 encoder (vp9_qsv) in FFmpeg. You will learn how to utilize different rate control methods such as Constant Bitrate (CBR), Variable Bitrate (VBR), Intelligent Constant Quality (ICQ), and Constant Quantization Parameter (CQP), as well as how to apply speed and quality presets to optimize your video encoding workflow.

Selecting a Rate Control Mode

The vp9_qsv encoder relies on the -rc_mode private option to define how bitrate and quality are managed. Depending on your target use case (e.g., streaming, archiving, or fast drafts), you can choose from the following modes:

1. Intelligent Constant Quality (ICQ)

ICQ is the recommended mode for high-quality archiving. It adjusts the bitrate dynamically to maintain a consistent visual quality level across different scenes, preventing quality drops in complex scenes without wasting bits on simple ones.

To configure ICQ, set -rc_mode ICQ and define the quality level using -global_quality (on a scale of 1 to 51, where lower values mean better quality; 20 to 24 is typically the sweet spot):

ffmpeg -i input.mp4 -c:v vp9_qsv -rc_mode ICQ -global_quality 22 output.mkv

2. Constant Quantization Parameter (CQP)

CQP locks the quantization parameter for every frame. While it ensures no mathematical compression variance, it is less efficient than ICQ and can result in bloated file sizes.

To use CQP, specify the mode and set the QP value using -q or -q:v:

ffmpeg -i input.mp4 -c:v vp9_qsv -rc_mode CQP -q:v 25 output.mkv

3. Variable Bitrate (VBR)

VBR target-allocates bitrate to scenes based on complexity, keeping the overall output near a specified average. It is highly useful for file-size-constrained streaming or playback.

To configure VBR, specify the target bitrate using -b:v and set the maximum allowed peak bitrate using -maxrate:

ffmpeg -i input.mp4 -c:v vp9_qsv -rc_mode VBR -b:v 4M -maxrate 8M output.mkv

4. Constant Bitrate (CBR)

CBR keeps the output bitrate strictly constant. This mode is ideal for live streaming over networks with strict bandwidth limitations, though it is the least efficient in terms of quality-per-file-size.

To configure CBR, set -b:v, -maxrate, and -minrate to the exact same value, and define a buffer size:

ffmpeg -i input.mp4 -c:v vp9_qsv -rc_mode CBR -b:v 5M -maxrate 5M -minrate 5M -bufsize 10M output.mkv

Adjusting Quality and Speed Presets

The vp9_qsv encoder supports hardware-specific speed/quality presets using the -preset flag. These presets control the tradeoff between encoding speed and compression efficiency.

The available presets range from 1 (veryslow / best quality) to 7 (veryfast / fastest speed). You can use either the integer values or their corresponding string aliases:

Example Command

The following command encodes a video using the Look-Ahead Intelligent Constant Quality (LA_ICQ) rate control mode (which analyzes frames in advance for better bitrate distribution) combined with the highest quality preset (veryslow):

ffmpeg -i input.mp4 -c:v vp9_qsv -rc_mode LA_ICQ -global_quality 20 -preset veryslow output.mkv