Compress video using hardware-accelerated H.264 encoding on AMD GPUs via VA-API.
Tested on: AMD Radeon RX 7700 XT (Navi 32, gfx1101) / Ubuntu 25.04
ffmpeg -vaapi_device /dev/dri/renderD128 \
-i input.mp4 \
-vf "format=nv12,hwupload" \
-c:v h264_vaapi -qp 23 \
-c:a aac -b:a 128k \
-movflags +faststart \
output.mp4| Parameter | Description |
|---|---|
-vaapi_device /dev/dri/renderD128 |
Use AMD GPU for hardware encoding |
-vf "format=nv12,hwupload" |
Convert to NV12 format and upload to GPU |
-c:v h264_vaapi |
Use VA-API H.264 encoder |
-qp 23 |
Quality level (lower = better quality, larger file; 18-28 typical range) |
-c:a aac -b:a 128k |
AAC audio at 128 kbps |
-movflags +faststart |
Move metadata to start for web streaming |
ffmpeg -vaapi_device /dev/dri/renderD128 \
-i input.mp4 \
-vf "eq=saturation=1.2,colorbalance=rs=0.05:bs=-0.05,format=nv12,hwupload" \
-c:v h264_vaapi -qp 20 \
-c:a copy \
output.mp4eq=saturation=1.2- Boost saturation by 20% (1.0 = normal)colorbalance=rs=0.05:bs=-0.05- Warm up whites (reduce blue, add red)eq=brightness=0.05- Slight brightness boosteq=contrast=1.1- Increase contrast by 10%
vainfoLook for VAEntrypointEncSlice entries for H264/HEVC to confirm encoding support.
On AMD RX 7700 XT (Ubuntu 25.04), expect ~400 fps encoding speed (vs ~130 fps with CPU libx264) - approximately 3x faster.
This gist was generated by Claude Code. Please verify commands and parameters for your specific use case.
This gist was generated by Claude Code. Please verify any information before relying on it.