Skip to content

Instantly share code, notes, and snippets.

@danielrosehill
Created December 4, 2025 15:04
Show Gist options
  • Select an option

  • Save danielrosehill/44f73b699057667fda8bd4214d9f0db9 to your computer and use it in GitHub Desktop.

Select an option

Save danielrosehill/44f73b699057667fda8bd4214d9f0db9 to your computer and use it in GitHub Desktop.
FFmpeg GPU-accelerated video compression using VA-API (AMD RX 7700 XT on Ubuntu 25.04)

FFmpeg GPU-Accelerated Video Compression (VA-API / AMD)

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

Basic Compression Command

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

Parameters Explained

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

With Color Correction

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.mp4

Color Filter Options

  • eq=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 boost
  • eq=contrast=1.1 - Increase contrast by 10%

Check VA-API Support

vainfo

Look for VAEntrypointEncSlice entries for H264/HEVC to confirm encoding support.

Performance

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.

Comments are disabled for this gist.