Encode with VAAPI on AMD GPUs
Select device = "vaapi" on a transcoder to encode on an AMD GPU through VAAPI, using
Mesa's radeonsi driver. Automatic device selection considers VAAPI only when the
environment variable VAAPI_AUTO_SELECT is 1, true or yes. Audio remains a separate software
encoding path.
VAAPI runs in a dedicated Packager image variant with the AMD (radeonsi) and Intel
(iHD) driver stacks. Ask which integrations it includes when you request it.
Contact Vindral support for access.
Encoders and defaults
| Encoder | Codec | Profile default |
|---|---|---|
h264_vaapi | H.264 | high for 8-bit 4:2:0; otherwise left to the encoder |
hevc_vaapi | HEVC | main, or main10 above 8 bits |
av1_vaapi | AV1 | main |
All three get async_depth=1 and bf=0. A bf in the rendition options, or
max_b_frames on the rendition, takes precedence. A generic profile = "baseline" is
passed to h264_vaapi as constrained_baseline.
Scaling uses scale_vaapi and deinterlacing deinterlace_vaapi, with a software
fallback when the build lacks the filter. H.264 and HEVC sources decode on the GPU;
AV1 sources decode in software. Frames are uploaded as NV12, or P010 above 8 bits; a
rendition that pins format = "yuv420p" is carried as NV12.
[[transcoders]]
id = "vaapi-transcoder"
source_ids = ["input"]
device = "vaapi"
[[transcoders.tracks]]
type = "video"
id = "video"
track_selector = { type = "track-kind", kind = "video" }
[[transcoders.tracks.renditions]]
id = "h264-720p"
codec = "h264"
encoder_name = "h264_vaapi"
gop_size_ms = 1000
bit_rate = 3_000_000
size = { width = 1280, height = 720 }
Device selection
| Variable | Effect |
|---|---|
VAAPI_DEVICE | Render node used for VAAPI by all transcoders in the process, for example /dev/dri/renderD128. Set it on any host with more than one render node; otherwise FFmpeg opens the first node it finds, which may be an Intel iGPU. |
VAAPI_AUTO_SELECT | 1, true or yes (any case) lets automatic device selection choose VAAPI. The Packager checks once per process that a VAAPI device can be created. Devices with load measurements rank first, then VAAPI, then CPU. |
Automatic detection matches only AMD render nodes (PCI vendor 0x1002); on Intel GPUs,
use QSV. An explicit device = "vaapi" does not need
VAAPI_AUTO_SELECT and drives any VAAPI device, Intel included.
The user running the Packager must be a member of the render group. Find the AMD render
node and check which codecs the driver can encode:
for node in /sys/class/drm/renderD*; do
printf '%s: ' "${node##*/}"
cat "$node/device/vendor"
done
export VAAPI_DEVICE=/dev/dri/renderD128 # the node that printed 0x1002
vainfo --display drm --device "$VAAPI_DEVICE" | grep EncSlice
Run the container
Pass the render node at its original path, together with the variable:
docker run --rm \
--device "$VAAPI_DEVICE" -e VAAPI_DEVICE \
--group-add "$(stat -c '%g' "$VAAPI_DEVICE")" \
-p 127.0.0.1:4040:4040 \
-v "$(pwd)/config.toml:/etc/packager/config.toml:ro" \
"${PACKAGER_IMAGE:?Set PACKAGER_IMAGE to the VAAPI-capable image}" start
Add -e VAAPI_AUTO_SELECT=1 if the configuration relies on automatic selection, and
-e LIBVA_DRIVER_NAME=radeonsi to force the AMD driver.
Supported configurations
| Area | Use |
|---|---|
| Keyframes | The rendition's gop_size_ms. VAAPI encoders keep their own keyframe cadence, so gop_alignment = "match_incoming" is not available on them. |
| Input bit depth | 8-bit input. |
| Several renditions | Hardware filtering, the default. |
| Deinterlacing to field rate | deinterlace_vaapi by default; it drops a fixed number of frames per rendition (6 on radeonsi, 2 on Intel iHD). For an exact frame count, use the software deinterlacer (hw_filtering_enabled = false) with one rendition. |
| AV1 source | Decoded in software (libdav1d); AV1 output encodes as usual. |