• Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
No Result
View All Result
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
No Result
View All Result
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
No Result
View All Result
Home Tutorials

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

by Sick Codes
April 25, 2020 - Updated on June 24, 2020
in Tutorials
5
amg video convert ffmpeg linux

amg video convert ffmpeg linux

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
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!

Next Post

Install Fail2Ban on CentOS 8, 9. Works on RHEL 8 and RHEL 9 too.

Add Swap Memory On Ubuntu/Arch/Debian (Any OS, one liner!)

One Liner: ULTIMATE Kubernetes Install! K3s! Ubuntu, CentOS, Debian, RHEL. Best k8s, minikube, okd, Openshift Alternative.

Comments 5

  1. Aaron says:
    2 years ago

    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.

    Reply
  2. DALE BURRELL says:
    2 years ago

    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,

    Reply
    • Sick Codes says:
      2 years ago

      I edit all video nowadays using Shotcut exclusively. You can mute audio tracks, among other things. It’s basically an ffmpeg wrapper.

      Reply
  3. Aaron says:
    2 years ago

    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.

    Reply
    • Sick Codes says:
      2 years ago

      Glad to hear it worked! I noticed the quality changed between cards which was interesting too. Speed change was awesome though.

      Reply

Leave a Reply Cancel reply

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

No Result
View All Result
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training

© 2017-2021 Sick.Codes

@sickcodes

@sickcodes

@sickcodes

Discord Server

sickcodes.slack.com

t.me/sickcodeschat

./contact_form