Plex: Guide to Moving Transcoding to RAM


jonp

356 posts in this topic Last Reply

Recommended Posts

5 hours ago, SPOautos said:

Since Kodi can direct play them all

Kodi uses the Client's CPU to decode any audio and video stream. Instead Plex uses mainly the media decoding API of the Client. By that Plex works on any low power hardware while Kodi does not.

 

Finally it would be easy. Plex only needs to include different players or allow using external player softwares. There are different feature requests in the forums pointing to this:

https://forums.plex.tv/t/request-update-to-latest-exoplayer-android-firetv-listen-to-your-customers/622086

https://forums.plex.tv/t/feature-request-configuring-external-player-like-mpc-or-vlc-for-pmp-on-windows/312576

 

I think Plex ignores them because Plex can't guarantee judder-free playback as it depends on resolution, hdr/sdr, bitrate, etc if the clients CPU has enough power to play a stream. Instead, the client's API guarantees it and everything that is not supported by the client, will be transcoded. Another reason could be, that they don't want users leaving the Plex UI and including open source players is a problem as Plex is making money with their software which could be disallowed by the open source players.

 

But finally you still have options. You could use Plex as your server and still use Kodi, Infuse, etc as your Player. Those softwares have Plex plugins for that.

 

Or you transcode all your content, so it can be played directly. This is how Netflix & Co solves it.

 

Or you consider using Emby / Jellyfin. They support external playback as far as I know.

Link to post
  • Replies 355
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Hey everyone, just thought I'd put this up here after reading a syslog by another forum member and realizing a repeating pattern I've seen here where folks decide to let Plex create temporary files fo

By this guide Plex uses your RAM while transcoding which prevents wearing out your SSD.   Edit the Plex Container and enable the "Advanced View":   Add this to "Extra Paramet

That should be correct, also make sure that the "Transcoder temporary directory" in Plex is set to /transcode Transcoding can require a lot of space and there might be risk of running out of RAM.

Posted Images

On 1/2/2021 at 4:46 AM, mgutt said:

That's the reason why you should limit the RAM path to 4 or 8GB. Even your server can crash.

 

Plex uses as much space for the temporary transcoding files as available. This has nothing to do with 4K. The same would happen if multiple clients transcode 1080p streams. Plex preserves so much files so the user is able to jump back on the timeline without the need to re-transcode. But as this is a rare case, you can limit the RAM usage without problems. Plex starts cleaning when there is no space left. In theory you could even limit it to 100MB (don't do it, causes juddering ;) ).

 

I’ve created a 4GB Ramdisk folder for Plex transcoding and it’s working perfectly.  It fills up and then Plex clears it out seamlessly. Thanks again for the reply. 

Link to post
On 12/14/2020 at 1:03 PM, UnraidDuck said:

Thanks to @Hoopster Reminder to RTFM, I now have Plex transcoding to the RAM disk.

image.thumb.png.39e700294516b702286818dc13d5c67d.png

So I also use Binhex PlexPass container so this image is super helpful! What I am curious about is which script did you end up using as I see two different ones posted in the comments.

 

There's this one...

#!/bin/bash

mkdir /tmp/PlexRamScratch

chmod -R 777 /tmp/PlexRamScratch

mount -t tmpfs -o size=4g tmpfs /tmp/PlexRamScratch

 

And also this one...

#!/bin/bash

mkdir /tmp/PlexRamScratch

mount -t tmpfs -o size=4g tmpfs /tmp/PlexRamScratch

Link to post
  • 3 weeks later...

So if you limit the ram to only use 4gb, it will delete once it reaches that limit and keep going. The alternative would be once the movie stops playing, it deletes it all at once. Does this sound correct?

 

Link to post
On 19.9.2020 at 1:22 PM, mgutt said:

New Guide which uses only a limited size of your RAM

I currently came across this and don't know if this was already mentioned here but this would be also achievable with a entry in the template at 'Extra Parameters':

 

--mount type=tmpfs,destination=/transcoding,tmpfs-size=4000000000

image.png.9624a396f2b9e442f03ebb18135ef02c.png

 

In the above example a RAMdisk is created with a limit of 4GB (the size has to be defined in bytes).

Link to post
8 minutes ago, ich777 said:

--mount type=tmpfs

 

It should be:

--mount type=tmpfs,destination=/transcode,tmpfs-size=4000000000

 

As /transcode is the default transcode path of Plex:

280215101_2021-02-0111_27_13.png.b5ded746a154fbc2e4e5bff080c64db5.png

 

This is really nice as it makes it even easier as this tmpfs path only exists inside of the Plex Container. I will update my Guide. Thank you!

 

Link to post

@jonp

 

It would be nice if you could update your first post as follows:

https://forums.unraid.net/topic/35878-plex-guide-to-moving-transcoding-to-ram/?do=findComment&comment=894460

 

It contains the improvement of @ich777 which makes the guide even easier for the user.

 

Using "/tmp" as mentioned in your post is dangerous as an unlimited RAM usage will probably cause server crashes.

Link to post
1 hour ago, UnraidDuck said:

The screenshot has the destination down as /transcoding, is that a typo in the text with

?

Sorry my bad... :P

 

EDIT: Corrected it in my post but that shouldn't matter this describes only the path in the container itself whether it's '/transc', '/transcode', '/transcoding', '/mnt/transcoding' or whatever you want. Just be sure to set the transcoding path in your App (Plex, Emby, Jellyfin,...) to the corresponding path that you defined in the 'Extra Parameters'.

Link to post

ok, well, here it falls back and writes then into /tmp/transcode inside docker which ends up in filling up docker image, nevermind, was just taking a look if it simply works (as i expected too) but fails here.

 

ok, reverted and now it works ... dont ask me why

Edited by alturismo
Link to post
12 minutes ago, alturismo said:

ok, reverted and now it works ... dont ask me why

If the transcode dir physically exists in the container, then this can happen. One user accidentally mapped his movies to /transcode/Movies and since then he was not able to map /transcode as a tmpfs path. Even after he corrected the wrong mapping, he was still not able to use /transcode. I think a fresh Plex installation would solve it (or an update?!). Not sure. But the solution was to use /transcode2 as the tmpfs path and changing this path in the Plex settings accordingly. 

Link to post

yes, confirmed, as i use a script to fix hevc tone mapping for hw transcoding on plex which will end up restarting the docker, after a restart the permissions are messed ... chmod /transcode and its good again

 

so it works when u dont restart the docker .... at least thats my current state

 

and as plex also only needs a restart on updates its not the best choice (yet)

Edited by alturismo
Link to post

@alturismo & @mgutt you can also append permissions to the mounted folder like:

 

--mount type=tmpfs,destination=/transcode,tmpfs-mode=1777,tmpfs-size=4000000000

 

This should set the permissions on every start of the container.

 

EDIT: Should be a little bit more precise, this sets to permissions:

tmpfs-mode=1777

 

Link to post

 

50 minutes ago, ich777 said:

this sets to permissions:

 

Tested this. After setting it the first time it works. But after stopping / starting the container it writes to /tmp/Transcode.

 

Then changed to 700. Same game.

 

Then changed to 0770. Same game.

 

Result after setting 0770 and first start:

755 drwxr-xr-x   3 plex users   60 Feb  1 14:36 transcode

 

Result after stop / start:

755 drwxr-xr-x   2 root root    40 Feb  1 14:37 transcode

 

Executing this inside the container and it works again:

chown 99:100 /transcode

 

Another solution:

Edit the container, change nothing and hit apply (which re-creates the container). 

 

So stop / start and restart does not set the owner. And now?

 

EDIT: Seems to be a bug:

https://github.com/docker/for-linux/issues/138

 

 

 

Link to post
2 minutes ago, mgutt said:

Then changed to 700. Same game.

This defaults to 1700.

 

Forgot to link the source: Click

 

Then this is possibly not usable for Plex, I run it in Emby without a problem, have to investigate further.

Link to post

yes, but not really a solution when u need to run a script after docker run ;) and restart, but im glad im not alone ...

 

same goes for any docker like emby too it seems ... at least after tests here

 

and i would say, this would also hit in when u just restart the server (which in the end restarts dockers too)

Link to post

@ich777 in emby, ffmpeg transcode logs before and after restarting docker

 

before

-segment_list "/transcode/transcoding-temp/95499A.m3u8"

after restarting docker

-segment_list "/config/transcoding-temp/BDAC04.m3u8"

 

of course the segmented files also come in there ...

Edited by alturismo
wrong copy / paste ;)
Link to post

@alturismo & @mgutt

 

I now have a working solution.

Put this into your 'Extra Parameters':

--mount type=tmpfs,destination=/tmp,tmpfs-size=4000000000

 

Then go to your Plex transcoding settings and set the path to '/tmp':

grafik.png.7b7094bbabd5991869740b0d8f56ed1b.png

 

Tested this after 5 restarts and the permissions for '/tmp' are always:

 

After the first start:

drwxrwxrwt   4 root root    80 Feb  1 15:36 tmp

 

After a restart:

drwxrwxrwt   3 root root    60 Feb  1 15:37 tmp

 

After the fifth restart:

drwxrwxrwt   3 root root    60 Feb  1 15:39 tmp

 

 

Hope that helps ;)

Link to post
32 minutes ago, ich777 said:

Then go to your Plex transcoding settings and set the path to '/tmp':

 

Is it needed? As /transcode does not exists, it should fallback to /tmp automatically.

Link to post

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.