FFmpeg HEVC VideoToolbox Rate Control Guide
This article explains how to configure rate control and quality
settings for the hardware-accelerated hevc_videotoolbox
encoder in FFmpeg on macOS. You will learn how to use constant quality,
variable bitrate (VBR), and constant bitrate (CBR) modes to optimize
your video transcodes for performance, file size, and visual
fidelity.
Quality-Based Variable Bitrate (VBR)
Quality-based VBR is the recommended mode for general encoding. It targets a specific visual quality level rather than a specific file size, allowing the bitrate to fluctuate dynamically depending on the complexity of the scene.
To enable quality-based encoding, use the -q:v option.
For the VideoToolbox encoder, quality is set on a scale of 1 to
100, where higher values yield better quality and larger file
sizes.
ffmpeg -i input.mp4 -c:v hevc_videotoolbox -q:v 65 output.mp4- Sweet Spot: A value between
50and70offers an optimal balance between quality and file size. - High Quality: Values between
75and85provide near-visually lossless results.
Average Bitrate (ABR)
If you need to target a specific file size, you can use Average Bitrate mode. This tells the encoder to aim for a specific target bitrate over the duration of the video.
To set an average bitrate, use the -b:v flag:
ffmpeg -i input.mp4 -c:v hevc_videotoolbox -b:v 5M output.mp4In this example, the encoder will target an average of 5 Megabits per second (Mbps).
Constrained Variable Bitrate (CVBR)
Constrained VBR is useful for streaming or playing back videos on devices with strict hardware limitations. It allows the bitrate to fluctuate based on complexity but places a hard ceiling on how high the bitrate can spike.
To configure CVBR, define the target bitrate with -b:v
and the maximum allowed bitrate with -maxrate:
ffmpeg -i input.mp4 -c:v hevc_videotoolbox -b:v 4M -maxrate 6M output.mp4This tells the encoder to target 4 Mbps on average, but never exceed a peak of 6 Mbps.
Constant Bitrate (CBR)
Constant Bitrate forces the encoder to maintain a rigid bitrate throughout the entire video, regardless of scene complexity. While inefficient for storage, it is sometimes required for specific hardware playback pipelines or low-latency streaming.
To approximate CBR in VideoToolbox, set -b:v and
-maxrate to the same value, and configure the buffer size
(-bufsize):
ffmpeg -i input.mp4 -c:v hevc_videotoolbox -b:v 4M -maxrate 4M -bufsize 4M output.mp4Additional Quality Options
You can further control the behavior of the VideoToolbox encoder using these hardware-specific flags:
-realtime 1: Optimizes the encoding pipeline for real-time speed rather than efficiency or maximum compression. Use this for live streaming.-frames_before_start 0: Reduces latency by minimizing the frame buffer before encoding starts.-profile:v main10: Forces 10-bit color depth encoding, which helps prevent color banding in gradients (requires 10-bit source material).