FFmpeg h264_qsv Rate Control and Quality Settings
This guide explains how to configure rate control methods and quality settings for Intel Quick Sync Video (QSV) hardware-accelerated H.264 encoding in FFmpeg. You will learn about different bitrate control modes—such as CBR, VBR, CQP, and ICQ—along with quality presets and advanced parameters to optimize your encoding performance and visual output.
Quality Presets
The -preset option controls the tradeoff between
encoding speed and compression efficiency. Intel QSV maps FFmpeg
standard presets to seven target usage levels (1 to 7, where 1 is best
quality and 7 is fastest speed).
You can use standard FFmpeg preset names: *
Quality-focused: veryslow,
slower, slow * Balanced:
medium * Speed-focused: fast,
faster, veryfast, superfast,
ultrafast
Example:
ffmpeg -i input.mp4 -c:v h264_qsv -preset slow output.mp4Rate Control Modes
Intel QSV supports several rate control methods depending on your target use case (streaming, archiving, or real-time communication).
1. Intelligent Constant Quality (ICQ)
ICQ is the recommended mode for archival and file-based transcoding. Similar to x264’s CRF (Constant Rate Factor), it adjusts the bitrate dynamically to maintain a consistent visual quality across different scenes.
To use ICQ, set the -global_quality flag. Lower values
produce higher quality and larger file sizes (range is 1 to 51, with 20
to 24 being optimal for most content).
ffmpeg -i input.mp4 -c:v h264_qsv -global_quality 23 output.mp42. Look-Ahead Intelligent Constant Quality (LA_ICQ)
This mode combines ICQ with Look-Ahead analysis. The encoder analyzes future frames to optimize bitrate allocation, resulting in better quality at a lower file size.
Enable it by setting -look_ahead 1 and specifying a
look-ahead depth (typically between 11 and 100 frames).
ffmpeg -i input.mp4 -c:v h264_qsv -global_quality 23 -look_ahead 1 -look_ahead_depth 30 output.mp43. Constant Bitrate (CBR)
CBR is ideal for live streaming where bandwidth is strictly limited.
You must set -b:v, -maxrate, and
-bufsize to the same target value.
ffmpeg -i input.mp4 -c:v h264_qsv -b:v 4000k -maxrate 4000k -bufsize 8000k output.mp44. Variable Bitrate (VBR)
VBR allows the bitrate to fluctuate based on scene complexity, while
aiming for a specified target average. Set -b:v as the
average target and -maxrate as the maximum allowed
ceiling.
ffmpeg -i input.mp4 -c:v h264_qsv -b:v 4000k -maxrate 8000k -bufsize 16000k output.mp45. Constant Quantization Parameter (CQP)
CQP bypasses psychoacoustic optimizations and forces a constant
compression level for every frame. It is generally used for testing and
debugging. You can set the QP value using -q:v.
ffmpeg -i input.mp4 -c:v h264_qsv -q:v 23 output.mp4Advanced Quality Options
To further fine-tune the encoder, you can utilize QSV-specific flags:
-rdo 1: Enables Rate Distortion Optimization, which significantly improves visual quality at the expense of a minor hit to encoding speed.-gop_size(or-g): Sets the Group of Pictures (GOP) size (keyframe interval). For streaming, this is usually set to twice the frame rate.-idr_interval: Controls the frequency of IDR frames relative to I-frames. Set to1to make every I-frame an IDR frame for better seeking compatibility.
Example incorporating advanced settings:
ffmpeg -i input.mp4 -c:v h264_qsv -preset slow -global_quality 20 -look_ahead 1 -look_ahead_depth 40 -rdo 1 -g 60 -idr_interval 1 output.mp4