How to Transcode Video Using h264_amf in FFmpeg
This article provides a straightforward guide on how to transcode
videos using the AMD Advanced Media Framework (AMF) hardware-accelerated
H.264 encoder (h264_amf) in FFmpeg. You will learn the
basic command-line syntax, essential configuration parameters like
bitrate and quality presets, and how to verify that your system supports
AMD hardware acceleration for faster video processing.
Prerequisites
To use h264_amf, you must have: * An AMD Radeon graphics
card that supports hardware-accelerated H.264 encoding. * Compatible AMD
graphics drivers installed on your system. * A version of FFmpeg
compiled with AMF support (enabled by default in most modern Windows
builds).
To verify that your FFmpeg installation supports the AMD encoder, run the following command in your terminal:
ffmpeg -encoders | grep amf(On Windows PowerShell, use
ffmpeg -encoders | Select-String amf)
If supported, you will see h264_amf listed in the
output.
Basic Transcoding Command
The simplest command to transcode an input video to H.264 using AMD hardware acceleration is:
ffmpeg -i input.mp4 -c:v h264_amf output.mp4In this command: * -i input.mp4 specifies the source
video file. * -c:v h264_amf tells FFmpeg to use the AMD
H.264 hardware encoder for the video stream. * output.mp4
is the destination file.
Advanced Configuration Parameters
To achieve the best balance between file size and video quality, you can customize the encoding parameters.
1. Controlling Bitrate
By default, the encoder uses a variable bitrate. You can manually set
the target video bitrate using the -b:v flag:
ffmpeg -i input.mp4 -c:v h264_amf -b:v 5M output.mp4This limits the video stream to a bitrate of 5 Megabits per second (5M).
2. Quality Presets
The h264_amf encoder offers preset options to prioritize
either encoding speed or visual quality. Use the -quality
option with one of the following values: speed,
balanced, or quality.
ffmpeg -i input.mp4 -c:v h264_amf -quality quality output.mp43. Rate Control Modes
You can define how the encoder manages the bitrate using the
-rc parameter. Common modes include: * cbr
(Constant Bitrate) * vbr (Variable Bitrate) *
cqp (Constant QP / Constant Quality)
For example, to use Constant QP mode for consistent visual quality (where lower QP values mean higher quality):
ffmpeg -i input.mp4 -c:v h264_amf -rc cqp -qp_i 22 -qp_p 22 output.mp4Complete Practical Example
This command transcodes a video using AMD AMF acceleration, sets a target bitrate of 8 Mbps, applies the high-quality preset, and copies the original audio track without re-encoding it:
ffmpeg -i input.mp4 -c:v h264_amf -b:v 8M -quality quality -c:a copy output.mp4