Configure hevc_qsv Rate Control and Quality in FFmpeg
This article provides a straightforward guide on how to configure
rate control modes and quality options for the Intel Quick Sync Video
HEVC encoder (hevc_qsv) in FFmpeg. You will learn how to
set constant quality, target bitrates, and hardware-specific speed
presets to optimize your H.265 video encoding workflows.
Rate Control Modes
The hevc_qsv encoder supports several rate control
methods to balance file size and visual quality.
1. Intelligent Constant Quality (ICQ)
ICQ is the recommended mode for general archiving and streaming when
you want consistent quality across different scenes. It adjusts the
bitrate dynamically to maintain a specified quality level. *
Option: Use -global_quality with a value
between 1 (best quality) and 51 (worst quality). A value of 20 to 24 is
typical for high quality. * Command Example:
bash ffmpeg -i input.mp4 -c:v hevc_qsv -global_quality 20 output.mp4
2. Lookahead Intelligent Constant Quality (LA_ICQ)
LA_ICQ analyzes upcoming frames to optimize bit distribution further,
improving compression efficiency at the cost of slight latency. *
Option: Enable lookahead by adding
-look_ahead 1. * Command Example:
bash ffmpeg -i input.mp4 -c:v hevc_qsv -global_quality 20 -look_ahead 1 -look_ahead_depth 15 output.mp4
3. Constant Bitrate (CBR)
CBR forces the encoder to maintain a strict, uniform bitrate. This is
ideal for streaming environments with limited bandwidth. *
Option: Set the target bitrate with -b:v
and match it with -maxrate and -bufsize. *
Command Example:
bash ffmpeg -i input.mp4 -c:v hevc_qsv -b:v 5M -maxrate 5M -bufsize 10M output.mp4
4. Variable Bitrate (VBR)
VBR allows the bitrate to fluctuate based on complexity, keeping the
average close to your target. * Option: Set the target
average bitrate with -b:v and a higher maximum limit with
-maxrate. * Command Example:
bash ffmpeg -i input.mp4 -c:v hevc_qsv -b:v 5M -maxrate 8M -bufsize 16M output.mp4
5. Constant Quantization Parameter (CQP)
CQP locks the quantization parameter for every frame, bypassing any
bit distribution algorithms. * Option: Use
-q or -qp to set the QP value. *
Command Example:
bash ffmpeg -i input.mp4 -c:v hevc_qsv -q 22 output.mp4
Quality and Performance Presets
Intel QSV uses speed presets to balance execution speed against compression efficiency.
Option: Use
-presetwith one of the standard FFmpeg speed strings:veryfast,faster,fast,medium,slow,slower,veryslow.Command Example:
ffmpeg -i input.mp4 -c:v hevc_qsv -preset slow -global_quality 22 output.mp4
Under the hood, these match Intel’s numerical target usages from
1 (best quality, slowest) to 7 (best speed,
lowest quality).
Advanced Quality Modifiers
To further fine-tune the output quality, you can adjust the following options:
B-Frames (
-bf): Setting the number of B-frames can improve compression. Use a value of 3 to 7 for optimal H.265 compression.ffmpeg -i input.mp4 -c:v hevc_qsv -global_quality 20 -bf 4 output.mp4GOP Size (
-g): Sets the distance between I-frames. For standard streaming, use a GOP size equal to double the frame rate (e.g.,60for a 30 fps video).ffmpeg -i input.mp4 -c:v hevc_qsv -global_quality 20 -g 60 output.mp4