[SOLVED] Plex doesnt do HW transcoding on Ubuntu 18.04 with i9-9900 (tone mapping related)

Got the solution.

So for anyone who attempts to get hw transcoding with tone mapping working on Ubuntu 18.04 with Intel CPUs from 9000 series and newer:

Install these:

Then build this library (you only need to go point 6 to point 8 since 18.04 has already a newer kernel):

Then you need to build and update the beignet drivers:

Go to a Directory where you want to build drivers like /home/%USERNAME%/Downloads

sudo apt -y install cmake pkg-config python ocl-icd-dev libegl1-mesa-dev ocl-icd-opencl-dev libdrm-dev libxfixes-dev libxext-dev llvm-7-dev clang-7 libclang-7-dev libtinfo-dev libedit-dev zlib1g-dev build-essential git clinfo

git clone --branch comet-lake https://github.com/rcombs/beignet.git

cd beignet

mkdir build

cd build

cmake -DLLVM_INSTALL_DIR=/usr/lib/llvm-7/bin ..

make -j8

sudo make install

sudo service plexmediaserver restart

Finally you can execute this command

sudo clinfo -l

It should show some output similar to this:

beignet-opencl-icd: no supported GPU found, this is probably the wrong opencl-icd package for this hardware
(If you have multiple ICDs installed and OpenCL works, you can ignore this message)
beignet-opencl-icd: no supported GPU found, this is probably the wrong opencl-icd package for this hardware
(If you have multiple ICDs installed and OpenCL works, you can ignore this message)
beignet-opencl-icd: no supported GPU found, this is probably the wrong opencl-icd package for this hardware
(If you have multiple ICDs installed and OpenCL works, you can ignore this message)
Platform #0: Intel(R) OpenCL HD Graphics
 `-- Device #0: Intel(R) UHD Graphics 630 [0x3e98]
Platform #1: Intel Gen OCL Driver
 `-- Device #0: Intel(R) UHD Graphics Coffee Lake Desktop GT2
Platform #2: Intel Gen OCL Driver

This is what you want to see:

Platform #0: Intel(R) OpenCL HD Graphics
 `-- Device #0: Intel(R) UHD Graphics 630 [0x3e98]
Platform #1: Intel Gen OCL Driver
 `-- Device #0: Intel(R) UHD Graphics Coffee Lake Desktop GT2
Platform #2: Intel Gen OCL Driver

Then HEVC HDR10 bit HW Transcoding with tone mapping should work.

CPU utilization with a H.265 65mbit 4k/HDR Video Stream is around 9% from plex with 6 threads for transcoding on a i9-9900k

2 Likes

I’m on 21.04 with a coffee lake 8100 and I’m having the same issue, except I can’t use the solution shown here. llvm-7 is not available and llvm-9 doesn’t seem to allow me to compile the updated beignet driver

Any suggestions?

@Brandito

If you’re using Ubuntu 21.04, you don’t compile your own.

Use it from the Ubuntu distro.

When you install Plex, the Debian package manager will install it for you if it sees it in the repository

Do I need to reinstall plex? It’s not currently able to hardware transcode HDR content on my 8100

Brandito.

Let’s check to see what’s installed and what exists?

dpkg -l | grep beignet
groups plex
ls -la /dev/dri | grep render

For some reason I didn’t get notified of your reply, but here is the output of those commands

plex@plex-ASM100:~$ dpkg -l | grep beignet
rc  beignet-opencl-icd:amd64                   1.3.2-8                                                              amd64        OpenCL library for Intel ix-3xxx/4xxx GPUs
plex@plex-ASM100:~$ groups plex
plex : plex adm cdrom sudo dip video plugdev render lpadmin lxd sambashare
plex@plex-ASM100:~$ ls -la /dev/dri | grep render

crw-rw----+  1 root render 226,   0 Jun 15 20:32 card0
crw-rw----+  1 root render 226, 128 Jun 15 20:32 renderD128
plex@plex-ASM100:~$ 

@Brandito

Thank you…

see that rc ??

it’s not completely installed.

Uninstall the package and manually install it on the comand line.
When that’s done, query again and you’ll see the correct ii on column 1.

Thanks, I was able to uninstall and reinstall beignet and now have the ii in column 1 but HDR content is still not using hardware to transcode, it actually doesn’t seem to want to transcode with software anymore either. I have rebooted too btw.

Is this likely because the 8100 PID isn’t included in the stock beignet driver? I’ve tried compiling an updated version with the PID but can’t seem to get that to work either

As always :wink:

Please do the following:

  1. Verify DEBUG logging enabled, VERBOSE logging disabled – Settings - Server - General - Show Advanced. (SAVE if you make changes)

  2. Start the playback attempt

  3. If it starts, play for 10 seconds.

  4. Stop

  5. Wait 20 seconds for logs to quiesce

  6. Settings - Server - Troubleshooting - Download Logs

  7. Attach the ZIP file it gives you.

Plex Media Server Logs_2021-06-17_20-32-03.zip (6.9 MB)
Here you go, hopefully this helps

You are getting HW transcoding.

Jun 17, 2021 19:51:27.593 [0x7ffb376d6b38] DEBUG - [Transcode/8b9c4d625263cdfa-com-plexapp-android] [FFMPEG] - Created surface 0.
Jun 17, 2021 19:51:27.593 [0x7ffb376d6b38] DEBUG - [Transcode/8b9c4d625263cdfa-com-plexapp-android] [FFMPEG] - Direct mapping possible.
Jun 17, 2021 19:51:27.593 [0x7ffb376d6b38] DEBUG - [Transcode/8b9c4d625263cdfa-com-plexapp-android] TPU: hardware transcoding: final decoder: vaapi, final encoder: vaapi
Jun 17, 2021 19:51:27.593 [0x7ffb376d6b38] DEBUG - [Transcode/8b9c4d625263cdfa-com-plexapp-android/JobRunner] Job running: FFMPEG_EXTERNAL_LIBS='/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Codecs/fa235d6-3858-linux-x86_64/' LIBVA_DRIVERS_PATH='/usr/lib/plexmediaserver/lib/dri' X_PLEX_TOKEN='xxxxxxxxxxxxxxxxxxxx' '/usr/lib/plexmediaserver/Plex Transcoder' '-codec:0' 'h264' '-hwaccel:0' 'vaapi' '-hwaccel_fallback_threshold:0' '10' '-hwaccel_output_format:0' 'vaapi' '-hwaccel_device:0' 'vaapi' '-codec:1' 'ac3' '-analyzeduration' '20000000' '-probesize' '20000000' '-i' '/nfs/plex/Movies/Transformers Age of Extinction (2014)/Transformers Age of Extinction (2014).mkv' '-analyzeduration' '20000000' '-probesize' '20000000' '-i' '/dev/shm/Transcode/Sessions/plex-transcode-8b9c4d625263cdfa-com-plexapp-android-0c06e9d1-b607-4395-8587-549f83c72b2b/temp-0.srt' '-filter_complex' '[0:0]hwupload[0];[0]scale_vaapi=w=720:h=300:format=nv12[1];[1]hwupload[2]' '-map' '[2]' '-metadata:s:0' 'language=eng' '-codec:0' 'h264_vaapi' '-b:0' '732k' '-maxrate:0' '976k' '-bufsize:0' '1952k' '-r:0' '23.975999999999999' '-force_key_frames:0' 'expr:gte(t,n_forced*8)' '-filter_complex' '[0:1] aresample=async=1:ocl='\''stereo'\'':rematrix_maxval=0.000000dB:osr=48000[3]' '-map' '[3]' '-metadata:s:1' 'language=eng' '-codec:1' 'libmp3lame' '-q:1' '4' '-map' '1:s:0' '-metadata:s:2' 'language=eng' '-codec:2' 'ass' '-map' '0:t?' '-codec:t' 'copy' '-segment_format' 'matroska' '-f' 'ssegment' '-individual_header_trailer' '0' '-flags' '+global_header' '-segment_format_options' 'output_ts_offset=10' '-segment_header_filename' 'header' '-segment_time' '8' '-segment_start_number' '0' '-segment_copyts' '1' '-segment_time_delta' '0.0625' '-segment_list' 'http://127.0.0.1:32400/video/:/transcode/session/8b9c4d625263cdfa-com-plexapp-android/0c06e9d1-b607-4395-8587-549f83c72b2b/manifest?X-Plex-Http-Pipeline=infinite' '-segment_list_type' 'csv' '-segment_list_size' '5' '-segment_list_separate_stream_times' '1' '-segment_list_unfinished' '1' '-max_delay' '5000000' '-avoid_negative_ts' 'disabled' '-map_metadata:g' '-1' '-map_metadata:c' '-1' '-map_chapters' '-1' 'media-%05d.ts' '-start_at_zero' '-copyts' '-vsync' 'cfr' '-init_hw_device' 'vaapi=vaapi:' '-filter_hw_device' 'vaapi' '-y' '-nostats' '-loglevel' 'quiet' '-loglevel_plex' 'error' '-progressurl' 'http://127.0.0.1:32400/video/:/transcode/session/8b9c4d625263cdfa-com-plexapp-android/0c06e9d1-b607-4395-8587-549f83c72b2b/progress'
Jun 17, 2021 19:51:27.593 [0x7ffb376d6b38] DEBUG - [Transcode/8b9c4d625263cdfa-com-plexapp-android/JobRunner] Jobs: Starting child process with pid 55056

Otherwise, I am seeing:

, 2021 20:31:59.371 [0x7ffb36c3db38] DEBUG - [Grabber/231b3658ae69ea27341e3708afac50774c64340a] HTTP/1.1 (0.0s) 200 response from GET http://192.168.1.160:80/lineup_status.json
Jun 17, 2021 20:31:59.479 [0x7ffb36f20b38] DEBUG - buildLiveM3U8: min 0 max 1977 ended 0
Jun 17, 2021 20:31:59.492 [0x7ffb365e4b38] DEBUG - Request: [127.0.0.1:43880 (Loopback)] GET /livetv/sessions/03906a78-d499-4a09-9f41-b40fb91e7970/5f3d0ca3-ee73-47b0-a581-cb043bb948f7/01977.ts (23 live) Signed-in
Jun 17, 2021 20:31:59.492 [0x7ffb365e4b38] DEBUG - Content-Length of /dev/shm/Transcode/Sessions/plex-transcode-03906a78-d499-4a09-9f41-b40fb91e7970/media-01977.ts is 1635036 (of total: 1635036).
Jun 17, 2021 20:31:59.495 [0x7ffb3a65eb38] DEBUG - Completed: [127.0.0.1:43880] 200 GET /livetv/sessions/03906a78-d499-4a09-9f41-b40fb91e7970/5f3d0ca3-ee73-47b0-a581-cb043bb948f7/01977.ts (23 live) 2ms 1635036 bytes (pipelined: 48)
Jun 17, 2021 20:31:59.495 [0x7ffb3a65eb38] DEBUG - Removed transcode data consumer, active count 1 => 0
Jun 17, 2021 20:31:59.568 [0x7ffb369d3b38] DEBUG - [Transcode] Transcoder segment range: 0 - 1978 (1978)
Jun 17, 2021 20:31:59.569 [0x7ffb3589ab38] DEBUG - [Transcode] Transcoder segment range: 0 - 1979 (1978)
Jun 17, 2021 20:31:59.708 [0x7ffb3a681b38] DEBUG - Completed: [192.168.1.244:55451] 200 GET /player/proxy/poll?deviceClass=pc&protocolVersion=3&protocolCapabilities=timeline%2Cplayback%2Cnavigation%2Cmirror%2Cplayqueues&timeout=1 (23 live) TLS GZIP 20000ms 5 bytes (pipelined: 828)
Jun 17, 2021 20:31:59.715 [0x7ffb3a65eb38] DEBUG - Auth: authenticated user 1 as Brandito
Jun 17, 2021 20:31:59.716 [0x7ffb376d6b38] DEBUG - Request: [192.168.1.244:55451 (Subnet)] GET /player/proxy/poll?deviceClass=pc&protocolVersion=3&protocolCapabilities=timeline%2Cplayback%2Cnavigation%2Cmirror%2Cplayqueues&timeout=1 (23 live) TLS GZIP Signed-in Token (Brandito)
Jun 17, 2021 20:31:59.716 [0x7ffb376d6b38] DEBUG - Content-Length is -1 (of total: -1).
Jun 17, 2021 20:32:00.414 [0x7ffb3582fb38] DEBUG - buildLiveM3U8: min 0 max 1978 ended 0
Jun 17, 2021 20:32:00.418 [0x7ffb3582fb38] DEBUG - buildLiveM3U8: ended due to segment 1978.651767 past end time 2021-06-18 01:32:00.000000000 +0000
Jun 17, 2021 20:32:00.426 [0x7ffb357b4b38] DEBUG - Request: [127.0.0.1:43880 (Loopback)] GET /livetv/sessions/03906a78-d499-4a09-9f41-b40fb91e7970/5f3d0ca3-ee73-47b0-a581-cb043bb948f7/01978.ts (23 live) Signed-in
Jun 17, 2021 20:32:00.427 [0x7ffb357b4b38] DEBUG - Content-Length of /dev/shm/Transcode/Sessions/plex-transcode-03906a78-d499-4a09-9f41-b40fb91e7970/media-01978.ts is 1671132 (of total: 1671132).
Jun 17, 2021 20:32:00.429 [0x7ffb3a65eb38] DEBUG - Completed: [127.0.0.1:43880] 200 GET /livetv/sessions/03906a78-d499-4a09-9f41-b40fb91e7970/5f3d0ca3-ee73-47b0-a581-cb043bb948f7/01978.ts (23 live) 3ms 1671132 bytes (pipelined: 49)

This looks like it missed Analyzing the media. (you can correct by hitting “Analyze”)

I do get HW transcoding for everything BUT HDR content when tone mapping is enabled.

Someone else happened to play transformers while I was testing with the movie Army of the Dead so I’ll rerun the steps you gave me to give you a new set of logs. Transformers was not a file that would cause an issue.

Plex Media Server Logs_2021-06-18_05-36-57.zip (6.9 MB)

Here is an updated set of logs testing with the movie Army of the Dead

@Brandito

I see Army of the Dead playing.

Jun 18, 2021 05:35:25.110 [0x7ffb351c3b38] DEBUG - [Transcode] [FFMPEG] - Format 0x30313050 -> p010le.
Jun 18, 2021 05:35:25.110 [0x7ffb351c3b38] DEBUG - [Transcode] [FFMPEG] - Created surface 0.
Jun 18, 2021 05:35:25.110 [0x7ffb351c3b38] DEBUG - [Transcode] [FFMPEG] - Direct mapping possible.
Jun 18, 2021 05:35:25.111 [0x7ffb351c3b38] DEBUG - [Transcode] TPU: hardware transcoding: final decoder: vaapi, final encoder: vaapi
Jun 18, 2021 05:35:25.111 [0x7ffb351c3b38] DEBUG - [Transcode/JobRunner] Job running: EAE_ROOT='/tmp/pms-8e18adca-fc99-45a7-9cf3-5e37aca0b902/EasyAudioEncoder' EnableExtendedVaFormats='1' FFMPEG_EXTERNAL_LIBS='/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Codecs/fa235d6-3858-linux-x86_64/' LIBVA_DRIVERS_PATH='/usr/lib/plexmediaserver/lib/dri' NEOReadDebugKeys='1' X_PLEX_TOKEN='xxxxxxxxxxxxxxxxxxxx' '/usr/lib/plexmediaserver/Plex Transcoder' '-codec:0' 'hevc' '-hwaccel:0' 'vaapi' '-hwaccel_fallback_threshold:0' '10' '-hwaccel_output_format:0' 'vaapi' '-hwaccel_device:0' 'vaapi' '-codec:1' 'eac3_eae' '-eae_prefix:1' 'bc5maji0iqlqsr7vhh1l7b14_' '-analyzeduration' '20000000' '-probesize' '20000000' '-i' '/nfs/plex/Movies/Army of the Dead (2021)/Army of the Dead (2021).mkv' '-filter_complex' '[0:0]hwupload[0];[0]scale_vaapi=w=2276:h=1280:format=p010[1];[1]hwmap=derive_device=opencl[2];[2]tonemap_opencl=tonemap=mobius:format=nv12:m=bt709:p=bt709:r=tv[3];[3]hwmap=derive_device=vaapi:reverse=1[4];[4]hwupload[5]' '-map' '[5]' '-codec:0' 'h264_vaapi' '-b:0' '20088k' '-maxrate:0' '26784k' '-bufsize:0' '53568k' '-r:0' '24' '-force_key_frames:0' 'expr:gte(t,n_forced*1)' '-filter_complex' '[0:1] aresample=async=1:ocl='\''stereo'\'':rematrix_maxval=0.000000dB:osr=48000[6]' '-map' '[6]' '-metadata:s:1' 'language=eng' '-codec:1' 'aac' '-b:1' '256k' '-f' 'dash' '-seg_duration' '1' '-init_seg_name' 'init-stream$RepresentationID$.m4s' '-media_seg_name' 'chunk-stream$RepresentationID$-$Number%05d$.m4s' '-window_size' '5' '-delete_removed' 'false' '-skip_to_segment' '1' '-time_delta' '0.0625' '-manifest_name' 'http://127.0.0.1:32400/video/:/transcode/session/bc5maji0iqlqsr7vhh1l7b14/b561076f-7c40-4ea0-af99-bfe493250fe5/manifest?X-Plex-Http-Pipeline=infinite' '-avoid_negative_ts' 'disabled' '-map_metadata' '-1' '-map_chapters' '-1' 'dash' '-map' '0:23' '-metadata:s:0' 'language=eng' '-codec:0' 'ass' '-f' 'segment' '-segment_format' 'ass' '-segment_time' '1' '-segment_header_filename' 'sub-header' '-segment_start_number' '0' '-segment_list' 'http://127.0.0.1:32400/video/:/transcode/session/bc5maji0iqlqsr7vhh1l7b14/b561076f-7c40-4ea0-af99-bfe493250fe5/manifest?stream=subtitles&X-Plex-Http-Pipeline=infinite' '-segment_list_type' 'csv' '-segment_list_size' '5' '-segment_list_separate_stream_times' '1' '-segment_format_options' 'ignore_readorder=1' '-segment_list_unfinished' '1' '-fflags' '+flush_packets' 'sub-chunk-%05d' '-start_at_zero' '-copyts' '-vsync' 'cfr' '-init_hw_device' 'vaapi=vaapi:' '-filter_hw_device' 'vaapi' '-y' '-nostats' '-loglevel' 'quiet' '-loglevel_plex' 'error' '-progressurl' 'http://127.0.0.1:32400/video/:/transcode/session/bc5maji0iqlqsr7vhh1l7b14/b561076f-7c40-4ea0-af99-bfe493250fe5/progress'

I see it enabling HW tone mapping chain.

[1]hwmap=derive_device=opencl[2];[2]tonemap_opencl=tonemap=mobius:format=nv12:m=bt709:p=bt709:r=tv[3];[3]hwmap=derive_device=vaapi:reverse=1[4]

Using Subtitles ? It looks like they are:

'language=eng' '-codec:0' 'ass' '-f' 'segment' '-segment_format' 'ass' 

Is the player set to “Always Burn” ?

I am asking because hardware cannot burn subtitles. It will do everything else but subtitle burning must be done by the CPU (there is no API for HW)

Try turning off subtitles and see if the behavior changes – It should.

No subtitles, happens with any 4k movie that is HDR, if it’s not HDR it uses hardware.

I do notice intel_gpu_top shows it starts up video encoding for like a second when first starting the movie then the cpu takes over.

My understanding is my cpu, an i3 8100, is not supported by the 2 year old beignet driver and that’s why I was trying to compile a more up to date driver. I also read plex is switching to using a better supported driver as well?

Or do you think my issue is still something else entirely?

Edit: sorry I lied, that movie did have forced subtitles enabled. Disabling them doesn’t help though, and all other 4k HDR movies with subtitles off also switch to software transcoding.

Do you have ANY files without subtitles ?

If forced subtitles are in the file, PMS will disable part of the hardware (because they are forced).

Not to challenge you but are you certain it’s performing SW tonemapping versus SW subtitle burning? I ask only because either task is a lot for an i3 CPU

The logs aren’t showing errors while showing me that the hardware is enagaged.

May I see the XML of one of the movies you’re testing with? (the <media> ... </media> part only.

I’ll check when I get home, but I only have the issue if the 4k movie is HDR, I have a couple that are not HDR and they hw transcode no problem.

And you’re right, when they software transcode they do not play well at all.

Here is another set of logs for Monster Hunter which is 4k HDR and doesn’t hardware transcode and the associated XML data you asked for. Subtitles were turned off
Plex Media Server Logs_2021-06-18_20-52-13.zip (6.0 MB)

<Media id="33950" duration="6186944" bitrate="15263" width="3840" height="1600" aspectRatio="2.35" audioChannels="6" audioCodec="eac3" videoCodec="hevc" videoResolution="4k" container="mkv" videoFrameRate="24p" videoProfile="main 10">
<Part accessible="1" exists="1" id="35204" key="/library/parts/35204/1613483207/file.mkv" duration="6186944" file="/nfs/plex/Movies/Monster Hunter (2020)/Monster Hunter (2020).mkv" size="11805392632" container="mkv" deepAnalysisVersion="4" indexes="sd" requiredBandwidths="15647,15635,15600,15543,15503,15480,15480,15480" videoProfile="main 10">
<Stream id="114157" streamType="1" default="1" codec="hevc" index="0" bitrate="14623" bitDepth="10" chromaSubsampling="4:2:0" codedHeight="1600" codedWidth="3840" colorPrimaries="bt2020" colorRange="tv" colorSpace="bt2020nc" colorTrc="smpte2084" frameRate="23.976" height="1600" level="150" profile="main 10" refFrames="1" requiredBandwidths="15007,14995,14960,14903,14863,14841,14841,14841" width="3840" displayTitle="4K (HEVC Main 10 HDR)" extendedDisplayTitle="4K (HEVC Main 10 HDR)"> </Stream>
<Stream id="114158" streamType="2" selected="1" default="1" codec="eac3" index="1" channels="6" bitrate="640" language="English" languageCode="eng" audioChannelLayout="5.1(side)" requiredBandwidths="640,640,640,640,640,640,640,640" samplingRate="48000" displayTitle="English (EAC3 5.1)" extendedDisplayTitle="English (EAC3 5.1)"> </Stream>
<Stream id="114159" streamType="3" default="1" forced="1" codec="srt" index="2" language="English" languageCode="eng" requiredBandwidths="1,1,1,1,1,1,1,1" title="Forced" displayTitle="English Forced (SRT)" extendedDisplayTitle="Forced (English SRT)"> </Stream>
<Stream id="114160" streamType="3" codec="srt" index="3" bitrate="0" language="English" languageCode="eng" requiredBandwidths="1,1,1,1,1,1,1,1" displayTitle="English (SRT)" extendedDisplayTitle="English (SRT)"> </Stream>
<Stream id="139951" streamType="3" codec="srt" index="4" bitrate="0" language="English" languageCode="eng" requiredBandwidths="1,1,1,1,1,1,1,1" title="SDH" displayTitle="English (SRT)" extendedDisplayTitle="SDH (English SRT)"> </Stream>
</Part>
</Media>```

@Brandito

  1. It has forced subtitles
<Stream id="114159" streamType="3" default="1" forced="1" codec="srt" index="2" language="English" languageCode="eng" requiredBandwidths="1,1,1,1,1,1,1,1" title="Forced" displayTitle="English Forced (SRT)" extendedDisplayTitle="Forced (English SRT)"> </Stream>
  1. On the player, In its Settings, Is it set to “Always Burn” subtitles ?

It’s set to automatic for the web player which I used to generate the log

Edit: tried it on one of my 1080p tvs where burn subtitles is also set to auto and same issue with subs turned off. I’m seriously only getting this issue with HDR content. I have a few 4k movies that are not HDR that transcode in hardware every time and they all have subs, some forced.

Transcoding 1080p content and lower has never been an issue

Any other suggestions?