Hardware Transcoding Issues

Server Version#: 1.19.3.2764
Player Version#: Multiple (Latest Web & iOS)

After getting things setup on FreeBSD, I’m now having trouble getting HW Transcoding to work.

I’ve followed all the steps in the post-install message and nuked the jail once. Before my problem was that /dev/drm wasn’t getting exposed, but after fixing that by loading the correct module (i915kms didn’t work, I had to use /boot/modules/i915kms.ko despite having a Haswell processor [i3 4330]), I’m now having the problem that the driver bundled with Plex isn’t running properly.

Here’s my vainfo output:

root@plex:~ # vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.7 (libva 2.7.1)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Desktop - 2.4.0
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      :	VAEntrypointVLD
      VAProfileH264MultiviewHigh      :	VAEntrypointEncSlice
      VAProfileH264StereoHigh         :	VAEntrypointVLD
      VAProfileH264StereoHigh         :	VAEntrypointEncSlice
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileJPEGBaseline           :	VAEntrypointVLD

And here’s the relevant log message when Plex is attempting to use the hardware transcoder, but FFMPEG is failing to load the driver:

May 22, 2020 23:02:31.110 [0x80c388f00] DEBUG - TPU: hardware transcoding: enabled, but no hardware decode accelerator found
May 22, 2020 23:02:31.110 [0x80c388f00] INFO - CodecManager: obtaining decoder 'aac'
...
May 22, 2020 23:04:18.774 [0x80acfde00] DEBUG - Codecs: testing h264_vaapi (encoder)
May 22, 2020 23:04:18.774 [0x80acfde00] DEBUG - Codecs: hardware transcoding: testing API vaapi
May 22, 2020 23:04:18.780 [0x80acfde00] ERROR - [FFMPEG] - libva: /usr/local/share/plexmediaserver-plexpass/lib/dri/iHD_drv_video.so init failed
May 22, 2020 23:04:18.780 [0x80acfde00] ERROR - [FFMPEG] - Failed to initialise VAAPI connection: 1 (operation failed).
May 22, 2020 23:04:18.781 [0x80acfde00] DEBUG - Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Input/output error
May 22, 2020 23:04:18.781 [0x80acfde00] DEBUG - Codecs: testing h264 (decoder) with hwdevice vaapi
May 22, 2020 23:04:18.785 [0x80acfde00] DEBUG - Codecs: hardware transcoding: testing API vaapi
May 22, 2020 23:04:18.785 [0x80acfde00] ERROR - [FFMPEG] - libva: /usr/local/share/plexmediaserver-plexpass/lib/dri/iHD_drv_video.so init failed
May 22, 2020 23:04:18.785 [0x80acfde00] ERROR - [FFMPEG] - Failed to initialise VAAPI connection: 1 (operation failed).
May 22, 2020 23:04:18.798 [0x80acfde00] DEBUG - Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Input/output error
May 22, 2020 23:04:18.798 [0x80acfde00] DEBUG - Scaled up video bitrate to 2619Kbps based on 1.500000x fudge factor.
May 22, 2020 23:04:18.798 [0x80acfde00] DEBUG - MDE: Selected protocol dash; container: mp4

Since I noticed vainfo used the i965 driver rather than the iHD driver, I tried to backup the plex bundled driver and copy the libva-intel-driver version into the relevant directory, but it couldn’t find the __vaDriverInit_1_0 function (I tried this before I nuked the jail, but I assume that the same result will occur)

The packages I’ve installed inside the jail are drm-fbsd12.0-kmod, libva-intel-driver and libva-utils.

The output of ls -l /dev/dri is:

root@plex:~ # ls -l /dev/dri
total 0
lrwxr-xr-x  1 root  wheel   8 May 22 22:51 card0 -> ../drm/0
lrwxr-xr-x  1 root  wheel  10 May 22 22:51 renderD128 -> ../drm/128

The output of uname -a is FreeBSD plex 12.1-RELEASE-p5 FreeBSD 12.1-RELEASE-p5 GENERIC amd64.

The plex user is added to the video group.

The devfs.rules looks ok since you see the devices in the jail.

Where did you add plex to the group? host or jail? It needs to be in the jail not host. Please uninstall vainfo or any other software related to that, you should only need plexmediaserver installed, you don’t even need drivers.

The error suggest plex couldn’t access the device, which most times is due to permissions.

You also need a recent drm-kmod on the host (you are loading boot/modules/i915kms.ko so I iamgine drm-fbsd12.0-kmod is installed (you might need to compile it on 12.1 btw as the pkg one is(or was built for 12.0)

If you loaded the module manually I suggest you add this to rc.conf kld_list="/boot/modules/i915kms.ko" and reboot.

A key factor in my experience is that that should be loaded at boot and the jail should have access at boot to, if you try to set this up on a running system it doesn’t always work (I’m not sure why but I sure had issues with this in the past).

Everything else is shipped with plex including the userland drivers:

ll /usr/local/share/plexmediaserver/lib/dri/
total 108033
-rw-r--r--  1 root  wheel    7926440 May 20 15:20 i965_drv_video.so
-rw-r--r--  1 root  wheel  188734992 May 20 15:20 iHD_drv_video.so

So as long as the kernel support is there, we shouldn’t need anything else.

Once you get that state clean and reboot let try again and if its failing please post new logs (full ZIP is preferred; feel free to DM)

Ah, compiling the kmod for 12.1 fixed it. Thanks for your help again!

Now the main problem I’m having is really bad artifacting when transcoding h264 1080p to h264 480p, even on the slowest h264 preset. It’s probably because I’m using a Haswell processor but I’ll do some more more fiddling around with settings unless there’s some magic bullet you can recommend :slight_smile:

Found the sorta-magic bullet; I disabled hardware encoding. The quality is much better now but the CPU usage is hovering at around 60%. Much better than before and probably the best I can get.

Yeah, that CPU does support HWT but its not very recent, Intel Quick Sync is much better on more recent CPU (and hence more recent Intel HD integrated graphics).

Check https://support.plex.tv/articles/115002178853-using-hardware-accelerated-streaming/ for more details.

  • The output quality of video may be lower, appearing slightly more blurry or blocky. This is especially true and more noticeable when streaming at resolutions below 720p or when using lower bit rate source material. (Hardware-accelerated video encoders are faster, but lower-quality than software encoders.)
  • Earlier generations of hardware typically have lower-quality output than newer generations. (For instance, output from a “Sandy Bridge” processor typically won’t look as good as from a “Kabylake” processor.)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.