[Guide] Plex Transcoding and RAM Disks

So you have a server with a ton of RAM and you want to use this RAM disk thingy that everyone keeps talking about. How do you do it? It’s super easy, barely an inconvenience. First, a quick overview, just what the heck is a RAM disk? A RAM disk is a portion of your system memory that is presented as a storage device just like a USB stick or a hard drive. You can read and write data to the disk as much as you want, and it won’t wear out like an SSD or a spinning drive. It is temporary in nature, so anything that you leave on the drive will disappear when you turn the computer off.

Now that you know what a RAM disk is, here’s how you can use it. The method varies slightly depending on what OS you’re using, but the end result will be the same. Find your OS below and follow the steps listed to configure your system. One quick note, the directions here will change the transcoding folder for live transcodes only. If you have optimized versions set up for your media, or clients sync media at something other than original quality, they will still be placed in the Plex library Cache\Transcode folder.

Choose your OS

Container in Unraid

Unraid has a built-in shared RAM disk accessible under the /dev/shm folder. This shared RAM disk defaults to half of the total system memory, which should usually be more than enough for a few Plex transcodes.

  1. Edit the configuration of your Plex container and add another path. You want to map /dev/shm on the host to /transcode in the container.

  2. Once the Plex container has started, open the Plex Web UI. Go to SettingsTranscoder. Click the Show Advanced button and set the Transcoder temporary directory to /transcode. Save the changes.
    image


Most modern Linux distros on bare metal

Nearly all modern Linux distributions have a built-in shared RAM disk accessible under the /dev/shm folder. If you’re not sure whether or not your distro has the built-in disk, just check to see if the /dev/shm folder exists. The built-in shared RAM disk defaults to half of the total system memory. If you’re using one of the distros that has this built-in, and you’re running Plex directly in the OS (ie not in a container), then changing the transcode folder is one simple step.

  1. Open the Plex Web UI. Go to SettingsTranscoder. Click the Show Advanced button if necessary, and change the Transcode temporary directory to /dev/shm. Save the settings.

Container on a bare metal linux distro

Just like in the unraid instructions, all you need to do is add a volume to map the /dev/shm folder
on the host to the /transcode folder in the container. If you’re using Docker for your containers and you followed the instructions for the official Plex container or the linuxservers container, you should already have a folder mapped to /transcode.

  • Docker
    Recreate your container, adding the following to the command
    -v /dev/shm:/transcode
    
  • Docker-compose
    Add the following line to the volumes section of your Plex container definition
    - /dev/shm:/transcode
    

Virtualized linux distro

The steps to change the transcode folder are identical to changing it on a bare metal distro, but if you’re virtualizing your OS, I would recommend reserving enough RAM to cover the RAM disk plus the OS. In this situation, you may also want to adjust the size of the RAM disk so it doesn’t default to half of the available RAM. See the instructions below for this.


Windows

Windows doesn’t have a built-in RAM disk, so you’ll need to install a program to create it for you. There are several options to create RAM disks, some of them come with more limitations than others. I’m going to use SoftPerfect RAM Disk v3.4.8 for my walk through, but if you prefer another program it should work just as well, as long as will automatically mount the disk and assign it a drive letter on boot. You can download SoftPerfect from MajorGeeks here: Download SoftPerfect RAM Disk - MajorGeeks
Please note that this program has been discontinued by the developer, but I have been using it for several years with no issues.

  1. Install SoftPerfect RAM Disk and open the program. Click the Plus icon to add a new RAM disk.
    • Set the size to how much RAM you want to use for the disk. I’m using 2048 in this example because this computer doesn’t have much RAM, but you should be able to use 4096MB (4GB) if you have 16GB, and 8192MB (8GB) if you have 32GB.
    • Change the drive letter to an available letter. I picked R: for RAM disk, but you can pick whatever floats your boat.
    • Finally, set the filesystem to NTFS
    • Leave the other options at their defaults. Click OK to create the RAM disk.
  2. Once the RAM disk is created, you just need to configure Plex to use the disk for transcoding. Open the Plex Web UI and go to SettingsTranscoder. Click on the Show Advanced button, and change the Transcoder temporary directory to the drive letter you entered above. Save your changes.

Advanced Topics

Changing the size of your shared RAM disk in Linux

As I mentioned above, the shared RAM disk defaults to half of the available system RAM. If you would like to change it to be larger (or smaller) by default, you will need to edit the /etc/fstab folder to adjust the size. Open /etc/fstab in your editor of choice and check for an existing line that mounts /dev/shm. If one doesn’t exist, create one with the following syntax:

tmpfs  /dev/shm  tmpfs  defaults,size=1g  0  0

Once you’ve made the change, you can remount the folder mount -o remount /dev/shm or reboot.

How much RAM do I need?

Short answer: At least 16GB total system RAM, with 8GB allocated to RAM disk.

Long-winded explanation:

When Plex needs to transcode media for any reason (resolution or bitrate change, container change, audio conversion, subtitles, etc.), it uses the transcode folder. It pulls the streams out of the original container in 8 second chunks, transcodes them if necessary, and then dumps them in the transcode folder. Depending on the bitrate, the video chunks can range anywhere from about 7 megabytes per minute for a basic SD video to 200+ megabytes for a high bitrate 1080p file. And if you have 4K media, you could be looking at 400-500MB per minute.

Plex keeps these chunks around even after they have been watched, until the playback stops (pausing is not stopping, and a paused video will keep the chunks around indefinitely) or until the transcode folder drops to less than 100MB of free space. Plex has some intelligence baked in that should remove the oldest watched chunks once the free space drops to 100MB, but if that can’t keep up, you can get the dreaded “Playback Error Conversion failed” error when you try to start playback.

10 Likes

Hell of a write up

Is there a guideline for how big the transcode directory needs to be? Currently use an old 120GB ssd that works well and that I dont care about killing. shm of 16GB large enough?

That really depends on what bitrate the media is being transcoded to. If you transcode to 4Mbps 720p, a 2 hour movie will take on average about 1.5GB of space based on the testing I’ve done. 8Mbps 1080p will be roughly double that, 3GB for a 2 hour movie In an ideal world most of your clients will be direct playing/direct streaming anyway, but if you have to transcode due to bandwidth limitations or shitty clients, you can use these numbers to gauge roughly how much space you might need.

Interesting, I tried switching it, and the max transcode was 0.8x. Must be some disconnect between running docker vi a linux vm. With the dedicated ssd my transcode rate is around 1.6x. Also seeing a higher iowait in netstat with the /dev/shm .

oh, making a walk through of creating a ram disk for plex is Tight.

1 Like

So I would just like to ask if this is going to boost performance or if it’s just mostly for saving your SSD from the R/W?
I have used it before ( a long time ago) and tbh I never noticed any performance boost. TBH I feel like I ran into “server isnt powerful enough” errors more often. This of course being a time before HWT was really something to use but I mean this was running on a I7 4770 back then so things might be better now. I am trying to keep the power cost down so with a i3 8100 and 8gb ram ( 1 stick) and a ITX MOBO 4 HDDs (4TBs each) its only pulling like 10-15 watts at idle. one of the big reasons I switched from my R7 2700x with 64gb ram and like 12 HDDs (2TB each) ATX MOBO and a 1080TI running 24/7 was for power savings but by buying more ram ill be well not saving much to say the least lol.

It’s both a performance boost and an SSD saver.

So the recently Plex passwords were hacked so I ended doing what most did which was log out of everything which I didn’t realize logged both of my PMS servers off. My main one I still couldn’t get back up going again after much trial and error.

I was about to move back from a dedicated box anyways so I went ahead and did a Unraid docker of Plex. I don’t use hw transoding much but wanted to at least have the option. I do have plexpass for those wondering. I think it is help most for me for watching local tv via antenna.

I was following the instructions in this video.

which is hard to see what the heck is going on but I’m not seeing what he’s pulling up as an option. I don’t have two gpu’s…just using the Intel integrated cpu on I believe a 10th gen cpu.

So anyway I was wondering if someone could help assist with this. I did not use the Plex container from Linuxserver because the first one I saw was Plex Media Server and just went with that one. Linuxserver.io doesn’t have the options that are in that video for me.

For the time being I went to extra parameters and entered
–device=/dev/dri:/dev/dri

the container I choose (plexinc/pms-docker) has to have transcoding set so I also did /dev/shm

I didn’t give any arguments but I’ll have to tinker around and see if it’s working or not.

Edit: Everything seems to be working correctly getting the little (hw) next to transcoding

I’m using an 8gb ram disk with a Crystal Disk Mark of around 9GB/s read and 15GB/s write. It’s working well but wondering if it’s overkill. I have a 500GB NVME that’s showing around 1.7GB/s read and write throughput. Would moving to the NVME drive be a good option? Seems like adding to the 24 GB usable RAM might be helpful. Thanks

I know this is a great but older guide but ive been trying to figure out my HW Transcoding issue for quite some time. Everything workins find with SW transcoding but something changed recently and i cant figure out what. When I try to HW transcode i get: Denying access due to session lacking permission to transcode key

Anyone have any ideas? Transcoding to ram just as the guide has it