amg video convert ffmpeg linux

Linux/Mac: Ffmpeg render/convert or export video using AMD GPU Graphics Card in Arch Linux, Mint, Debian, Manjaro

To use your GPU rather than your CPU to convert videos under AMD architecture, you need to use va-api, video acceleration API.

51 seconds using CPU 100fps 21mb file-size
34 seconds using GPU 130fps 42mb file-size


# VA-API for Radeon HD 2000 and newer require libva-mesa-driver
# VDPAU for Radeon R300 and newer require mesa-vdpau
# libva-vdpau-driver
# you can just install both

# arch manjaro
sudo pacman -S libva-mesa-driver mesa-vdpau libva-vdpau-driver

# debian ubuntu
apt install mesa-va-drivers -y

You may need to reboot in order for the kernel to load with the new updates.

This will install a library a library for

After installing libva vdpau drivers for mesa, you will have a device driver that you can reference in ffmpeg /dev/dri/renderD128

Convert ffmpeg files using your AMD Graphics Card, Laptop Radeon Vega Mobile works too.

Initialize the device

# init device
ffmpeg -init_hw_device vaapi=gpu:/dev/dri/renderD128

Now you can convert with the GPU:

ffmpeg -i "$IN_VIDEO" -vaapi_device /dev/dri/renderD128 -vcodec h264_vaapi -vf format='nv12|vaapi,hwupload' "$OUT_VIDEO"

How to tell if my GPU is being used to convert videos using the gpu?

Run two tests.

# test 1
ffmpeg -i in.mp4 normal.mp4

# test 2
ffmpeg -i in.mp4 -vaapi_device /dev/dri/renderD128 -vcodec h264_vaapi -vf format='nv12|vaapi,hwupload' accelerated.mp4
cpu ffmpeg high usage
cpu ffmpeg high usage
amd video gpu ffmpeg video convert
amd video gpu ffmpeg video convert

The GPU accelerated version using AMD Ryzen 5 3500U with Radeon Vega finished before we could even get a decent CPU reading!

Leave a Reply

Your email address will not be published. Required fields are marked *