Configure h264_videotoolbox Rate Control in FFmpeg

This article provides a practical guide on configuring rate control and quality settings for the hardware-accelerated h264_videotoolbox encoder in FFmpeg on macOS. You will learn how to use target bitrate (VBR), constant quality (CQ), and strict constant bitrate (CBR) modes to optimize your video encoding workflow for speed, file size, and visual fidelity.

Understanding h264_videotoolbox Rate Control

The h264_videotoolbox encoder utilizes Apple’s hardware-accelerated VideoToolbox framework. Unlike software encoders like libx264 which use Constant Rate Factor (CRF), VideoToolbox relies on different flags for managing bitrate and quality.

There are three primary methods to control the rate and quality: Variable Bitrate (VBR), Quality-Based VBR, and Constant Bitrate (CBR).


If your goal is to maintain a consistent visual quality regardless of the video content, use the quality-based method. This is the closest equivalent to the crf mode found in libx264.

In h264_videotoolbox, quality is controlled using the -q:v option. The scale ranges from 0 to 100, where higher numbers represent better quality.

ffmpeg -i input.mp4 -c:v h264_videotoolbox -q:v 65 output.mp4

2. Average Variable Bitrate (Bitrate Target)

If you need your output file to target a specific average file size, you should set a target bitrate using the -b:v option. The encoder will dynamically adjust the bitrate depending on the complexity of the scene, keeping the overall average close to your target.

ffmpeg -i input.mp4 -c:v h264_videotoolbox -b:v 5M output.mp4

To prevent extreme bitrate spikes that might cause playback issues on older hardware, you can cap the maximum bitrate using the -maxrate option:

ffmpeg -i input.mp4 -c:v h264_videotoolbox -b:v 5M -maxrate 7M output.mp4

3. Constant Bitrate (CBR)

Constant Bitrate is ideal for live streaming where network bandwidth is limited and strictly capped. To force h264_videotoolbox into CBR mode, you must set the target bitrate (-b:v) and the maximum bitrate (-maxrate) to the exact same value, while also configuring the buffer size (-bufsize).

ffmpeg -i input.mp4 -c:v h264_videotoolbox -b:v 4M -maxrate 4M -bufsize 8M output.mp4

Summary of Key Flags

FFmpeg Flag Description Values
-c:v h264_videotoolbox Enables the macOS hardware-accelerated H.264 encoder. N/A
-b:v Sets the target or average video bitrate. e.g., 4M, 5000k
-q:v Sets the target quality level (Constant Quality). 0 to 100
-maxrate Defines the maximum allowable bitrate limit. e.g., 6M
-bufsize Sets the rate control buffer size. e.g., 8M