Hardware Accelerated Decode (Nvidia) for Linux

Thanks for sharing your process!

I couldn’t get scaling working correctly, when using the configure params from the original Plex Transcoder, so I just used as little as possible. Worked fine for me. I am currently working on getting hdr tonemapping working with opencl, so that it is actually possible when doing live transcodes (not sure if that’s really possible yet, but got 13fps on the cpu alone, so I am confident that I can get more than that using opencl).

When I have finished finding parameters that actually work, I plan on getting a working build script (there already is one in the branch, but the params are off) as well as a replacement for the transcoder that is customizable (i.e. enable disable replacement, only replace transcoding sessions, enable / disable hdr tonemapping, etc.)

What you may also notice, is that the current build script first downloads some codecs from the plex servers. The transcoder is built in a way, that uses as little codecs built into ffmpeg as possible, however, I gave up on that since it’s just to much work.

I recommend trying to build the fork in a “normal” way, i.e. like you would do normally for ffmpeg on your system. I am testing this on ubuntu.

Also, for hdr tonemapping, I have a seperate branch now, plex-changes-4.0.2. (actually the current one is probably broken, since I merged ffmpeg master in :neutral_face: Commit b17dc695c904dbc9250aec345d7dc29249ed70c5 should still be fine.)

4 Likes

+1 For decoding on Nvidia in Linux (I have a p2000). I’m in a position now where I either have to switch to Windows, or upgrade my mb/cpu/ram to handle all the decoding my CPU (i7-3770) is doing for 4k. Id rather not throw hardware at a software limitation.

1 Like

Any way I can use all 5 of my votes on this feature? :wink: Really surprised this hasn’t received more attention.

1 Like

I vote DJ and Geraden should apply for jobs at plex.

We need to have this. Emby can do it. I test earlier with my rig, Emby, using a P2000. I had 4 x H265 4K Movies with True-HD and DTS-HD Audio tracks playing, being transcoded to H264 1080P 15Mbps, and my CPU load was 3.

It’s insane what these cards can do!

1 Like

I’ve already starred and watched the git repo. Sadly I cannot provide any significant assistance on it but watching it like a hawk. If you guys manage to fully get Nvidia encode and decode with a bonus of tonemapping support, that’d be the holy grail IMHO and I’d gladly toss some funds your way.

2 Likes

+1 for GPU transcoding.
I just pulled the trigger on a p2000 and i7 8700. So hopefully not too far away!

2 Likes

Already starting to see people in the Reddit Homelab forums discussing leaving plex for Emby because of this. Emby already has this functioning.

2 Likes

I honestly don’t know why this is still an issue. They could have added this well over a year ago. All they had to do was add “–enable-decoder=cuvid” into the ffmpeg build parameters and it would hw decode on nvidia.

7 Likes

Hi, i am a AMD rzyen 2400G user , not commercial, i think no one will take me as a non-domestic user
even using AMD 580 、570 which is cheaper than others at same level performance

Thanks for the recommendation, I am going to try it

I’m using hardware transcoding on a Nvidia GT650M in linux just fine.
All I pretty much had to do was install the CUDA drivers and a small boot kernel config tweak and it worked straight away.

Check your “decode”. I doubt it’s hw

1 Like

Nope, it’s definitely hw.

Since hw decoding isn’t working with nvdec yet, is it possible to have the Intel QSV do hw decode while the Nvidia nvenc does hw encode? I have an Nvidia P2000 and new Intel i5-9600k which should be a powerful combination. I’m only able to get hardware encoding though. The decode is being done by software. I’d love to get them both active at the same time since we don’t know when Plex will add support for full hw with Nvidia only.

Why not just use the Intel igpu for both?

On linux?

Can you provide some more info other than saying it works? The last time I checked, plex’s transcoder (ffmpeg) simply does not support hw decode with nvidia on linux because it wasn’t built to support it

I’m a bit too busy, but if I recall correctly, the youtuber Byte My Bits did pretty much the same thing I did and got it working too.

I want to try it both ways and test it out (Nvidia only, Intel only, and combination of both). However, I can’t get the Intel hw transcoding to work at all right now. I tried a bunch of things yesterday but it would cause Plex to crash every time it started to transcode anything. I suspect it is the same issue as reported over here with the new i5-9600k:
https://forums.plex.tv/t/hw-trancoding-not-work-on-i5-9600k/331081

As far as I can tell, the Intel side should “just work” with Ubuntu 18.04 since the drivers are built into the kernel. However, that might not be the case with the newest Intel cpus.

That video shows hardware encoding, not hw decode.

If you look at the text in the windows at 10:08 https://youtu.be/bQLgbc9NFdU?t=608 you’ll see that it says Transcoding H264 to H264 (hw) Notice how the first H264 does not have a (hw) next to it. That means decode is software.

Full hw transcode would say Transcoding H264 (hw) to H264 (hw)

Anyway, here’s the build configuration of Plex’s ffmpeg for all interested:

root@Tower2:/usr/lib/plexmediaserver# LD_LIBRARY_PATH=/usr/lib/plexmediaserver /usr/lib/plexmediaserver/Plex\ Transcoder
ffmpeg version git-2018-09-24-531e313 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.8.2 (GCC)
  configuration: --libdir=/data/jenkins/pms-deps-universal-v2/BUILD_TAG/linux-ubuntu-x86_64/output/pms-depends-linux-ubuntu-x86_64-release-79dcc0f/lib --prefix=/data/jenkins/pms-deps-universal-v2/BUILD_TAG/linux-ubuntu-x86_64/output/pms-depends-linux-ubuntu-x86_64-release-79dcc0f --disable-bzlib --disable-ffplay --disable-ffprobe --disable-avdevice --disable-schannel --disable-linux-perf --disable-mediacodec --disable-debug --disable-doc --disable-shared --pkg-config-flags=--static --enable-muxers --enable-gpl --enable-version3 --enable-gnutls --enable-eae --disable-encoders --disable-decoders --disable-hwaccels --enable-libass --enable-librtmp --disable-devices --disable-lzma --disable-iconv --disable-protocol=concat --enable-libvorbis --enable-libopus --external-decoder=h264 --disable-bsfs --enable-bsf='aac_adtstoasc,extract_extradata,dca_core,h264_mp4toannexb,hevc_mp4toannexb,vp9_superframe,vp9_superframe_split,framedrop' --enable-decoder=png --enable-decoder=apng --enable-decoder=bmp --enable-decoder=mjpeg --enable-decoder=thp --enable-decoder=gif --enable-decoder=dirac --enable-decoder=ffv1 --enable-decoder=ffvhuff --enable-decoder=huffyuv --enable-decoder=rawvideo --enable-decoder=zero12v --enable-decoder=ayuv --enable-decoder=r210 --enable-decoder=v210 --enable-decoder=v210x --enable-decoder=v308 --enable-decoder=v408 --enable-decoder=v410 --enable-decoder=y41p --enable-decoder=yuv4 --enable-decoder=ansi --enable-decoder=alac --enable-decoder=flac --enable-decoder=vorbis --enable-decoder=opus --enable-decoder=pcm_f32be --enable-decoder=pcm_f32le --enable-decoder=pcm_f64be --enable-decoder=pcm_f64le --enable-decoder=pcm_lxf --enable-decoder=pcm_s16be --enable-decoder=pcm_s16be_planar --enable-decoder=pcm_s16le --enable-decoder=pcm_s16le_planar --enable-decoder=pcm_s24be --enable-decoder=pcm_s24le --enable-decoder=pcm_s24le_planar --enable-decoder=pcm_s32be --enable-decoder=pcm_s32le --enable-decoder=pcm_s32le_planar --enable-decoder=pcm_s8 --enable-decoder=pcm_s8_planar --enable-decoder=pcm_u16be --enable-decoder=pcm_u16le --enable-decoder=pcm_u24be --enable-decoder=pcm_u24le --enable-decoder=pcm_u32be --enable-decoder=pcm_u32le --enable-decoder=pcm_u8 --enable-decoder=pcm_alaw --enable-decoder=pcm_mulaw --enable-decoder=ass --enable-decoder=dvbsub --enable-decoder=dvdsub --enable-decoder=ccaption --enable-decoder=pgssub --enable-decoder=jacosub --enable-decoder=microdvd --enable-decoder=movtext --enable-decoder=mpl2 --enable-decoder=pjs --enable-decoder=realtext --enable-decoder=sami --enable-decoder=ssa --enable-decoder=stl --enable-decoder=subrip --enable-decoder=subviewer --enable-decoder=text --enable-decoder=vplayer --enable-decoder=webvtt --enable-decoder=xsub --enable-decoder=libzvbi_teletext --enable-decoder=eac3_eae --enable-decoder=truehd_eae --enable-decoder=mlp_eae --enable-encoder=flac --enable-encoder=alac --enable-encoder=libvorbis --enable-encoder=libopus --enable-encoder=mjpeg --enable-encoder=wrapped_avframe --enable-encoder=ass --enable-encoder=dvbsub --enable-encoder=dvdsub --enable-encoder=movtext --enable-encoder=ssa --enable-encoder=subrip --enable-encoder=text --enable-encoder=webvtt --enable-encoder=xsub --enable-encoder=pcm_f32be --enable-encoder=pcm_f32le --enable-encoder=pcm_f64be --enable-encoder=pcm_f64le --enable-encoder=pcm_s8 --enable-encoder=pcm_s8_planar --enable-encoder=pcm_s16be --enable-encoder=pcm_s16be_planar --enable-encoder=pcm_s16le --enable-encoder=pcm_s16le_planar --enable-encoder=pcm_s24be --enable-encoder=pcm_s24le --enable-encoder=pcm_s24le_planar --enable-encoder=pcm_s32be --enable-encoder=pcm_s32le --enable-encoder=pcm_s32le_planar --enable-encoder=pcm_u8 --enable-encoder=pcm_u16be --enable-encoder=pcm_u16le --enable-encoder=pcm_u24be --enable-encoder=pcm_u24le --enable-encoder=pcm_u32be --enable-encoder=pcm_u32le --enable-encoder=h264_vaapi --enable-encoder=hevc_vaapi --enable-encoder=h264_nvenc --enable-encoder=eac3_eae --arch=x86_64 --enable-libzvbi --cc='ccache gcc' --extra-ldflags=-L/data/jenkins/pms-deps-universal-v2/BUILD_TAG/linux-ubuntu-x86_64/output/pms-depends-linux-ubuntu-x86_64-release-79dcc0f/lib --extra-libs='-lgcrypt -lgpg-error -ldl'
  libavutil      56.  7.101 / 56.  7.101
  libavcodec     58. 12.102 / 58. 12.102
  libavformat    58.  9.100 / 58.  9.100
  libavfilter     7. 12.100 /  7. 12.100
  libswscale      5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
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'

Notice how there is --enable-encoder=h264_nvenc but no --enable-decoder=h264_cuvid or --enable-decoder=h264_nvdec

3 Likes