Plex Remote Transcoder - A distributed transcoding backend for Plex

@boboki said:
I am in no way at all concerned with the internal ips, this is a quick sandbox environment that once I get functional I will then rebuild in my production. All IPs, data, servernames, etc will all change after I go prod.

Here is the feedback from bash after running the export which did require me to run it in quotes

Are you sure that the FS mount is working correctly? Can you see the file /mnt/Media/Requests/Movies - Requests/...?

Yup, verified I can see those files without issue. I tried again with an cleaner path:

 "export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application Support;export PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000;export XDG_CACHE_HOME=/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Cache/;export OLDPWD=/;export PLEX_MEDIA_SERVER_USER=plex;export TERM=linux;export X_PLEX_TOKEN=;export PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver;export UPSTART_INSTANCE=;export PWD=/usr/lib/plexmediaserver;export FFMPEG_EXTERNAL_LIBS=/var/lib/plexmediaserver/Library/Application\\ Support/Plex\\ Media\\ Server/Codecs/ecd8c57-1099-linux-ubuntu-x86_64/;export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin;export UPSTART_JOB=plexmediaserver;export HOME=/var/lib/plexmediaserver;export XDG_DATA_HOME=/usr/lib/plexmediaserver/Resources/;export PLEX_MEDIA_SERVER_TMPDIR=/tmp;export LD_LIBRARY_PATH=/usr/lib/plexmediaserver;export TMPDIR=/tmp;export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6;export PRT_ID=324990b6501e11e69ccc005056bf0d20;cd /opt/plex/tmp/plex-transcode-hqec4m509boujvx9dwnj0pb9-9fadc56b-75a0-42d6-8f67-144c6242cd80;prt_local -codec:0 h264 -i /mnt/Media/Temp/Plextest/Big.mkv -map_inlineass 0:2 -filter_complex '[0:0]scale=w=min(1280\\,iw):h=min(688\\,ih):force_original_aspect_ratio=decrease,inlineass=font_scale=1.000000:font_path=/usr/lib/plexmediaserver/Resources/Fonts/DejaVuSans-Regular.ttf:fontconfig_file=/usr/lib/plexmediaserver/Resources/fonts.conf[0]' -map '[0]' -codec:0 libx264 -crf:0 19 -pix_fmt:0 yuv420p -maxrate:0 1207k -bufsize:0 2414k -r:0 23.975999999999999 -preset:0 veryfast -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -map 0:1 -codec:1 copy -copypriorss:1 0 -f matroska -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 - -map 0:2 -f null -codec copy nullfile -start_at_zero -copyts -y -nostats -loglevel quiet -loglevel_plex error -progressurl http://:32400/video/:/transcode/session/hqec4m509boujvx9dwnj0pb9/progress"
bash: export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application Support;export PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000;export XDG_CACHE_HOME=/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Cache/;export OLDPWD=/;export PLEX_MEDIA_SERVER_USER=plex;export TERM=linux;export X_PLEX_TOKEN=;export PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver;export UPSTART_INSTANCE=;export PWD=/usr/lib/plexmediaserver;export FFMPEG_EXTERNAL_LIBS=/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Codecs/ecd8c57-1099-linux-ubuntu-x86_64/;export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin;export UPSTART_JOB=plexmediaserver;export HOME=/var/lib/plexmediaserver;export XDG_DATA_HOME=/usr/lib/plexmediaserver/Resources/;export PLEX_MEDIA_SERVER_TMPDIR=/tmp;export LD_LIBRARY_PATH=/usr/lib/plexmediaserver;export TMPDIR=/tmp;export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6;export PRT_ID=324990b6501e11e69ccc005056bf0d20;cd /opt/plex/tmp/plex-transcode-hqec4m509boujvx9dwnj0pb9-9fadc56b-75a0-42d6-8f67-144c6242cd80;prt_local -codec:0 h264 -i /mnt/Media/Temp/Plextest/Big.mkv -map_inlineass 0:2 -filter_complex '[0:0]scale=w=min(1280\,iw):h=min(688\,ih):force_original_aspect_ratio=decrease,inlineass=font_scale=1.000000:font_path=/usr/lib/plexmediaserver/Resources/Fonts/DejaVuSans-Regular.ttf:fontconfig_file=/usr/lib/plexmediaserver/Resources/fonts.conf[0]' -map '[0]' -codec:0 libx264 -crf:0 19 -pix_fmt:0 yuv420p -maxrate:0 1207k -bufsize:0 2414k -r:0 23.975999999999999 -preset:0 veryfast -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -map 0:1 -codec:1 copy -copypriorss:1 0 -f matroska -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 - -map 0:2 -f null -codec copy nullfile -start_at_zero -copyts -y -nostats -loglevel quiet -loglevel_plex error -progressurl http://:32400/video/:/transcode/session/hqec4m509boujvx9dwnj0pb9/progress: No such file or directory

You can see it got the same error, but if I just do a simple copy of that file from both server and transcode server both of them have no issues copying the file.

 cp -v /mnt/Media/Temp/Plextest/Big.mkv /tmp/
â/mnt/Media/Temp/Plextest/Big.mkvâ -> â/tmp/Big.mkvâ

I also verified the permissions are set to 777 on those files. I copied a movie into the /tmp file on both servers, added a Library pointing to it, then tried to play it. Copied the manual export command and ran it on the transcoder as well, and got same error message of no such file or directory.

How about /opt/plex/tmp? The error means that some file/directory is not available on the transcode host. Go through the command and test for every file and directory.

Hey,

I’m getting a 401 error when using prt sessions. Aside from that this script is amazing. Any pointers? Network discovery is enabled and login without auth is set for my ip range.

@LightSpeedTaco said:
Hey,

I’m getting a 401 error when using prt sessions. Aside from that this script is amazing. Any pointers? Network discovery is enabled and login without auth is set for my ip range.

What exactly is the error you’re seeing?

drwxr-xrwx 4 plex plex 4096 Jul 17 15:05 plexmediaserver - /var/lib/plexmediaserver
drwxr-xr-x 3 plex plex 12288 Jul 21 13:34 plexmediaserver - /usr/lib/plexmediaserver
drwxr-xr-x 2 plex plex 4096 Jul 22 11:17 tmp - /opt/plex/tmp
drwxrwxrwx 3 plex plex 4096 Jul 17 14:24 Library - /var/lib/plexmediaserver/Library
drwxr-xr-x 9 plex plex 12288 Jul 21 13:44 Resources - /usr/lib/plexmediaserver/Resources
drwxrwxrwx 2 plex plex 4096 Jul 17 15:04 ecd8c57-1099-linux-ubuntu-x86_64 - /var~~~~/Codecs

Only one that seems off, connection wise, is PLEX_MEDIA_SERVER_TMPDIR=/tmp but I did verify the transcoder temp path in the PMS is set to /opt/plex/tmp via the web console.

^^ are all the dir listings from the transcode box logged in as plex user

Attached an image of the putty session post command run.

@LightSpeedTaco said:

Attached an image of the putty session post command run.

Ahh, it can’t connect to PMS. You need to make sure that 127.0.0.1 is allowed to connect without authentication. You can do this in the server settings for PMS.

I’ve removed the PIN on my account and added 127.0.0.1/255.255.255.255 to the access without auth then restarted my mediaserver but the issue persists. Any ideas? It’s probably just something dumb on my end.

@LightSpeedTaco said:
I’ve removed the PIN on my account and added 127.0.0.1/255.255.255.255 to the access without auth then restarted my mediaserver but the issue persists. Any ideas? It’s probably just something dumb on my end.

Can you curl to it?

curl http://localhost:32400/status/sessions

@LightSpeedTaco said:
I’ve removed the PIN on my account and added 127.0.0.1/255.255.255.255 to the access without auth then restarted my mediaserver but the issue persists. Any ideas? It’s probably just something dumb on my end.

OK, seems like this is an issue. I’ll update the code to use a Plex token.

@LightSpeedTaco said:
I’ve removed the PIN on my account and added 127.0.0.1/255.255.255.255 to the access without auth then restarted my mediaserver but the issue persists. Any ideas? It’s probably just something dumb on my end.

Try checking out the latest commit. It’ll prompt you for you Plex username and password so that it can get an auth token.

@wnielson said:

@LightSpeedTaco said:
I’ve removed the PIN on my account and added 127.0.0.1/255.255.255.255 to the access without auth then restarted my mediaserver but the issue persists. Any ideas? It’s probably just something dumb on my end.

Try checking out the latest commit. It’ll prompt you for you Plex username and password so that it can get an auth token.

It works like a charm! Thanks for your continued hard work and support. Enjoy the 20 dollar donation :slight_smile:

Paul

@LightSpeedTaco said:
It works like a charm! Thanks for your continued hard work and support. Enjoy the 20 dollar donation :slight_smile:

Paul

Glad it works. Cheers!

@boboki said:
drwxr-xrwx 4 plex plex 4096 Jul 17 15:05 plexmediaserver - /var/lib/plexmediaserver
drwxr-xr-x 3 plex plex 12288 Jul 21 13:34 plexmediaserver - /usr/lib/plexmediaserver
drwxr-xr-x 2 plex plex 4096 Jul 22 11:17 tmp - /opt/plex/tmp
drwxrwxrwx 3 plex plex 4096 Jul 17 14:24 Library - /var/lib/plexmediaserver/Library
drwxr-xr-x 9 plex plex 12288 Jul 21 13:44 Resources - /usr/lib/plexmediaserver/Resources
drwxrwxrwx 2 plex plex 4096 Jul 17 15:04 ecd8c57-1099-linux-ubuntu-x86_64 - /var~~~~/Codecs

Only one that seems off, connection wise, is PLEX_MEDIA_SERVER_TMPDIR=/tmp but I did verify the transcoder temp path in the PMS is set to /opt/plex/tmp via the web console.

^^ are all the dir listings from the transcode box logged in as plex user

So, well spotted on that PLEX_MEDIA_SERVER_TMPDIR , that’s from he PMS people being horrific with their approach to setup in PMS n Linux. There’s actually 3 seperate areas they use for encoding and the one in the web interface ONLY applies to live stream transcoding. That one you’ve spotted there is for syncing & audio fingerprinting. The PMS coders are very sloppy with their variables n not very friendly with their coding for third parties. I’ve changed that variable to the same as the stream transcoder area /opt/plex/tmp.

That however won’t solve your issue as you’ve overlooked what the issue actually is. I can’t copy n paste on my phone for some reason but look at your output, the last few lines when it’s talking about your transcode session progress url… You’ll see there’s something amiss with it…it has the port & path but no IP address. It’s a web link, they don’t work without a server address i.e. An IP address. Have a look at mine here -

"ā€˜-progressurl’, ā€˜http://172.16.1.81:32400/video/:/transcode/session/srjwx16nkp9u015gghyvf5hfr/progress’ "

@boboki said:
Yup, verified I can see those files without issue. I tried again with an cleaner path:

Try running that command again but change:

-loglevel quiet -loglevel_plex error

to:

-loglevel verbose -loglevel_plex verbose

Tried the log levels and the error message remains not changed and still no prt.log exists on the transcode box. I tried changing all the paths I could find to the correct ā€œlinux listedā€ way shown below:

"export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application\\ Support;export PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000;export XDG_CACHE_HOME='/var/lib/plexmediaserver/Library/Application\\ Support/Plex\\ Media\\ Server/Cache/';export OLDPWD=/;export PLEX_MEDIA_SERVER_USER=plex;export TERM=linux;export X_PLEX_TOKEN=;export PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver;export UPSTART_INSTANCE=;export PWD=/usr/lib/plexmediaserver;export FFMPEG_EXTERNAL_LIBS=/var/lib/plexmediaserver/Library/Application\\ Support/Plex\\ Media\\ Server/Codecs/ecd8c57-1099-linux-ubuntu-x86_64/;export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin;export UPSTART_JOB=plexmediaserver;export HOME=/var/lib/plexmediaserver;export XDG_DATA_HOME=/usr/lib/plexmediaserver/Resources/;export PLEX_MEDIA_SERVER_TMPDIR=/tmp;export LD_LIBRARY_PATH=/usr/lib/plexmediaserver;export TMPDIR=/tmp;export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6;export PRT_ID=6c0e9bb0501f11e68c39005056bf0d20;cd /opt/plex/tmp/plex-transcode-1a6brfrrhxcyshismunmi-d0471c84-59a9-437a-ba80-c50ba7b73b3e;prt_local -codec:0 h264 -i /tmp/Big.mkv -map_inlineass 0:2 -filter_complex '[0:0]scale=w=min(1280\\,iw):h=min(688\\,ih):force_original_aspect_ratio=decrease,inlineass=font_scale=1.000000:font_path=/usr/lib/plexmediaserver/Resources/Fonts/DejaVuSans-Regular.ttf:fontconfig_file=/usr/lib/plexmediaserver/Resources/fonts.conf[0]' -map '[0]' -codec:0 libx264 -crf:0 19 -pix_fmt:0 yuv420p -maxrate:0 1207k -bufsize:0 2414k -r:0 23.975999999999999 -preset:0 veryfast -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -map 0:1 -codec:1 copy -copypriorss:1 0 -f matroska -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 - -map 0:2 -f null -codec copy nullfile -start_at_zero -copyts -y -nostats -loglevel verbose -loglevel_plex verbose -progressurl http://:32400/video/:/transcode/session/1a6brfrrhxcyshismunmi/progress"

No change in that either, still same no such dir error. I also tried to replace the /tmp lines with /opt/plex/tmp and also tried to add a ip addrerss to the bottom http progress url, no change in error.

@boboki said:>
No change in that either, still same no such dir error. I also tried to replace the /tmp lines with /opt/plex/tmp and also tried to add a ip addrerss to the bottom http progress url, no change in error.

You shouldn’t wrap the whole command in double quotes–that’s why you are seeing the No such file or directory error. Copy and paste this exactly (make sure you are running this at the plex user):

export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/var/lib/plexmediaserver/Library/Application Support";export PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000;export XDG_CACHE_HOME="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Cache/";export OLDPWD=/;export PLEX_MEDIA_SERVER_USER=plex;export TERM=linux;export X_PLEX_TOKEN=xxxx;export PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver;export UPSTART_INSTANCE=;export PWD=/usr/lib/plexmediaserver;export FFMPEG_EXTERNAL_LIBS="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Codecs/ecd8c57-1099-linux-ubuntu-x86_64/";export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin;export UPSTART_JOB=plexmediaserver;export HOME=/var/lib/plexmediaserver;export XDG_DATA_HOME=/usr/lib/plexmediaserver/Resources/;export PLEX_MEDIA_SERVER_TMPDIR=/tmp;export LD_LIBRARY_PATH=/usr/lib/plexmediaserver;export TMPDIR=/tmp;export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6;export PRT_ID=784b7f224f9011e6bb7d005056bf0d20;cd /opt/plex/tmp/plex-transcode-7gu53i3tffsdfy8iwqpuys0pb9-5d048cba-9034-4c14-8890-2ce95d9f902e;prt_local -codec:0 h264 -codec:1 ac3 -i '/mnt/Media/Requests/Movies - Requests/Brotherhood.Of.The.Wolf.2001.1080p.BluRay.x264-FLHD/Brotherhood of the Wolf.mkv' -map_inlineass 0:2 -filter_complex '[0:0]scale=w=min(1280\\,iw):h=min(550\\,ih):force_original_aspect_ratio=decrease,inlineass=font_scale=1.000000:font_path=/usr/lib/plexmediaserver/Resources/Fonts/DejaVuSans-Regular.ttf:fontconfig_file=/usr/lib/plexmediaserver/Resources/fonts.conf[0]' -map '[0]' -metadata:s:0 language=fre -codec:0 libx264 -crf:0 19 -pix_fmt:0 yuv420p -maxrate:0 2000k -bufsize:0 4000k -r:0 23.975999999999999 -preset:0 veryfast -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -map 0:1 -metadata:s:1 language=fre -codec:1 aac -ar:1 48000 -channel_layout:1 5.1 -b:1 579k -f matroska -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 - -map 0:2 -f null -codec copy nullfile -start_at_zero -copyts -y -nostats -loglevel verbose -loglevel_plex verbose -progressurl http://:32400/video/:/transcode/session/7gu53i3tffsdfy8iwqpuys0pb9/progress

Oh, and you should probably remove the X_PLEX_TOKEN value in your previous posts.

Went back and edited those out. Ok, so I did it without quotes and here are the errors that came up:

bash: export: `Support/Plex': not a valid identifier
bash: export: `Server/Cache/': not a valid identifier
bash: export: `Support/Plex\': not a valid identifier
bash: export: `Media\': not a valid identifier
bash: export: `Server/Codecs/ecd8c57-1099-linux-ubuntu-x86_64/': not a valid identifier
bash: cd: /opt/plex/tmp/plex-transcode-upsxxkkpwek9yh64ku0xxn7b9-954b5213-ac90-4994-bf66-a7b4622a0d9c: No such file or directory
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

@boboki said:
Went back and edited those out. Ok, so I did it without quotes and here are the errors that came up:

bash: export: `Support/Plex': not a valid identifier
bash: export: `Server/Cache/': not a valid identifier
bash: export: `Support/Plex\': not a valid identifier
bash: export: `Media\': not a valid identifier
bash: export: `Server/Codecs/ecd8c57-1099-linux-ubuntu-x86_64/': not a valid identifier
bash: cd: /opt/plex/tmp/plex-transcode-upsxxkkpwek9yh64ku0xxn7b9-954b5213-ac90-4994-bf66-a7b4622a0d9c: No such file or directory
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

Alright, somethings are messed up here. First off, because the transcode session is no longer active the temporary folder used for the transcode is missing. First, let’s create it:

mkdir -p /opt/plex/tmp/plex-transcode-7gu53i3tffsdfy8iwqpuys0pb9-5d048cba-9034-4c14-8890-2ce95d9f902e

The first 5 errors you are seeing, bash: export: ... not a valid identifier, means that the string is not being quoted properly. Make sure that this is being copied and pasted correctly:

export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/var/lib/plexmediaserver/Library/Application Support"
export PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000
export XDG_CACHE_HOME="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Cache/"
export OLDPWD=/
export PLEX_MEDIA_SERVER_USER=plex
export TERM=linux
export X_PLEX_TOKEN=xxxx
export PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver
export UPSTART_INSTANCE=
export PWD=/usr/lib/plexmediaserver
export FFMPEG_EXTERNAL_LIBS="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Codecs/ecd8c57-1099-linux-ubuntu-x86_64/"
export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
export UPSTART_JOB=plexmediaserver
export HOME=/var/lib/plexmediaserver
export XDG_DATA_HOME=/usr/lib/plexmediaserver/Resources/
export PLEX_MEDIA_SERVER_TMPDIR=/tmp
export LD_LIBRARY_PATH=/usr/lib/plexmediaserver
export TMPDIR=/tmp
export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
export PRT_ID=784b7f224f9011e6bb7d005056bf0d20

cd /opt/plex/tmp/plex-transcode-7gu53i3tffsdfy8iwqpuys0pb9-5d048cba-9034-4c14-8890-2ce95d9f902e

prt_local -codec:0 h264 -codec:1 ac3 -i '/mnt/Media/Requests/Movies - Requests/Brotherhood.Of.The.Wolf.2001.1080p.BluRay.x264-FLHD/Brotherhood of the Wolf.mkv' -map_inlineass 0:2 -filter_complex '[0:0]scale=w=min(1280\\,iw):h=min(550\\,ih):force_original_aspect_ratio=decrease,inlineass=font_scale=1.000000:font_path=/usr/lib/plexmediaserver/Resources/Fonts/DejaVuSans-Regular.ttf:fontconfig_file=/usr/lib/plexmediaserver/Resources/fonts.conf[0]' -map '[0]' -metadata:s:0 language=fre -codec:0 libx264 -crf:0 19 -pix_fmt:0 yuv420p -maxrate:0 2000k -bufsize:0 4000k -r:0 23.975999999999999 -preset:0 veryfast -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none -map 0:1 -metadata:s:1 language=fre -codec:1 aac -ar:1 48000 -channel_layout:1 5.1 -b:1 579k -f matroska -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 - -map 0:2 -f null -codec copy nullfile -start_at_zero -copyts -y -nostats -loglevel verbose -loglevel_plex verbose -progressurl http://:32400/video/:/transcode/session/7gu53i3tffsdfy8iwqpuys0pb9/progress