FFmpeg h264_amf Rate Control and Quality Settings

This guide explains how to configure rate control and quality options for the h264_amf encoder in FFmpeg. The h264_amf encoder utilizes AMD’s Advanced Media Framework (AMF) to leverage hardware-accelerated H.264 video encoding on AMD Radeon graphics cards. Below, you will find the essential parameters, rate control modes, and command-line examples needed to optimize your encoding workflow for quality, speed, or file size.

Rate Control Modes (-rc)

The rate control mode determines how the encoder allocates bitrate across the video. You can set the rate control mode using the -rc parameter. The most common modes for h264_amf include:


Configuring Quality and Bitrate Options

Depending on your chosen rate control mode, you will need to adjust different parameters to control the output quality.

1. Constant Quality (CQP Mode)

To use Constant QP, set -rc to cqp and define the QP (Quantization Parameter) values for I-frames and P-frames. QP values range from 0 to 51, where lower values mean higher quality and larger file sizes (a value of 18–23 is generally recommended for visually lossless quality).

Example command:

ffmpeg -i input.mp4 -c:v h264_amf -rc cqp -qp_i 22 -qp_p 22 output.mp4

2. Constant Bitrate (CBR Mode)

To use CBR, set -rc to cbr and specify your target bitrate using the -b:v flag.

Example command:

ffmpeg -i input.mp4 -c:v h264_amf -rc cbr -b:v 5M output.mp4

3. Variable Bitrate (VBR Peak Mode)

To use VBR with a peak limit, set -rc to vbr_peak. You must define both the target average bitrate (-b:v) and the maximum allowed peak bitrate (-maxrate).

Example command:

ffmpeg -i input.mp4 -c:v h264_amf -rc vbr_peak -b:v 4M -maxrate 8M output.mp4

Performance and Quality Presets (-quality)

The -quality option allows you to balance encoding speed against compression efficiency. AMD AMF supports three primary quality presets:

Example command using the quality preset:

ffmpeg -i input.mp4 -c:v h264_amf -rc vbr_peak -b:v 5M -maxrate 10M -quality quality output.mp4

Profile and Level Settings

To ensure compatibility with specific playback devices, you can set the H.264 profile and level:

Example command:

ffmpeg -i input.mp4 -c:v h264_amf -profile:v high -level 4.1 output.mp4