Hardware Accelerated Decode (Nvidia) for Linux

59 days since the last Server Update, unless I’m missing a post somewhere. So almost 2 months, no updates in this thread. The only thing holding me back from going back to Emby is the lack of a Tautulli like app/reporting for Emby.

Come on Plex Devs, at least just tell us if it’s coming soon or not. And if not I can just be on my merry way,

2 Likes

*39 days. Which is still quite a bit of time considering they push updates nearly twice a month. Crossing my fingers that the next update is a big one that addresses this feature :crossed_fingers:

3 Likes

I use the machine that my Plex Media Server runs on for multiple different house hold uses. I found it appalling that PMS can’t do hardware accelerated decoding and instead (on my Xeon with no iGPU) it proceeds to eat up all 4 cores transcoding 4k media, where as the security camera software I have running on there (Shinobi), which is made by ONE GUY has no problem giving me the option to configure how it uses ffmpeg. Now I understand transcoding media is more complicated than simply passing a camera stream to ffmpeg with the right parameters but emotionally it feels like a feature that plex really should have always had and really I feel like I could fix this myself very quickly if Plex was open-source. Not to mention the power required to run 4 cores at max speed vs running specialised hardware to do decoding really gets on my nerves, it feels like such a waste of both power and heat output. And just forget it if someone else also wants to stream 4k.

2 Likes

I’ll be checking this thread often now that I’ve found it.

I truly hope that the devs will create support for decoding on Linux. Linux is a mature OS which many paying power users use with Plex to provide media streaming to their family and friends. The rise of 4K media availability has made many existing platforms obsolete unless you add a Quadro or Nvidia 10xx card. This too for my virtualized environment on which I have both professional and private VM’s (HP DL 380 G6 with dual xeon X5670), it slows to a crawl doing one 2160p h.265 10bit mediafile (two is unthinkable, even with 24 threads).

I would very much like to keep using Plex ánd start streaming 4K, in the not so far future this will only be possible with a Quadro card unless I swap my server. Heck, if you would start shipping P2000’s with a Plex logo on top and a bit of markup to subsidize the extra code changes it would probably sell @ChuckPA. :wink:

2 Likes

Bump! It would be nice with some kind of response from a dev…

They don’t care what customers want, they just want to add features that no one needs.

If it’s to any help to Plex developers or anyone I have ffmpeg 4.1 installed on my linux Plex server and this is the simplest command that works great on my machine to enable both NVDEC and NVENC that I need Plex to run when transcoding:
ffmpeg -hwaccel nvdec -i input.mkv -c:v h264_nvenc output.mkv

Support for decoding through NVDEC was appearantly added to ffmpeg version 4.0 released 9 months ago. Without “-hwaccel nvdec” to enable hw-accellerated decoding the CPU on this server is unfortunately not powerful enough to do transcoding.

Hardware accelerated decoding has been working for far longer than 9 months using VA-API backends. I have previously had Kodi on this machine and have had HW accelerated decoding working there way back when it was still called XBMC both with an integrated radeon card and nvidia cards with both the opensource nouveau driver and the offical nvidia driver. Sadly none of that works for Plex. But I would be happy if Plex at least gains support for NVDEC in Linux.

Here is the output when I run ffmpeg with no arguments (configuration flags): https://pastebin.com/7Lq8Rza8

5 Likes

Thank you for posting such a constructive reply in this thread!

Apparently, more is needed than just an ffmpeg upgrade. The way that Plex passes arguments on to ffmpeg is dependent on various parameters and the Plex codebase needs changing as well it seems.

I know. The Plex Transcoder binary is a fork of ffmpeg “git-2018-09-24-531e313”. I’m not sure what version it’s based on but ffmpeg 4.0.1 (with NVDEC capabilites) was released 2018-06-16: https://ffmpeg.org/releases/

The Plex Transcoder ffmpeg fork actually reports that it supports cuda, vaapi and cuvid on my system:
htpc ~ # LD_LIBRARY_PATH=/usr/lib/plexmediaserver /usr/lib/plexmediaserver/Plex\ Transcoder -hwaccels
ffmpeg version git-2018-09-24-531e313 Copyright © 2000-2018 the FFmpeg developers
built with gcc 4.8.2 (GCC)

Hardware acceleration methods:
cuda
vaapi
cuvid

My ffmpeg 4.1 binary is very similar except it also supports vdpau:
Hardware acceleration methods:
vdpau
cuda
vaapi
cuvid

What I’m asking is that the closed source Plex codebase is changed so that it will use the “-hwaccel nvdec” option if it finds the “cuda” string when it queries ffmpeg with “ffmpeg -hwaccels”.

4 Likes

Emby 4.0 looks very shiny right now …

can confirm emby’s shininess
:star_struck::star_struck::heart_eyes::heart_eyes::eggplant::sweat_drops:
I LOVE HOW IT SHOWS ME MY OPTIONS BEFORE I EVEN SUBSCRIBE COUGH WINK HINT ETC

goodbye mustard yellow tyranny!!

PS im realizing some of you picked the “lifetime” subscription. good luck plexers!

4 Likes

I’m about to do the same, I already bought Emby and man is awesome! Plex needs to get there sh#* together!!

2 Likes

I installed the Plex alpha version 1.15.0.573 today and I have been experimenting much more with the Plex Transcoder binary. This version of the Plex Media Server ships with a newer version of FFMpeg compiled with Clang instead of GCC:
ffmpeg version 1.4-a15abb0-22 Copyright © 2000-2018 the FFmpeg developers
built with clang version 5.0.1 (tags/RELEASE_501/final)

Most interstingly:
This version actually supports the “-hwaccel nvdec” option!

I have been able to successfully launch and transcode on my own with the “Plex Transcoder” binary by setting these environment variables:
FFMPEG_EXTERNAL_LIBS=’/config/Library/Application\ Support/Plex\ Media\ Server/Codecs/a15abb0-2009-linux-x86_64/’ LD_LIBRARY_PATH=/usr/lib/plexmediaserver/ /usr/lib/plexmediaserver/Plex\ Transcoder

I have been trying to replicate all the arguments that Plex Media server sends to this binary and I’ve been running it outside of Plex. Unfortunately Plex Media Server still doesn’t send the “-hwaccel nvdec” option to it so the decode still isn’t accellerated within Plex. But while the “Plex Transcoder” binary that shipped with Plex 1.14 just seemed to ignore the “-hwaccel nvdec” argument this one shipped with Plex 1.15 doesn’t!

When I added the “-hwaccel nvdec” option to this new binary I achieved a speed of ~x6 with -hwaccel nvdec without pegging my CPU at 100% when trying it on a video from my Plex library.
Without it the speed was only ~x2 with both my poor CPU cores pegged at 100%.

So while there hasn’t been much word from the devs about this maybe supporting it is not that far off? All that’s required now is that Plex Media Server sends the argument “-hwaccel nvdec” to the Plex Transcoder binary included in Plex 1.15. Can we please have that in the final release?

I will gladly beta-test further alpha releases if they start enabling nvdec which is now fully possible with the newest transcoder binary (Plex ffmpeg fork).

4 Likes

How are you accessing alpha releases?

It’s from a thread on these forums: Much faster (hopefully), smaller (mostly) and better PMS builds preview (1.15.0.573-123756e9a)

Personally though I installed it through the fkmclane layman overlay on Gentoo.

I just wrote a bash script that forces NVDEC on my Plex. What you need to do is to run the latest Plex 1.15 alpha from the thread I posted above and then rename the “Plex Transcoder” binary to “Plex Transcoder2”. After that create this file in it’s place called “Plex Transcoder” with these contents:

#!/bin/sh
/usr/lib/plexmediaserver/Plex\ Transcoder2 -hwaccel nvdec "$@"

Of course the path “/usr/lib/plexmediaserver/” will have to be modified to wherever Plex is installed.
After that chmod +x this file. Now transcoding is fully HW accellerated from your server (provided it has a supported Nvidia card installed with the offical drivers)! That’s how easy it is to enable at this point. Can we please have it officially soon?

Of course the brute force way I have done here does not report correctly on the Plex dashboard but clearly my CPUs don’t get pegged and the GPU usage reported by “nvidia-smi” now increases more than before.

6 Likes

well it cant report if plex wasnt doing it intentionally. When you run nvidia-smi dmon -s u do you see the dec% section go above 0 ?

1 Like

Yes sir:

htpc ~ # nvidia-smi dmon -s u
# gpu    sm   mem   enc   dec
# Idx     %     %     %     %
    0     9     1     3     7
    0     8     1     2     6
    0     9     1     3     6
    0    10     1     3     7
    0     9     1     3     7
    0     8     1     3     5
1 Like

sexy. Although not safe for general consumption, this does shed some positive light for the men and women at plex showing (subtly) that changes are happening. You did not have to (re)compile ffmpeg, and the option is already allowed. All that needs to happen is for them to “Flip the switch” allowing that arg to be {pre/ap}pended to their transcoder args when they are ready. Everyone relax. Progress is being made and we are just not privvy to it as it is not open source. :slight_smile:

1 Like

Very interesting.

Does anyone have a docker image for the latest beta found here: https://artifacts.plex.tv/plex-media-server-alpha/1.15.0.573-123756e9a/debian/plexmediaserver_1.15.0.573-123756e9a_amd64.deb