Plex: Guide to Moving Transcoding to RAM


Recommended Posts

On 10/13/2022 at 6:37 PM, Hoopster said:

...I have this in my go file to limit transcoding to 16GB and to recreate the folder in RAM on reboot:

mkdir /tmp/PlexRamScratch
chmod -R 777 /tmp/PlexRamScratch
mount -t tmpfs -o size=16g tmpfs /tmp/PlexRamScratch

With this, the mapping in the Plex docker container is /transcode to /tmp/PlexRamScratch

 

This forces Plex to reclaim space by deleting older transcoded bits that have already played rather than just waiting to delete them all when the entire transcode finishes.

 

For those who may not realize, for this to work, the PLEX container must be mapped like this:

 

 

 

transcode.thumb.png.61fa8f285a018899f187e434327f70cc.png

 

 

 

craigr

Edited by craigr
clarity
  • Like 1
Link to comment
15 hours ago, craigr said:

 

For those who may not realize, for this to work, the PLEX container must be mapped like this:

 

 

 

transcode.thumb.png.61fa8f285a018899f187e434327f70cc.png

 

 

 

craigr


you can also accomplish this within Plex server settings specify the transcode directory to be /transcode/PlexRamScratch instead of it being /transcode 

Edited by tmchow
  • Like 1
Link to comment
  • 7 months later...
28 minutes ago, cholzer said:

Funny problem, Plex on my AppleTV complains that there is not enough disk space to transcode.
And indeed, the ram disk it is full.
 

Filesystem      Size  Used Avail Use% Mounted on
tmpfs           8.6G  8.5G  107M  99% /tmp/PlexRamScratch


Shouldnt Plex clean up old transcode files?

Yes but there are 2 things that could stop it. 1. If the stream session isnt closed, it doesnt clean up after itself. 2. Depending on what kind of transcode quality youre trying to watch, 8,6GB isnt enough in size(especially if someone else is transcoding simultaneously). I think Plex does have "emergency trigger" which will clean up if the destination has not enough space anymore but it might be that the current available space is too much for plex to see the issue.

Edited by Mainfrezzer
  • Like 1
Link to comment
8 hours ago, Mainfrezzer said:

Yes but there are 2 things that could stop it. 1. If the stream session isnt closed, it doesnt clean up after itself. 2. Depending on what kind of transcode quality youre trying to watch, 8,6GB isnt enough in size(especially if someone else is transcoding simultaneously). I think Plex does have "emergency trigger" which will clean up if the destination has not enough space anymore but it might be that the current available space is too much for plex to see the issue.


The AppleTV is the only device which accesses my Plex Server and the transcoding is audio only as Video is direct streamed (Apple still refuses to support TrueHD / DTS-HD).
So I thought that 8GB should be enough for this. But I have increased it to 16GB now.
I wonder why Plex Server does not clean up after itself.

However previously I have noticed that the transcode folder rarely reset in size while I was transcoding to an SSD. I always manually deleted the folder once a week.

Edited by cholzer
Link to comment
3 minutes ago, cholzer said:

I wonder why Plex Server does not clean up after itself.

when i tested it (compared to emby which is known NOT to cleanup) plex indeed did free up while the transcode destination got filled up, but i  only tested inclugin video transcode to make sure ... but no ios devices here ;)

 

TrueHD Transcode is known to use alot of space (whyever) ... may thats your culprit as its audio only ...

 

so your questions rather should go to Plex Forums instead here including some debugging ...

  • Like 1
Link to comment
  • 2 weeks later...

with compose it looks like this is working
 

    volumes:

      - /mnt/user/Docker/Plex:/config

      - /mnt/user/Video/Películas/:/media/Películas:rw

      - /mnt/user/Video/Movies/:/media/Movies:rw

      - /mnt/user/Video/Series/:/media/Series:rw

      - type: tmpfs

        target: /transcode

        tmpfs:

          size: 2000000000

 

I don't see disk writes while transcoding by plex, but If I remove them I can see a constant 1-2 mb/sec of writes by plex transcoder process in htop.

 

Is there any other way to check that is working? it looks like tmpfs is not using /dev/shm

Link to comment
  • 1 month later...

I have NVIDIA GPU transcoding working on my server. But I have a fair bit of ram i'd like to utilize also for transocding. But I do not think it is working as I am still getting very low ram usage according to unaid and plex dashboard. 

 

CONTAINER: BINHEX PLEX

 

image.thumb.png.4e797aebb24d79bdd7dc28d3f85680b9.png

image.png.98d1f3806e1a55c6ff49750ea79e77a6.png

 

EXTRA PARAMETERS: --runtime=nvidia --device=/dev/dri --mount type=tmpfs,destination=/transcode,tmpfs-size=3200000000 --no-healthcheck

 

image.png.95156b4718d0d6d958521be75de48bed.png

 

Can someone please tell me what am i doing wrong and how to rectify it so I can utilize some ram?

Edited by z0ki
Link to comment
On 10/13/2022 at 7:37 PM, Hoopster said:

This could be a problem.  I used to have mine set up this way but without limiting transcoding RAM in some way, tmp will eventually fill up all available RAM completely especially if there are multiple transcoding sessions going on simultaneously.

 

I also have 64GB RAM on my server but have limited transcoding to using 16GB RAM. 

 

I have this in my go file to limit transcoding to 16GB and to recreate the folder in RAM on reboot:

mkdir /tmp/PlexRamScratch
chmod -R 777 /tmp/PlexRamScratch
mount -t tmpfs -o size=16g tmpfs /tmp/PlexRamScratch

 

With this, the mapping in the Plex docker container is /transcode to /tmp/PlexRamScratch

 

This forces Plex to reclaim space by deleting older transcoded bits that have already played rather than just waiting to delete them all when the entire transcode finishes.

Hello,
Was reviewing this post as I am soon to be migrating back to PLEX DOCKER from another OS. 
Are there some 'best practices' other than this transcode recommendation regarding the PLEX DOCKER deployment that are recommended?
I will keep skimming this thread and attempt to collect information. 

 

Look forward to hearing back.

 

Thanks.

Link to comment
31 minutes ago, bombz said:

Are there some 'best practices' other than this transcode recommendation regarding the PLEX DOCKER deployment that are recommended?

I don't know about recommended but I also have Plex appdata folder on a dedicated SSD.  I separated it from other Docker container appdata because Plex appdata can get large and backing it up and restoring it is easier with dedicated storage.

 

This is certainly not a necessity.  It is just a personal preference.

Link to comment
On 11/10/2023 at 4:14 PM, Hoopster said:

I don't know about recommended but I also have Plex appdata folder on a dedicated SSD.  I separated it from other Docker container appdata because Plex appdata can get large and backing it up and restoring it is easier with dedicated storage.

 

This is certainly not a necessity.  It is just a personal preference.

Hello,

 

This is an interesting idea. I do currently use CA backup for all my current dockers, and you make a good point as the backups would get quite large if including the metadata within the plex docker folder. 
As you stated; you are currently running 'Plex\Library\<matadata>' appdata folder folder on a separate SSD or 'pool' -- out of curiosity, is it simple to point the PLEX docker to another SSD to use that location as the metadata, perhaps a variable that is required to be added upon deploying the PLEX docker?
Can you install PLEX docker to the 'default appdata location' -- while pointing the 'metadata' DIR at another SSD disk/pool?
or
Are you simply pointing the whole PLEX docker instance 'appdata + metadata' at a whole different SSD disk/pool in a btrfs or zfs mirror?
 

I am really curious to this setup because it is an excellent point if/when required to restore the docker the metadata is on a completely different disk. Please feel free to include screens or PM me as I don't want this to hijack the thread out of respect.

Look forward to hearing back.

 

Thank you.

Link to comment
  • 4 weeks later...
On 2/19/2023 at 2:15 AM, craigr said:

 

For those who may not realize, for this to work, the PLEX container must be mapped like this:

 

 

 

transcode.thumb.png.61fa8f285a018899f187e434327f70cc.png

 

 

 

craigr

Hello, 

 

You have altered your go file @ \\UNRAID\flash\config\go 
which I am assuming looks like this?

 

#!/bin/bash
# Start the Management Utility
/usr/local/sbin/emhttp &
echo ; >/usr/local/sbin/mover
mkdir /tmp/PlexRamScratch
chmod -R 777 /tmp/PlexRamScratch
mount -t tmpfs -o size=16g tmpfs /tmp/PlexRamScratch


From there you add the path variable within the plex docker?

 

/tmp/PlexRamScratch


image.png.8a32215ec68f572be52eba377145eff6.png

 

Then within the PLEX GUI set the same transcode DIR?

 

image.png.142ea011994bbab17daf83112619579a.png

 

Would this requirement still be needed in EXTRA PERAMETERS?

 

EXTRA PARAMETERS: 

--runtime=nvidia --device=/dev/dri --mount type=tmpfs,destination=/transcode,tmpfs-size=17179869184 --no-healthcheck

 

Use Nvidia GPU 

-runtime=nvidia

 

Use CPU for Trancodes 

--device=/dev/dri


Use 16GB RAM for Transcode 

--mount type=tmpfs,destination=/transcode,tmpfs-size=17179869184 --no-healthcheck

 

 

Look forward to the feedback for clarity 

Link to comment
On 12/8/2023 at 10:06 PM, bombz said:

Hello, 

 

You have altered your go file @ \\UNRAID\flash\config\go 
which I am assuming looks like this?

 

#!/bin/bash
# Start the Management Utility
/usr/local/sbin/emhttp &
echo ; >/usr/local/sbin/mover
mkdir /tmp/PlexRamScratch
chmod -R 777 /tmp/PlexRamScratch
mount -t tmpfs -o size=16g tmpfs /tmp/PlexRamScratch


From there you add the path variable within the plex docker?

 

/tmp/PlexRamScratch


image.png.8a32215ec68f572be52eba377145eff6.png

 

Then within the PLEX GUI set the same transcode DIR?

 

image.png.142ea011994bbab17daf83112619579a.png

 

Would this requirement still be needed in EXTRA PERAMETERS?

 

EXTRA PARAMETERS: 

--runtime=nvidia --device=/dev/dri --mount type=tmpfs,destination=/transcode,tmpfs-size=17179869184 --no-healthcheck

 

Use Nvidia GPU 

-runtime=nvidia

 

Use CPU for Trancodes 

--device=/dev/dri


Use 16GB RAM for Transcode 

--mount type=tmpfs,destination=/transcode,tmpfs-size=17179869184 --no-healthcheck

 

 

Look forward to the feedback for clarity 

 

My go file PLEX lines:

 

#Limit PLEX Transcode RAM Drive Size
mkdir /tmp/PlexRamScratch
chmod -R 777 /tmp/PlexRamScratch
mount -t tmpfs -o size=32g tmpfs /tmp/PlexRamScratch

 

image.thumb.png.022f2d3f5777ea953665c964f5995fbf.png

 

image.thumb.png.743c30210d79b596401e05bafba12161.png

 

image.thumb.png.ffc33220609d5a7ad3256716be31db34.png

 

I do not have any extra parameters.  I am however using the Intel IGPU not Nvidia.

 

Good luck!

Edited by craigr
Link to comment
On 12/9/2023 at 5:06 AM, bombz said:

Would this requirement still be needed in EXTRA PERAMETERS?

 

nope, its either / or ... both ways are fine and in the end the same result, but you dont need todo so "double"

 

On 12/14/2023 at 4:17 AM, frodr said:

Will the guide work on Jellyfin?

yes, but be aware that jellyfin (emby) does not clean up once the (ram)disk gets full (while transcodes are running), so it should be big enough to handle ...

Link to comment
  • 3 weeks later...
9 minutes ago, smaiderman said:

Is there a way to check if everything is working as intended?

 

Look in the folder you have designated in RAM for transoding (/tmp/PlexRamScratch on my system).  There should be a Transcode folder there with a Sessions subfolder which contains the transcoding pieces if things are working properly.

 

image.thumb.png.59a04f84ddb7a31b509e3a0b13aaeb5c.png

Link to comment
38 minutes ago, Hoopster said:

 

Look in the folder you have designated in RAM for transoding (/tmp/PlexRamScratch on my system).  There should be a Transcode folder there with a Sessions subfolder which contains the transcoding pieces if things are working properly.

 

image.thumb.png.59a04f84ddb7a31b509e3a0b13aaeb5c.png

Mine looks loke this, No "sessions" folder, but others
image.thumb.png.df9aa4c37aa725feda8e1963d2c7cf63.png

 

Is this working?

Thank you again :)

Link to comment
1 hour ago, smaiderman said:

Is this working?

Mine has always had the /tmp/PlexRamScratch/Transcode/Sessions structure; however, if you see the transcode files being created and deleted in your folder structure as a file is being transcoded, that would indicate it is working properly.

Link to comment

Thank you for this guide, this seems to be working for me as I can see items being created in the sessions folder on the RamScratch disk.

 

However, I have 'stopped' a plex viewing halfway throguh and can still see items in the 'session' folder on the RamScratch Disk, how long does it usually take to remove these?

 

Link to comment

I've followed the guide from @craigr but for some reason the transcode isn't taking place on the RAM, as shown in the first screenshot.

chrome_9TlsHh1DKX.png.e80dac730d5ae6050e2a4987008db68e.png

 

The movie is definitely being transcoded as you can see below.

chrome_FVVk7x1UuG.png.b09cb8dfdbba30438448cf6a2c4891f2.png

 

My Plex docker setup is shown below.

chrome_cIniChH0rO.png.b39824c753682c8b3ac8d2616ecdcf53.png

 

chrome_ayWZFfOM1Z.thumb.png.770d65c7c553e6dc0c85a723e2d6fd2e.png

 

I dont know where i've gone wrong and I cant figure out where the transcoding session is because it's not in my Appdata either.

chrome_9Iw9LXPLAk.thumb.png.821771e1eadc750227d4f3b2468cd558.png

 

If anyone could help me out i'd really appreciate it. Thanks

Link to comment
  • 3 weeks later...
On 1/8/2024 at 12:10 PM, ChutneyBadger said:

I've followed the guide from @craigr but for some reason the transcode isn't taking place on the RAM, as shown in the first screenshot.

chrome_9TlsHh1DKX.png.e80dac730d5ae6050e2a4987008db68e.png

 

The movie is definitely being transcoded as you can see below.

chrome_FVVk7x1UuG.png.b09cb8dfdbba30438448cf6a2c4891f2.png

 

My Plex docker setup is shown below.

chrome_cIniChH0rO.png.b39824c753682c8b3ac8d2616ecdcf53.png

 

chrome_ayWZFfOM1Z.thumb.png.770d65c7c553e6dc0c85a723e2d6fd2e.png

 

I dont know where i've gone wrong and I cant figure out where the transcoding session is because it's not in my Appdata either.

chrome_9Iw9LXPLAk.thumb.png.821771e1eadc750227d4f3b2468cd558.png

 

If anyone could help me out i'd really appreciate it. Thanks

Hi,

not sure if you still have this issue, it seems that you set your Plex Media Server to /Transcode and yet the docker refers to /transcode. For Linux based OS, capital is different than lower case. 

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.