Got HW Transcoding to work with libva/vaapi on Ryzen APU (Ryzen 7 4700U)

Thanks that’s right, I was trying to rely on the docker compose but forgot again that we weren’t specifying the libraries. That did fix the test.

This is AWESOME! Thanks so much for figuring this out. The hardware encoding seems to work great for me so far.

1 Like

Hello, in your image, when I tryng to transcoding a video file it shows that is working and cpu is slow, HW words show up, but in the plex container it shows this error :

/usr/share/libdrm/amdgpu.ids: No such file or directory

This is the full test log,

Splitting the commandline.
Reading option ‘-hide_banner’ … matched as option ‘hide_banner’ (do not show program banner) with argument ‘1’.
Reading option ‘-loglevel’ … matched as option ‘loglevel’ (set logging level) with argument ‘debug’.
Reading option ‘-vaapi_device’ … matched as option ‘vaapi_device’ (set VAAPI hardware device (DRM path or X11 display name)) with argument ‘/dev/dri/renderD128’.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option hide_banner (do not show program banner) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Applying option vaapi_device (set VAAPI hardware device (DRM path or X11 display name)) with argument /dev/dri/renderD128.
[AVHWDeviceContext @ 0x7fb8e812ba80] libva: VA-API version 1.16.0
[AVHWDeviceContext @ 0x7fb8e812ba80] libva: Trying to open /vaapi-amdgpu/lib/dri/radeonsi_drv_video.so
[AVHWDeviceContext @ 0x7fb8e812ba80] libva: Found init function __vaDriverInit_1_16
/usr/share/libdrm/amdgpu.ids: No such file or directory
[AVHWDeviceContext @ 0x7fb8e812ba80] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0x7fb8e812ba80] Initialised VAAPI connection: version 1.16
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x3231564e → nv12.
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x30313050 → p010le.
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x36313050 → unknown.
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x30323449 → yuv420p.
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x32315659 → yuv420p.
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x56595559 → unknown.
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x32595559 → yuyv422.
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x59565955 → uyvy422.
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x41524742 → bgra.
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x41424752 → rgba.
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x58524742 → bgr0.
[AVHWDeviceContext @ 0x7fb8e812ba80] Format 0x58424752 → rgb0.
[AVHWDeviceContext @ 0x7fb8e812ba80] VAAPI driver: Mesa Gallium driver 22.2.4 for AMD Radeon Graphics (raven, LLVM 15.0.5, DRM 3.35, 5.4.0-135-generic).
[AVHWDeviceContext @ 0x7fb8e812ba80] Driver not found in known nonstandard list, using standard behaviour.
Successfully parsed a group of options.
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…

Use -h to get full help or, even better, run ‘man ffmpeg’


EDIT: I created a path /usr/share/libdrm/ from host to container and the error is not there. is that ok?

Nice catch! I had the same message on my side but never noticed.

I just released a newer version of the mod that now includes amdgpu.ids

You just have to launch a new plex container and the updated mod will be downloaded automatically.

@war_lock and @InvisiGo that worth’s a try to see if that fixes your issues :crossed_fingers:

1 Like

No, that did not fix it.

Here’s what I just got from running the test command:

Splitting the commandline.
Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-vaapi_device' ... matched as option 'vaapi_device' (set VAAPI hardware device (DRM path or X11 display name)) with argument '/dev/dri/renderD128'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option hide_banner (do not show program banner) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Applying option vaapi_device (set VAAPI hardware device (DRM path or X11 display name)) with argument /dev/dri/renderD128.
[AVHWDeviceContext @ 0x7f4323660a80] libva: VA-API version 1.16.0
[AVHWDeviceContext @ 0x7f4323660a80] libva: Trying to open /vaapi-amdgpu/lib/dri/radeonsi_drv_video.so
[AVHWDeviceContext @ 0x7f4323660a80] libva: Found init function __vaDriverInit_1_16
[AVHWDeviceContext @ 0x7f4323660a80] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0x7f4323660a80] Initialised VAAPI connection: version 1.16
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x3231564e -> nv12.
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x30313050 -> p010le.
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x36313050 -> unknown.
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x30323449 -> yuv420p.
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x32315659 -> yuv420p.
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x56595559 -> unknown.
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x32595559 -> yuyv422.
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x59565955 -> uyvy422.
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x41524742 -> bgra.
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x41424752 -> rgba.
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x58524742 -> bgr0.
[AVHWDeviceContext @ 0x7f4323660a80] Format 0x58424752 -> rgb0.
[AVHWDeviceContext @ 0x7f4323660a80] VAAPI driver: Mesa Gallium driver 22.2.4 for AMD Radeon Vega 11 Graphics (raven, LLVM 15.0.5, DRM 3.46, 5.18.0-0.deb11.4-amd64).
[AVHWDeviceContext @ 0x7f4323660a80] Driver not found in known nonstandard list, using standard behaviour.
Successfully parsed a group of options.
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

Everything looks fine with the test, it should work within Plex too. By the way, it’s worth to know that HWAccel with AMDGPU is limited to h264 and hevc (h265).

For your reference, here’s the result on my side :

Splitting the commandline.
Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-vaapi_device' ... matched as option 'vaapi_device' (set VAAPI hardware device (DRM path or X11 display name)) with argument '/dev/dri/renderD128'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option hide_banner (do not show program banner) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Applying option vaapi_device (set VAAPI hardware device (DRM path or X11 display name)) with argument /dev/dri/renderD128.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] libva: VA-API version 1.16.0
[AVHWDeviceContext @ 0x7f7b60a1d2c0] libva: Trying to open /vaapi-amdgpu/lib/dri/radeonsi_drv_video.so
[AVHWDeviceContext @ 0x7f7b60a1d2c0] libva: Found init function __vaDriverInit_1_16
[AVHWDeviceContext @ 0x7f7b60a1d2c0] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Initialised VAAPI connection: version 1.16
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x3231564e -> nv12.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x30313050 -> p010le.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x36313050 -> unknown.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x30323449 -> yuv420p.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x32315659 -> yuv420p.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x56595559 -> unknown.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x32595559 -> yuyv422.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x59565955 -> uyvy422.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x41524742 -> bgra.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x41424752 -> rgba.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x58524742 -> bgr0.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Format 0x58424752 -> rgb0.
[AVHWDeviceContext @ 0x7f7b60a1d2c0] VAAPI driver: Mesa Gallium driver 22.2.4 for AMD Radeon 500 Series (polaris12, LLVM 15.0.5, DRM 3.40, 5.10.146).
[AVHWDeviceContext @ 0x7f7b60a1d2c0] Driver not found in known nonstandard list, using standard behaviour.
Successfully parsed a group of options.
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'
LLVM triggered Diagnostic Handler: non-trivial scalar-to-vector conversion

The main difference between yours :

VAAPI driver: Mesa Gallium driver 22.2.4 for AMD Radeon Vega 11 Graphics (raven, LLVM 15.0.5, DRM 3.46, 5.18.0-0.deb11.4-amd64).

And mine :

VAAPI driver: Mesa Gallium driver 22.2.4 for AMD Radeon 500 Series (polaris12, LLVM 15.0.5, DRM 3.40, 5.10.146).

Is the AMD chipset driver : Radeon Vega 11 (raven) vs Radeon 500 (polaris).

FYI I just published a new version which includes libdrm.so from alpine:edge instead of relying on Plex’s version of the library. I don’t think that should have any effect, but who knows. It’s really a hit and miss process at this point.

You probably can’t do anything about this, but for some videos when I am streaming with transcoding, I get these errors:

Dec 05, 2022 20:40:05.171 [0x7f70fe8a2b38] ERROR - [Req#264d/Transcode/d3fe440ea5030603-com-plexapp-android/4e77662f-55e2-4556-a174-4fefecabbbaf] [AVHWDeviceContext @ 0x7fc0c108ff40] Failed to get number of OpenCL platforms: -1001.
Dec 05, 2022 20:40:05.172 [0x7f7100290b38] ERROR - [Req#2657/Transcode/d3fe440ea5030603-com-plexapp-android/4e77662f-55e2-4556-a174-4fefecabbbaf] [AVHWDeviceContext @ 0x7fc0c108ff40] Failed to get number of OpenCL platforms: -1001.
Dec 05, 2022 20:40:05.173 [0x7f70ff2fcb38] ERROR - [Req#2658/Transcode/d3fe440ea5030603-com-plexapp-android/4e77662f-55e2-4556-a174-4fefecabbbaf] [Parsed_hwmap_2 @ 0x7fc0c0c26400] Failed to created derived device context: -19.
Dec 05, 2022 20:40:05.174 [0x7f70fe49cb38] ERROR - [Req#2659/Transcode/d3fe440ea5030603-com-plexapp-android/4e77662f-55e2-4556-a174-4fefecabbbaf] [Parsed_hwmap_2 @ 0x7fc0c0c26400] Failed to configure output pad on Parsed_hwmap_2
Dec 05, 2022 20:40:05.182 [0x7f7101995b38] ERROR - [Req#265a/Transcode/d3fe440ea5030603-com-plexapp-android/4e77662f-55e2-4556-a174-4fefecabbbaf] Error reinitializing filters!
Dec 05, 2022 20:40:05.183 [0x7f70fe8a2b38] ERROR - [Req#265b/Transcode/d3fe440ea5030603-com-plexapp-android/4e77662f-55e2-4556-a174-4fefecabbbaf] Failed to inject frame into filter network: Error number -19 occurred
Dec 05, 2022 20:40:05.186 [0x7f7100290b38] ERROR - [Req#265c/Transcode/d3fe440ea5030603-com-plexapp-android/4e77662f-55e2-4556-a174-4fefecabbbaf] Error while processing the decoded data for stream #0:0
Dec 05, 2022 20:40:18.360 [0x7f7102a00b38] WARN - [Req#279d/Transcode/d3fe440ea5030603-com-plexapp-android] Transcode runner appears to have died.
Dec 05, 2022 20:40:19.675 [0x7f7100290b38] WARN - [Req#27fb] QueryParser: Invalid field 'contentDirectoryID' found, ignoring.
Dec 05, 2022 20:40:19.675 [0x7f7100290b38] WARN - [Req#27fb] QueryParser: Invalid field 'pinnedContentDirectoryID' found, ignoring.
Dec 05, 2022 20:40:19.677 [0x7f7100290b38] WARN - [Req#27fb] QueryParser: Invalid field 'contentDirectoryID' found, ignoring.
Dec 05, 2022 20:40:19.677 [0x7f7100290b38] WARN - [Req#27fb] QueryParser: Invalid field 'pinnedContentDirectoryID' found, ignoring.

I have other files that hw transcode fine, so it seems weird/random and maybe that’s just how it is.

1 Like

I probably can’t help on this one.

There is an advanced setting in Plex to enable more verbose Transcoder (ffmpeg) log level by setting TranscoderLogLevel to verbose.
https://support.plex.tv/articles/201105343-advanced-hidden-server-settings/

I guess it could help you to understand what the problem might be.

Its me again, I thought everything works fine but, when I wanted to transcoding from Firetv or Android device it doesnt work anymore. Only works on Plex Web. But using the hexeth docker it works perfect on all device. What should wrong?. Thanks in advanced.

same for my container

are you getting color flashes with hexeths image though or does everything work perfectly?

I can confirm though that it also only works on Plex web for me, it does not work on AppleTV or on an iPhone, not working meaning it does it in CPU, not in hw.
it also seems that even on web some movies are not done in hw in all qualities for some reason

mauimauer image works good so I assume it has something to do with alpine being used as the base?

Same here with Unraid 6.11.5!
Did you get any luck with it? I’ve tried different encoding and resolution but HW doesn’t trigger.

I’ll have a look at the logs asap

I don’t know if it’s helpful. FWIW, I am able to successfully transcode a few files on any platform (I tried a 4k LOTR TTT and it will hw encode on web and Android at least). This file won’t on any platform (Amazing Spiderman 4k). Here are the verbose logs when transcoding starts:

Here is the log for a file that successfully gets hardware transcoded.

The main difference I see between these two use cases is the presence of these errors (that I saw some of without verbose logging when transcoding this same file)

Dec 06, 2022 08:45:21.241 [0x7f50e931db38] ERROR - [Req#d1f/Transcode/d3fe440ea5030603-com-plexapp-android/e17777b4-a28d-4bc8-ac1d-0b1b105347c6] [AVHWDeviceContext @ 0x7f3b4afdc940] Failed to get number of OpenCL platforms: -1001.
Dec 06, 2022 08:45:21.242 [0x7f50eb6e1b38] ERROR - [Req#d20/Transcode/d3fe440ea5030603-com-plexapp-android/e17777b4-a28d-4bc8-ac1d-0b1b105347c6] [AVHWDeviceContext @ 0x7f3b4afdc940] Failed to get number of OpenCL platforms: -1001.
Dec 06, 2022 08:45:21.242 [0x7f50e911ab38] ERROR - [Req#d21/Transcode/d3fe440ea5030603-com-plexapp-android/e17777b4-a28d-4bc8-ac1d-0b1b105347c6] [Parsed_hwmap_2 @ 0x7f3b4af84980] Failed to created derived device context: -19.
Dec 06, 2022 08:45:21.242 [0x7f50e931db38] ERROR - [Req#d22/Transcode/d3fe440ea5030603-com-plexapp-android/e17777b4-a28d-4bc8-ac1d-0b1b105347c6] [Parsed_hwmap_2 @ 0x7f3b4af84980] Failed to configure output pad on Parsed_hwmap_2
Dec 06, 2022 08:45:21.253 [0x7f50eb6e1b38] ERROR - [Req#d23/Transcode/d3fe440ea5030603-com-plexapp-android/e17777b4-a28d-4bc8-ac1d-0b1b105347c6] Error reinitializing filters!
Dec 06, 2022 08:45:21.253 [0x7f50e911ab38] ERROR - [Req#d24/Transcode/d3fe440ea5030603-com-plexapp-android/e17777b4-a28d-4bc8-ac1d-0b1b105347c6] Failed to inject frame into filter network: Error number -19 occurred
Dec 06, 2022 08:45:21.253 [0x7f50e931db38] ERROR - [Req#d25/Transcode/d3fe440ea5030603-com-plexapp-android/e17777b4-a28d-4bc8-ac1d-0b1b105347c6] Error while processing the decoded data for stream #0:0
Dec 06, 2022 08:45:21.253 [0x7f50eb6e1b38] WARN - [Req#d26/Transcode/d3fe440ea5030603-com-plexapp-android/e17777b4-a28d-4bc8-ac1d-0b1b105347c6] [libopus @ 0x7f3b4d3bd040] 1 frames left in the queue on closing
Dec 06, 2022 08:45:21.281 [0x7f50e931db38] INFO - [Req#d28/Transcode/d3fe440ea5030603-com-plexapp-android/e17777b4-a28d-4bc8-ac1d-0b1b105347c6] Conversion failed!

edit: I searched for some of those errors and it pointed me at HDR tone mapping issues. I disabled that and now more things are being hardware transcoded.

edit2: this issue was actually mentioned earlier in the thread with mauimauer’s image Got HW Transcoding to work with libva/vaapi on Ryzen APU (Ryzen 7 4700U) - #9 by matzemink So at least this is at parity with that :wink:

Great finding!

Thanks for this explanation!!!

I have Plex installed on Proxmox LXC. I 've updated today to plexmediaserver version 1.30.0.6486-629d58034, copied again the libs as you said and hw acceleration it’s still working.

AMD Ryzen 5 PRO 3400GE
vainfo: Driver version: Mesa Gallium driver 22.3.0-devel for RAVEN (raven, LLVM 15.0.3, DRM 3.42, 5.15.74-1-pve)

noob here :slight_smile:

Can anyone summarize/post a quick guide again as I went through this forum, installed the docker in unraid, added settings in /boot/config/go file…still no dice :frowning: .

AMD 5600G, unraid 6.11.0

many thanks!

I would suggest to read the posts, try it out and post results
There hasnt been a definite “works for all” yet so you either participate in the trial and error or wait until (IF) there is a definite working and maintained image…
as a first you might want to check if the (not maintained) version from mauimauer works for you

I guess I’ve tried most of them including mauimauer image, no dice. I gave up, just added an old nvidia card (gtx 1050ti) and it works. Too bad that only Intel and nvidia are well supported but not AMD, they deserve more love

This works with the standard linuxio docker image. Confirmed working with a 7950x igpu today

1 Like

yes, for the lsio based image, this is the best solution, still has some caveats afaik
not all video formats work, does not work on all players (like AppleTV) and falls back to either direct play or cpu decoding
HDR tone mapping needs to be disabled

functionality wise, the last original image from mauimauer works best but unfortunately its not regularly maintained