How to Transcode Video to AV1 Using AMD Radeon Hardware Acceleration Using FFmpeg

These commands transcode a video to AV1 using AMD Radeon VAAPI hardware acceleration. They were tested with a Radeon RX 7800 XT.

Your Radeon card must have the AV1 encoder hardware installed, this is only the case for RDNA3/Navi33 architectures, ie Radeon 7600++ - earlier RDNA2 cards have only the AV1 decoder installed, not the encoder

Speed-optimized command

Use this when you want to have super fast encoding speed (approximately 100% playback speed on 4K video on Radeon 7800 XT):

transcode_av1_speed.sh
LIBVA_DRIVER_NAME=radeonsi ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i input.mp4 -c:v av1_vaapi -rc_mode CQP -global_quality:v 105 -c:a copy output-av1.mkv

Replace input.mp4 and output-av1.mkv with your file names. The default render device is /dev/dri/renderD128; if you are not sure which device belongs to your Radeon card, see How to Identify Which /dev/dri/renderD Device Is Your AMD Radeon GPU.

What the flags do

  • LIBVA_DRIVER_NAME=radeonsi forces the Radeon VAAPI driver. You may not need this on every distribution, but it helps when multiple GPU drivers are installed.
  • -hwaccel vaapi enables hardware-accelerated decoding.
  • -hwaccel_device /dev/dri/renderD128 points FFmpeg at the default DRM render node.
  • -hwaccel_output_format vaapi keeps the decoded frames in video memory so the encoder can read them directly.
  • -c:v av1_vaapi selects the AV1 VAAPI encoder.
  • -rc_mode CQP uses constant-quantizer (CQP) rate control.
  • -global_quality:v 105 sets the encoder quality. Lower is higher quality and larger file; higher is smaller and lower quality.
  • -c:a copy copies the audio stream without re-encoding.

File-size optimized command

For smaller files at the cost of encoding speed, use a higher global_quality and force the encoder to work harder with a pre-encode pass, VBAQ, B-frames and an extended GOP:

transcode_av1_optimized.sh
LIBVA_DRIVER_NAME=radeonsi ffmpeg \
  -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi \
  -i input.mp4 \
  -c:v av1_vaapi -rc_mode CQP -global_quality:v 140 \
  -compression_level 29 \
  -bf 4 \
  -g 240 \
  -c:a copy \
  output-av1.mkv

This example uses the default render node. If your Radeon is at a different device, override RENDER_DEVICE or use the device found in How to Identify Which /dev/dri/renderD Device Is Your AMD Radeon GPU.

Wrapper script

Save this as transcode-av1-radeon.sh and run it with the input file; it will automatically write <basename>-av1.mkv next to the input:

transcode-av1-radeon.sh
#!/bin/bash
set -euo pipefail

RENDER_DEVICE="${RENDER_DEVICE:-/dev/dri/renderD128}"

if [ $# -ne 1 ]; then
    echo "Usage: $0 <input video>" >&2
    exit 1
fi

input="$1"
base="${input%.*}"
output="${base}-av1.mkv"

LIBVA_DRIVER_NAME=radeonsi ffmpeg \
  -hwaccel vaapi -hwaccel_device "$RENDER_DEVICE" -hwaccel_output_format vaapi \
  -i "$input" \
  -c:v av1_vaapi -rc_mode CQP -global_quality:v 140 \
  -compression_level 29 \
  -bf 4 \
  -g 240 \
  -c:a copy \
  "$output"

Example:

example_usage.sh
chmod +x transcode-av1-radeon.sh
./transcode-av1-radeon.sh input.mp4
# Produces input-av1.mkv

Use a different render node by exporting it:

example_render_device.sh
RENDER_DEVICE=/dev/dri/renderD129 ./transcode-av1-radeon.sh input.mp4

What the extra flags do

  • -global_quality:v 140: Targets “below standard quality” in the table, sacrificing some fidelity for a smaller file.
  • -compression_level 29: Uses a bitmask that enables the Quality preset, a pre-encode analysis pass and Variance-Based Adaptive Quantization (VBAQ). The pre-encode pass collects per-frame statistics, and VBAQ redistributes bits away from flat/simple regions toward areas where the human eye is more likely to notice detail.
  • -bf 4: Enables 4 B-frames. B-frames are not used by default because they slow encoding, but they improve compression by looking both backward and forward in time for motion.
  • -g 240: Extends the GOP/keyframe interval to roughly 8 seconds at 30 FPS. Fewer I-frames means more consecutive P/B frames, which are much smaller.

Quality / bitrate guidance

The global_quality scale for av1_vaapi is 0–255, which is different from the 0–63 CRF scale used by CPU AV1 encoders. These are approximate mappings; always test with your own source:

Target qualityCPU CRF (0–63)av1_vaapi global_quality (0–255)Typical 720pTypical 1080pTypical 4KTypical 8K
High quality / near-transparent2080~3 – 5 Mbps~6 – 9 Mbps~25 – 35 Mbps~80 – 120 Mbps
Standard quality (recommended)26105~1.5 – 2.5 Mbps~3 – 5 Mbps~12 – 18 Mbps~40 – 60 Mbps
Moderate compression30120~1 – 1.8 Mbps~2 – 3.5 Mbps~8 – 12 Mbps~25 – 40 Mbps
Below standard quality35140~0.5 – 1 Mbps~1 – 2 Mbps~4 – 7 Mbps~12 – 25 Mbps
High compression / archival low40160~0.3 – 0.6 Mbps~0.6 – 1.2 Mbps~2 – 4 Mbps~6 – 12 Mbps

The bitrates for 720p, 1080p and 8K are rough estimates scaled from the 4K values; always test with your own source.

Confirming AV1 hardware encoding is available

Check the relevant part of vainfo:

vainfo_output.txt
      VAProfileAV1Profile0            :	VAEntrypointVLD
      VAProfileAV1Profile0            :	VAEntrypointEncSlice

On this machine vainfo reports the AMD driver as:

vainfo_driver.txt
vainfo: Driver version: Mesa Gallium driver 26.0.8-1ubuntu0.3 for AMD Radeon RX 7800 XT (radeonsi, navi32, ACO, DRM 3.64, 7.0.0-31-generic)

Verification on this computer

Both commands were run against a short 1920×1080 test clip. The default (speed) command produced:

transcode_output_speed.txt
Output #0, matroska, to 'testsrc_av1_q105.mkv':
  Stream #0:0: Video: av1 (Main) (AV01 / 0x31305641), vaapi(tv, progressive), 1920x1080, q=2-31, 30 fps
  Stream #0:1: Audio: aac (LC), 44100 Hz, mono, fltp, 69 kb/s
[out#0/matroska] video:82KiB audio:43KiB ... bitrate= 208.9kbits/s speed=16x

The file-size optimized command produced:

transcode_output_optimized.txt
Output #0, matroska, to 'testsrc_optimized.mkv':
  Stream #0:0: Video: av1 (Main) (AV01 / 0x31305641), vaapi(tv, progressive), 1920x1080, q=2-31, 30 fps
  Stream #0:1: Audio: aac (LC), 44100 Hz, mono, fltp, 69 kb/s
[out#0/matroska] video:63KiB audio:43KiB ... bitrate= 178.5kbits/s speed=6.26x

On this simple clip the optimized command reduced the video bitrate by roughly 15% while running at about one third the speed.

On this particular PC the Radeon card is actually /dev/dri/renderD129 because /dev/dri/renderD128 belongs to the integrated Intel GPU. Always use the device that vainfo reports as your Radeon card.


Check out similar posts by category: Video Linux