Enable Hardware Decoding in Plex
#!/bin/bash
con="plex"
echo ""
echo "<font color='red'><b>Applying hardware decode patch...</b></font>"
echo "<hr>"
docker exec -i $con mv "/usr/lib/plexmediaserver/Plex Transcoder" "/usr/lib/plexmediaserver/Plex Transcoder2"
docker exec -i $con /bin/sh -c 'printf "#!/bin/sh\nexec /usr/lib/plexmediaserver/Plex\ Transcoder2 -hwaccel nvdec "\""\$@"\""" > "/usr/lib/plexmediaserver/Plex Transcoder";'
docker exec -i $con chmod +x "/usr/lib/plexmediaserver/Plex Transcoder"
docker exec -i $con chmod +x "/usr/lib/plexmediaserver/Plex Transcoder2"
docker restart $con
echo ""
echo "<font color='red'><b>Done!</b></font>"
Description: Translation of manual steps required to patch Plex docker to enable hardware decoding if you're running an Nvidia version of Unraid.
Quick Start: Set up and run as a script every time Plex updates. If your container is not called "plex", change the "con" variable (see notes)
Disclaimer: If it can be improved (or if it's dangerously wrong), please let me know.
Notes:
Should be run when Plex is installed/updated
From the command line, run "docker ps" to see what your plex container is called. Set that as the "con" variable in your script (mine is "plex")
This script is only required until Plex officially supports hardware decoding
It preforms the same as recommended in the NVidia plugin support thread here (where it was originally published), namely...
Renames the file "Plex Transcoder" to "Plex Transcoder2"
Creates a new "Plex Transcoder" file with the suggested contents
Changes permissions on both "Plex Transcoder" and "Plex Transcoder2" files (not sure it's required on Transcoder2 - seemed to work for me without)
Restarts the Plex container (not sure if required, but doing it anyhow)
Probably best nothing is playing whilst the script is run
You'll need to have Plex running for the script to work. Would require different code if stopped (would probably be safer to stop the container first, make the changes then start again, but here we are)
Run "nvidia-smi dmon -s u" from the terminal (not within Plex container) to check whether the decoding is working. Set a video to play in a transcoded state, and the 3rd and 4th columns from the end should be non-zero
This includes the "exec" addition to the Plex Transcoder file contents
Good luck!