To use your GPU rather than your CPU to convert videos under AMD architecture, you need to use va-api, video acceleration API.
Results:
51 seconds using CPU 100fps 21mb file-size
34 seconds using GPU 130fps 42mb file-size
Requirements:
# 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:
IN_VIDEO=video1.mp4 OUT_VIDEO=video2.mp4 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
The GPU accelerated version using AMD Ryzen 5 3500U with Radeon Vega finished before we could even get a decent CPU reading!
My AMD 4500u Laptop has a Performance setting in the BOIS. It did not make a difference. I’m going back to the balanced setting. Just that you may find it interesting.
I forgot to mention that the CPU runs cooler also
Do you have a good way to cut all the extra audio. I record off the air programing. All examples fail I’ve found fails for me.
Even if I could do that ahead of time,
I edit all video nowadays using Shotcut exclusively. You can mute audio tracks, among other things. It’s basically an ffmpeg wrapper.
Worked perfect on my laptop. – Amd 4500U
Before speed=1.5
After speed-2.4
I didn’t think a moble APU had the funtion to do this.
Glad to hear it worked! I noticed the quality changed between cards which was interesting too. Speed change was awesome though.