Speed up Plex Transcoding on Raspberry

Guides and tutorials for various stuff. Posted by DietPi users.
Post Reply
PiTech
Posts: 7
Joined: Fri May 08, 2020 12:39 pm

Speed up Plex Transcoding on Raspberry

Post by PiTech »

Video tutorial
https://youtu.be/G4aqz1w8MNg


Written tutorial
I have modified my plex transcode directory to use ram insted of slow sd card
it has led to a considerable performace gain
as pi is too slow to transcode video it has great performace for audio
Note:You should not use it if you have little available ram
everything is ram gets wiped on reboot anyways so it is a great place to transcode

mount your ram by
tmpfs /tmp tmpfs defaults,noatime,rw 0 0

use /tmp as transcode directory on plex
klmmc
Posts: 12
Joined: Fri Mar 06, 2020 8:46 pm

Re: Speed up Plex Transcoding on Raspberry

Post by klmmc »

Hi!
Thanks for the tutorial.
How much available RAM do you recommend for this?
User avatar
WarHawk
Posts: 610
Joined: Thu Jul 20, 2017 8:55 am

Re: Speed up Plex Transcoding on Raspberry

Post by WarHawk »

also make sure zram and zswap is turned on, you can tweak it to have swap be 2X times the physical RAM, even compressed it will be MUCH faster than trying to transcode to a HD
User avatar
MichaIng
Site Admin
Posts: 2293
Joined: Sat Nov 18, 2017 6:21 pm

Re: Speed up Plex Transcoding on Raspberry

Post by MichaIng »

Indeed, default transcode dir is on disk because for video transcoding it can easily eat some GiB. But this is exactly as well a reason why it should never be on a SDcard. Got my attention on this topic a few weeks ago and aim to find a good generic solution. Best for now IMO is to move the transcode dir to /mnt/dietpi_userdata/... so that it can be easily (which is always recommended!) moved to an external drive. 99% of cases this will be faster (even regular HDD) and will not kill your SDcard.

Then we could add some little code/tool (or add to dietpi-drive_manager) that allows to easily mount a tmpfs there (in case on lets say 2 GiB+ devices) and indeed as WarHawk suggested make use of zram. I'd use a dedicated tmpfs/zram mount btw so that it does not break regular /tmp usage, which is intended for much smaller files.

Would be great if you guys could print some sizes your transcode dir gets, so we get an overview how much RAM would be required. I see the video leaves /tmp on default size (this would be 512 MiB), but I've seen much larger transcode dirs. Does this depend on other PMS settings?
User avatar
WarHawk
Posts: 610
Joined: Thu Jul 20, 2017 8:55 am

Re: Speed up Plex Transcoding on Raspberry

Post by WarHawk »

Usually for a single video it's about the same size as the video being encoded...max is 2-4G
One should NEVER encode to a SDcard or non spinning media...the writes alone will kill it in short measure!

But that is for a single stream...multiple streams will completely thrash it..

Transcoding on a RPi isn't recommended, the ARM processor just doesn't have the oomph needed to transcode (now preoptimizing for a direct stream might be a good way...but on a RPi will take AGES!)

With that said..I stumbled across someone trying to develop a distributed Plex Remote Transcoder
https://github.com/wnielson/Plex-Remote-Transcoder
A distributed transcoding backend for Plex.

Please help by reporting bugs, pull-requests or feature requests!

For those interested in testing this out quickly, there is a step by step guide for getting this working on two Ubuntu machines. You can find the guide here.

Additionally, for proposed features and some current limitations, check out this page.
How Does it Work?
There have been quite a few projects attempting to load balance a Plex server, most of which involve proxying HTTP requests between multiple Plex Media Server (PMS) installations. This project takes a different, and arguably easier approach that simply involves running the Plex New Transcoder on a remote host. In this setup there is only ever one PMS installation (the master node), but there can be any number of transcode hosts (slave nodes). Since transcoding is typically the most processor intensive aspect of PMS, it makes sense to be able to distribute this workload among all available computing resources.

The way this works is by replacing the default Plex New Transcoder binary on the master PMS with a wrapper. This wrapper allows us to intercept the transcode request on the master node and send it to a transcode slave node. The transcode slave invokes the true Plex New Transcoder binary, does the (trans|en)coding and saves the video segments to a network mounted shared filesystem on the master. The master then sends these segments to the client and the video is played back just like normal.
Image
mail2rst
Posts: 51
Joined: Fri Apr 13, 2018 4:53 pm

Re: Speed up Plex Transcoding on Raspberry

Post by mail2rst »

please guide me. how i can configure transcoding on RAM. i want to created TMP directory on RAM & divert plex to transcode on that folder. please guide me, thanks
MarkVV
Posts: 1
Joined: Mon Jul 20, 2020 1:42 pm

Re: Speed up Plex Transcoding on Raspberry

Post by MarkVV »

PiTech wrote: Sat May 09, 2020 7:48 am Video tutorial
https://youtu.be/G4aqz1w8MNg


Written tutorial
I have modified my plex transcode directory to use ram insted of slow sd card
it has led to a considerable performace gain
as pi is too slow to transcode video it has great performace for audio
Note:You should not use it if you have little available ram
everything is ram gets wiped on reboot anyways so it is a great place to transcode

mount your ram by
tmpfs /tmp tmpfs defaults,noatime,rw 0 0

use /tmp as transcode directory on plex
Thanks. But I need a little bit more RAM.
Last edited by MarkVV on Thu Aug 06, 2020 6:10 pm, edited 1 time in total.
mail2rst
Posts: 51
Joined: Fri Apr 13, 2018 4:53 pm

Re: Speed up Plex Transcoding on Raspberry

Post by mail2rst »

Thanks MarkVV
I follow the video and made provided changes. how i am able to confirm that the /tmp folder mounted on ram location.

like in linux commands LSBLK or BLKID, those show us the mounted drives with linux machine through fstab. when i give lsblk or blkid commands they show me the partition mounted Sda1, sda2 etc. but not this RAM partition. so i just want to confirm transcoding will conducted on RAM. is there any other command show me that system working according to our requirement like show /TMP folder on RAM (not on disk).

thanks
User avatar
Joulinar
Posts: 2068
Joined: Sat Nov 16, 2019 12:49 am

Re: Speed up Plex Transcoding on Raspberry

Post by Joulinar »

@mail2rst

just run df -h and you will see /tmp mounted from tmpfs.

Code: Select all

root@DietPi4:~# df -h |grep /tmp
tmpfs           2,0G    6,9M  2,0G    1% /tmp
root@DietPi4:~#
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
mail2rst
Posts: 51
Joined: Fri Apr 13, 2018 4:53 pm

Re: Speed up Plex Transcoding on Raspberry

Post by mail2rst »

Thanks Joulinar,

i gave your given command & it shows me /TMP folder. also just for information. in my machine there is 4GB ram & system itself allot maximum size for this to 2GB. so i think everything according to my wishes. thanks
Post Reply