Enable Plex Hardware Transcoding on Synology Nas
Plex on Docker on Synology: enabling Hardware Transcoding
Today, I wanted to find out how to enable hardware transcoding in Plex, running in a Docker container, on a Synology DiskStation Manager system.
To testify you what the situation was like earlier enabling hardware transcoding, I played the moving-picture show Joker on my mobile telephone, transcoding to 720p. As you can see in the paradigm below, Plex used almost 100% of the CPU without hardware transcoding. The fan of the device was sounding like a jet engine!
After some lilliputian around, I found a way to do this pretty easily. I idea it would be a good idea to share the solution with the globe (which took more than fourth dimension to do), and so here you lot are! Grab a cup of coffee, considering it may be going to have a while to read and execute. 😅
What needs to be washed
- Grant access to graphics device nodes.
- Create or modify a Plex Docker container.
- Have fun!
Observe out if your Intel® processor supports Intel® Quick Sync Video hither, which you demand if you apply the integrated graphics of your Intel® processor. For hardware transcoding back up on other processors, endeavour this article from Plex.
If you are a Xpenology user, you may need a modified actress.lzma and extra2.lzma for having DSM 6.2.3 to recognize your Intel® integrated graphics (i915). Click for more than info.
Another point of attention
I tin can highly recommend to take a shared folder for docker containers. For example, I have a shared binder called "docker" and created a subfolder called "plex". The docker/plex binder will be example sensitive in every footstep, then brand certain that when y'all used capital letters in the binder name, yous too use those in the following commands and scripts.
If you take an existing Plex container without using a shared folder for the configuration, you lot need to copy the /config and /transcode folders from an existing Plex docker container to the shared docker/plex folder. Accept a wait at this article to learn how to re-create folders from docker containers. Then SSH into DiskStation Manager and re-create the folders. I used these commands for example (the /config folder can have a long time):
sudo su
docker cp plexinc-pms-001:/config /volume1/docker/plex/
docker cp plexinc-pms-001:/transcode /volume1/docker/plex/
Make sure that yous mount the volumes docker/plex/config to /config and docker/plex/transcode to /transcode before you run the adjusted container subsequently.
Grant access to graphics device nodes
First we need to allow the Docker containers to have access to the graphics device nodes. Those device nodes are almost likely /dev/dri/card0 and /dev/dri/renderD128. Y'all can check that if you SSH into DiskStation Managing director:
cd /dev/dri/
ls -50
In my instance that returns the following result:
full 0
crw------- 1 root root 226, 0 Aug 3 20:41 card0
crw------- 1 root root 226, 128 Aug three 20:41 renderD128
Notation that the device permissions are crw--------. The c stands for "graphic symbol device" and rw stands for read and write permissions for the user root. There are no group permissions or other permissions set at this time.
You could go ahead and use the command chmod to edit the permissions, merely the permissions will be reset to their defaults later a reboot of your DiskStation Director system. You can solve this by running a script that handles this every fourth dimension the organization boots.
- Create the post-obit file in your docker/plex folder: devicepermissions.sh
- Edit the file, add the following lines and salve the file.
#!/bin/sh
sudo chmod 666 /dev/dri/*
When executed, this command sets the permissions of all device nodes in /dev/dri/ to crw-rw-rw-. The group root and other users now take read and write access too. I should mention that this makes your organisation less secure, every bit other users than the root user volition now have access to the device nodes. Permit'southward say that danger is my centre name.
You can too set the permissions for the specific device nodes if yous use the following lines:
#!/bin/sh
sudo chmod 666 /dev/dri/card0 /dev/dri/renderD128
- Now become to the Control Console and open up the Task Scheduler.
- Create a task: click Create > Triggered Task > User-divers Script.
- Requite your job a name (eg. Device Permissions), set the user to root and set event to Kicking-upwards.
- Set the following line as run control and click OK.
bash /volume1/docker/plex/devicepermissions.sh
Manually run the script from the Chore Scheduler to ready the permissions without having to perform a reboot. If you listing the device nodes over again, information technology looks like this:
full 0
crw-rw-rw- 1 root root 226, 0 Aug 3 20:41 card0
crw-rw-rw- 1 root root 226, 128 Aug 3 20:41 renderD128
Create or change a Plex Docker container
I hope that I don't have to explain how you download the image and create a Docker container. If that is the case, this article probably isn't for you lot. At that place are nonetheless some things that you have to make certain:
- You need to run the container using loftier privilege.
- Don't run the container immediately after creating information technology. If you have a Plex container already running, stop the container.
At present yous need to edit some settings that are not bachelor through the Docker GUI on DiskStation Manager. Select your freshly created or electric current Plex container in the Docker GUI and click on Settings > Export. Select Export container settings and export the settings to a location of your option.
Now open up the exported settings file (.json) in a program like notepad. At that place you will find the following line:
"devices" : null,
Replace that line with the following lines. Suit it to your needs if you have dissimilar graphics device nodes. Read more about adding devices in this article.
"devices" : [ { "CgroupPermissions": "rwm", "PathInContainer": "/dev/dri/card0", "PathOnHost": "/dev/dri/card0" }, { "CgroupPermissions": "rwm", "PathInContainer": "/dev/dri/renderD128", "PathOnHost": "/dev/dri/renderD128" } ],
Salvage the file and go back to the Docker GUI. Click on Settings > Import and select the edited file. Enter a unique container name, because it will create a new container with the settings from the settings file. Afterwards that, make sure that you disable car-restart on the old container.
Permit's try this thing out
So, let's fire up Plex and meet if hardware transcoding is working now. I watched the movie Joker on my mobile phone, transcoding to 720p once again. Annotation that Transcode now has (hw) behind it, indicating that hardware transcoding is working. The results speak for themselves! As you tin can encounter in the image beneath, the CPU usage is reduced drastically.
Initially, the CPU usage is virtually xl%, probably because it is transcoding ahead. After some time, the CPU usage drops even more! Mission success.
If information technology is still not working for you, make sure that you accept Use hardware acceleration when available enabled on the Transcoder settings page in Plex.
Wrapping things up
I hope that this article helped you to configure hardware transcoding likewise. If you have some remarks or questions, feel gratis to leave a comment. I volition not help you to set up the whole thing. 😜
0 Response to "Enable Plex Hardware Transcoding on Synology Nas"
Post a Comment