├── Plex_nvdec_enable.sh
└── README.md
/Plex_nvdec_enable.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ############################### DISCLAIMER ################################
4 | # This script now uses someone elses work! #
5 | # Please visit https://github.com/revr3nd/plex-nvdec/ #
6 | # for the author of the new transcode wrapper, and show them your support!#
7 | # Any issues using this script should be reported at: #
8 | # https://github.com/Xaero252/unraid-plex-nvdec/issues/ #
9 | ###########################################################################
10 |
11 | # This is the download location for the raw script off github. If the location changes, change it here
12 | plex_nvdec_url="https://raw.githubusercontent.com/revr3nd/plex-nvdec/master/plex-nvdec-patch.sh"
13 | patch_container_path="/usr/lib/plexmediaserver/plex-nvdec-patch.sh"
14 |
15 | # This should always return the name of the docker container running plex - assuming a single plex docker on the system.
16 | con="$(docker ps --format "{{.Names}}" | grep -i plex)"
17 |
18 | ####
19 | # Helper functions
20 | ####
21 |
22 | # Usage: checkdep appname
23 | checkdep() {
24 | if ! command -v $1 >/dev/null 2>&1; then
25 | echo -n "Error: Dependency '$1' is not in the path. Is it installed?"
26 | exit 1
27 | fi
28 | }
29 |
30 | ####
31 | # Check dependencies
32 | ####
33 |
34 | # Verify plex container is running
35 | if [ -z $con ]; then
36 | echo -n "Error: Cannot find Plex container. Make sure it's running and has 'plex' in the name."
37 | exit 1
38 | fi
39 |
40 | checkdep wget
41 | checkdep docker
42 |
43 | ####
44 | # Main work
45 | ####
46 |
47 | # Uncomment and change the variable below if you wish to edit which codecs are decoded:
48 | #CODECS=("h264" "hevc" "mpeg2video" "mpeg4" "vc1" "vp8" "vp9")
49 |
50 | # Turn the CODECS array into a string of arguments for the wrapper script:
51 | if [ "$CODECS" ]; then
52 | codec_arguments=""
53 | for format in "${CODECS[@]}"; do
54 | codec_arguments+=" -c ${format}"
55 | done
56 | fi
57 |
58 | echo "Applying hardware decode patch..."
59 |
60 | # Grab the latest version of the plex-nvdec-patch.sh from github:
61 | echo -n 'Downloading patch script...'
62 | wget -qO- --show-progress --progress=bar:force:noscroll "${plex_nvdec_url}" | docker exec -i "$con" /bin/sh -c "cat > ${patch_container_path}"
63 |
64 | # Verify that wget was successful
65 | if [[ $? -ne 0 ]]; then
66 | echo -n "Error: wget download failed, non-zero exit code."
67 | exit 1;
68 | fi
69 |
70 | # Make the patch script executable.
71 | docker exec -i "$con" chmod +x "${patch_container_path}"
72 |
73 | # Run the script, with arguments for codecs, if present.
74 |
75 | if [ "$codec_arguments" ]; then
76 | docker exec -i "$con" /bin/sh -c "${patch_container_path}${codec_arguments}"
77 | else
78 | docker exec -i "$con" /bin/sh -c "${patch_container_path}"
79 | fi
80 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # unraid-plex-nvdec
2 |
3 | ## DISCLAIMER
4 | __This script now uses someone elses work!__
5 |
6 | Please visit https://github.com/revr3nd/plex-nvdec/ for the author of the new transcode wrapper, and show them your support!
7 | Any issues resulting from using this script should be reported either on this repository, or on the unraid forums here:
8 |
9 | ## BEFORE YOU BEGIN
10 | Ensure that Plex, and the unraid-nvidia environment is working properly. Follow the instructions from the LinuxServer.io team to configure Plex to use the nvidia container runtime and pass through your card. Make sure you can transcode videos with that environment __before__ attempting to use this script.
11 |
12 | If you've manually applied, or installed any other version of this script prior to one using revr3nd's wrapper - please force update your Plex docker before proceeding.
13 |
14 | ### REQUIREMENTS
15 | * Working Plex and Unraid-Nvidia setup.
16 | * User Scripts plugin from Community Apps.
17 | * A little bit of time.
18 |
19 | ### First time setup
20 | 1. Create a new script in the "User Scripts plugin" by clicking the "Add new Script" button on the "User Scripts" page in Settings.
21 | 2. Enter a name for the script, "Plex nvdec enable" is the name I use, but you can name it anything you like.
22 | 3. Click the name of the script, and then click "Edit Script."
23 | 4. Delete the contents of the edit pane.
24 | 5. Copy the contents of [Plex nvdec enable.sh](Plex_nvdec_enable.sh) from this repository into the empty edit pane.
25 | 6. Click Save Changes.
26 | 7. Click "Run Script" next to the script on the User Scripts page.
27 | 8. (Optional) Set a schedule to run the script. Highly recommended to reapply the patch each time Plex is updated.
28 |
29 | ## Testing
30 | To test that this works, go to the command line on unraid, then run `nvidia-smi dmon -s u`. You'll see the final 2 columns be `enc` and `dec` which represents encoding and decoding by the GPU. Now go to a plex client and play a movie that will do a transcode. If this patch worked, you'll see both columns be non-zero as it's transcoding. If only the `enc` column is non-zero, something went wrong with your patch.
31 |
32 | ## Updating
33 |
34 | To update, simply edit the script, and paste the new code in. This script shouldn't be updated very often, as it is just pulling someone else's generic transcode wrapper.
35 |
36 | ## FAQ
37 |
38 | * __Is there any way to get this script to run automatically when Plex updates?__ _No. There isn't currently an event available to monitor the update of Docker containers. It could be done, but it would have to be done outside of this script. You can however set the script to run every day after you schedule your containers to update._
39 |
40 | * __How do I use the `CODECS` variable, and when should I use it?__ _**Most** users will not need to uncomment this variable. If you wish to experiment with adding various formats to decode, you can uncomment that variable. All "supported" formats are listed in that variable. Know that some of these formats are known to be unstable, or provide unsatisfactory quality output when used with nvdec currently. Below is a list of which formats they are, as well as which ones are enabled by default:_
41 |
42 | * h264 (default) H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
43 | * hevc (default) H.265 / HEVC (High Efficiency Video Coding)
44 | * mpeg2video MPEG-2 video
45 | * mpeg4 MPEG-4 part 2
46 | * vc1 SMPTE VC-1
47 | * vp8 (default) On2 VP8
48 | * vp9 (default) Google VP9
49 |
50 |
--------------------------------------------------------------------------------