Server Version#: 1.32.2.7100
I am not sure which server version broke the hw transcoding on my Intel NUC iGPU but I suspect it started a few versions ago (noisy fan because of software transcoding).
To give a bit more context:
- HW transcoding was working before
- Suddenly it did not
- Was using Ubuntu 20.04, I though that plex did receive an update requiring more update date packages
- Upgraded to Ubuntu 22.04 - still not working
- Everything fine with users/groups/access to
/dev/dri/renderD128 - manual run of
ffmpegwith vaapi is working fineffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -i /path/to/file.mkv -f null - - Updated to latest stable all intel drivers/packages (compute, media and display runtime from here which gave a nice boost of hw capability: got 6x in ffmpeg with ubuntu packages, ~8x with intel latest) - still not working in plex
VAAPI not working in plex
The journey started with debug/verbose logs:
Jun 03, 2023 21:17:52.436 [140500955691832] DEBUG - [Req#15ba/Transcode] Codecs: testing hevc (decoder) with hwdevice vaapi
Jun 03, 2023 21:17:52.436 [140500955691832] VERBOSE - [Req#15ba/Transcode] [FFMPEG] - Rescanning for external libs: '/data/plex/Plex\ Media\ Server/Codecs/8217c1c-4565-linux-x86_64/'
Jun 03, 2023 21:17:52.436 [140500955691832] DEBUG - [Req#15ba/Transcode] Codecs: hardware transcoding: testing API vaapi
Jun 03, 2023 21:17:52.437 [140500955691832] VERBOSE - [Req#15ba/Transcode] [FFMPEG] - Trying to use DRM render node for device 0.
Jun 03, 2023 21:17:52.437 [140500955691832] VERBOSE - [Req#15ba/Transcode] [FFMPEG] - libva: VA-API version 1.18.0
Jun 03, 2023 21:17:52.437 [140500955691832] VERBOSE - [Req#15ba/Transcode] [FFMPEG] - libva: User requested driver 'i965'
Jun 03, 2023 21:17:52.437 [140500955691832] VERBOSE - [Req#15ba/Transcode] [FFMPEG] - libva: Trying to open /data/plex/Plex Media Server/Cache/va-dri-linux-x86_64/i965_drv_video.so
Jun 03, 2023 21:17:52.437 [140500955691832] VERBOSE - [Req#15ba/Transcode] [FFMPEG] - libva: va_openDriver() returns -1
Jun 03, 2023 21:17:52.437 [140500955691832] ERROR - [Req#15ba/Transcode] [FFMPEG] - Failed to initialise VAAPI connection: -1 (unknown libva error).
Jun 03, 2023 21:17:52.437 [140500955691832] DEBUG - [Req#15ba/Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: I/O error
It seems that plex is trying to open /data/plex/Plex Media Server/Cache/va-dri-linux-x86_64/i965_drv_video.so to use vaapi which fails and therefor fallback to software decoding.
I/O error is actually nothing fancy:
d@nucsrv:/data/plex/Plex Media Server/Cache/va-dri-linux-x86_64$ ls -lha
total 8.0K
drwxr-xr-x 1 plex plex 66 Jun 3 21:52 .
drwxr-xr-x 1 plex plex 692 Jun 3 21:43 ..
lrwxrwxrwx 1 plex plex 77 Jun 3 21:52 iHD_drv_video.so -> '/data/plex/Plex Media Server/Drivers/imd-74-linux-x86_64/dri/iHD_drv_video.so'
d@nucsrv:/data/plex/Plex Media Server/Cache/va-dri-linux-x86_64$
The file simply does not exist for the i965 driver. Only the lib for the iHD driver does.
iHD vs i965
Not quite sure about the difference between these 2 Intels drivers but it got me thinkingā¦
d@nucsrv:/data/plex/Plex Media Server/Cache/va-dri-linux-x86_64$ sudo vainfo
Trying display: wayland
error: XDG_RUNTIME_DIR not set in the environment.
Trying display: x11
error: can't connect to X server!
Trying display: drm
libva info: VA-API version 1.18.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_18
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.18 (libva 2.18.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.1.6 ()
vainfo: Supported profile and entrypoints
VAProfileNone : VAEntrypointVideoProc
VAProfileNone : VAEntrypointStats
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Simple : VAEntrypointEncSlice
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointFEI
VAProfileH264Main : VAEntrypointEncSliceLP
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointFEI
VAProfileH264High : VAEntrypointEncSliceLP
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointEncPicture
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264ConstrainedBaseline: VAEntrypointFEI
VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
VAProfileVP8Version0_3 : VAEntrypointVLD
VAProfileVP8Version0_3 : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointFEI
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointEncSlice
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
d@nucsrv:/data/plex/Plex Media Server/Cache/va-dri-linux-x86_64$
My Intel NUC iGPU seems to use the iHD driver, not the i965.
Poking around
ā Real i965 lib
Found out that Intel did provided the file from its package, tried to symlink it where Plex was expecting to find it:
d@nucsrv:/data/plex/Plex Media Server/Cache/va-dri-linux-x86_64$ sudo ln -s /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so i965_drv_video.so
But it did not work. VAAPI successfully initialized but reported that no profile (decoding/encoding I assumed) was found and therefor a software fallback occured. I removed that symlink.
ā Real iHD lib
I tried to trick plex into using the real iHD lib from Intel but clearly lib versions/headers did not match and therefor did not work.
d@nucsrv:/data/plex/Plex Media Server/Cache/va-dri-linux-x86_64$ sudo ln -s /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so i965_drv_video.so
resulted in
Jun 03, 2023 21:49:25.103 [140169198832440] VERBOSE - [Req#e80/Transcode/rtolksxx1fh0i35oa0zdmj6e] [FFMPEG] - libva: Trying to open /data/plex/Plex Media Server/Cache/va-dri-linux-x86_64/i965_drv_video.so
Jun 03, 2023 21:49:25.105 [140169198832440] ERROR - [Req#e80/Transcode/rtolksxx1fh0i35oa0zdmj6e] [FFMPEG] - libva: dlopen of /data/plex/Plex Media Server/Cache/va-dri-linux-x86_64/i965_drv_video.so failed: Error relocating /usr/lib/x86_64-linux-gnu/libstdc++.so.6: __wmemmove_chk: symbol not found
ā Plex iHD lib
From the cache directory where plex was looking for the i965_drv_video.so there was a iHD_drv_video.so file pointing to /data/plex/Plex Media Server/Drivers/imd-74-linux-x86_64/dri/iHD_drv_video.so : this one, as bundled with plex, should align with plex transcoder binary⦠So I tried to trick Plex one last time:
d@nucsrv:/data/plex/Plex Media Server/Cache/va-dri-linux-x86_64$ sudo ln -s iHD_drv_video.so i965_drv_video.so
And it worked !
Jun 03, 2023 22:01:32.362 [139959308180280] DEBUG - [Req#6c3/Transcode] Codecs: testing hevc (decoder) with hwdevice vaapi
Jun 03, 2023 22:01:32.362 [139959308180280] VERBOSE - [Req#6c3/Transcode] [FFMPEG] - Rescanning for external libs: '/data/plex/Plex\ Media\ Server/Codecs/8217c1c-4565-linux-x86_64/'
Jun 03, 2023 22:01:32.363 [139959308180280] DEBUG - [Req#6c3/Transcode] Codecs: hardware transcoding: testing API vaapi
Jun 03, 2023 22:01:32.363 [139959308180280] VERBOSE - [Req#6c3/Transcode] [FFMPEG] - Trying to use DRM render node for device 0.
Jun 03, 2023 22:01:32.363 [139959308180280] VERBOSE - [Req#6c3/Transcode] [FFMPEG] - libva: VA-API version 1.18.0
Jun 03, 2023 22:01:32.363 [139959308180280] VERBOSE - [Req#6c3/Transcode] [FFMPEG] - libva: User requested driver 'i965'
Jun 03, 2023 22:01:32.363 [139959308180280] VERBOSE - [Req#6c3/Transcode] [FFMPEG] - libva: Trying to open /data/plex/Plex Media Server/Cache/va-dri-linux-x86_64/i965_drv_video.so
Jun 03, 2023 22:01:32.363 [139959308180280] VERBOSE - [Req#6c3/Transcode] [FFMPEG] - libva: Found init function __vaDriverInit_1_18
Jun 03, 2023 22:01:32.364 [139959308180280] VERBOSE - [Req#6c3/Transcode] [FFMPEG] - libva: va_openDriver() returns 0
Jun 03, 2023 22:01:32.364 [139959308180280] VERBOSE - [Req#6c3/Transcode] [FFMPEG] - Initialised VAAPI connection: version 1.18
Summary
Plex tries to load Plex Media Server/Cache/va-dri-linux-x86_64/i965_drv_video.so to enable vaapi but fails as the file does not exist. What is strange is the file Plex Media Server/Cache/va-dri-linux-x86_64/iHD_drv_video.so does exist and perfectly work with my NUC which seems to be logical as vainfo reports using iHD too and not i965.
The logs seem to indicate that the i965 is specifically set/called by plex (libva: User requested driver 'i965') which could be the issue here as plex currently runs on an iHD intel plateform (and provides/bundles its own iHD while not having its own i965 ĀÆ\(ć)/ĀÆ).
My workaround is simple: it feeds to plex the right file under the wrong name, wrong filename plex is actually trying to load:
$ cd <your_plex_base_path>/Plex Media Server/Cache/va-dri-linux-x86_64
$ sudo ln -s iHD_drv_video.so i965_drv_video.so
But I am pretty sure this should not be needed as Plex should try to load the correct file on its own and hece is a bug.
