PLEX in Docker WITH Hardware-Accelerated Transcoding

Discussion about Plex and Emby Media Server
Locked
sports_wook
Posts: 74
Joined: 04 Feb 2020, 05:00

PLEX in Docker WITH Hardware-Accelerated Transcoding

Post by sports_wook »

There are many benefits to running Plex in a docker container, but the big benefits for me are:
    Being in full control of your updates (not having to wait on TerraMaster to update Plex)
      Having full control over the database files/location (which sometimes disappear/move with Plex updates from TM, causing you to have to start over with your Plex configuration)

      The only downfall to running Plex in a docker container is that you don't have the ability to use hardware accelerated transcoding due to docker not having proper access to the root file system and permissions/access issues to the drivers used to transcode. BUT I think I finally figured out to make this work from docker! It's working properly for me, so here are the steps I took:
      • You must already have Plex running as a docker container. For more info see here
      • Use a terminal to ssh to your TerraMaster unit, then assume root privileges (sudo su, then enter admin password)
      • Navigate to /etc/init.d/ directory and create a file to correct the permissions for drivers:
        • cd /etc/init.d/
      • Create the file that will fix the permissions:
        • touch plexhwtrcd
      • Edit the file we just created:
        • vi plexhwtrcd
      • Once the file is open in vi editor, hold Shift then hit i to enter edit mode, and enter the following in the file:
        • #!/bin/sh
          sudo chmod 666 /dev/dri/*
        • then hit Escape key to stop editing, hold Shift and hit the ; key, type wq, then hit Enter
      • Give proper/executable permissions to the file you just created:
        • chmod 755 plexhwtrcd
      • Create a symlink from the file we just created to /etc/sc.d directory (this will allow it the script we created to run every time the system is booted because otherwise the permissions will rest on reboot):
        • ln -s /etc/init.d/plexhwtrcd /etc/sc.d/plexhwtrcd
      • For the rest of the steps, you MUST have Portainer installed - either through the TM Applications store, or running in Docker as a container. Either one is fine. All of these steps in Portainer may not be necessary, but these are the changes I made in Portainer that are working for me:
        • Stop/edit the Plex container in Portainer
        • Navigate to the Runtime & Resources tab, and enable "Privileged Mode" switch
        • Next to Devices click '+add device' and enter the following for host AND container:
          • /dev/dri
          • 2- Portainer container changes_Page_1.jpg
        • Navigate to the Capabilites tab and enable DAC_READ_SEARCH switch:
          • 2- Portainer container changes_Page_2.jpg
        • Click Deploy the container button in Portainer
      • Reboot your system
      After reboot, navigate to the Acitivity Dashboard on your Plex page, and try streaming a video either in another browser tab or from another device. My Plex is set to stream at original quality within my home network, so I used my iPhone to stream a video from cellular network so that transcoding would occur. When hardware acceleration is being used, you should see (hw) next to the Video format as shown below from my own Plex server (as explained here
      hwtranscode.jpg
      I've noticed far lower system resources being used when video is being transcoded after following these steps, so I believe it is working. The Plex support page on transcoding also verifies that it's working properly for me since (hw) is shown next to the Video format in the screenshot above from my Plex server.

      Open to any feedback/suggestions if anyone has recommendations for improvements or corrections, but I wanted to share since I seem to have finally figured this out!
      unixtall
      Posts: 56
      Joined: 31 Dec 2019, 19:02

      Re: PLEX in Docker WITH Hardware-Accelerated Transcoding

      Post by unixtall »

      wooo incredible post.

      I remember that we talk about it. Thanks for the tutorial for transcode. I will test.

      Thanks you
      sports_wook
      Posts: 74
      Joined: 04 Feb 2020, 05:00

      Re: PLEX in Docker WITH Hardware-Accelerated Transcoding

      Post by sports_wook »

      Just updated form 4.2.14 to 4.2.15 and can confirm that this survived through the update and no need to reconfigure. Still working properly with successful hardware transcoding after the system update.
      Locked