nebhead / plexpostproc Goto Github PK
View Code? Open in Web Editor NEWPlex PostProcessing Script for DVR(Beta)
Plex PostProcessing Script for DVR(Beta)
Great script, thank you. It seems that the filename contains the same extension, even after conversion. So I end up with a .ts file even after creating an .mkv file. Is this intentional?
Also, I'm having some permissions issues, is there a way to make sure the script runs as super-user?
Hi ,
i use plex on unraid with a docker and i need to reinstall handbrake in the plex docker each time the plex as a new version has install.
My question 1 : how i can fix this ?
My question 2: I can use the handbraker docker in unraid ?
your script is magic but i need to install handbrake in the plex docker with the terminal ..
thx
Just updated to the new sript and at first I was getting error 1, then it would run constantly, now i'm getting a failed to move error.
"Finished transcode,ERROR # 1 : Failed to move converted file: /tmp/tmp.zzWHyMdI08.mkv"
Made sure it was CHMOD +x, 777 and owned by plex:plex
I must have missed something simple...
Ubuntu 18.04
I was having issues with five or more HandBrakeCLI processes getting kicked off and bogging my system down, or also encodes getting lost in a reboot. I've added a queue system that you might want to check out. I also thought adding an encode log would be nice.
I've thrown together the following shell scripts and call encodequeue.sh with a cron job (*/30 * * * *
home/[user]/PlexPostProc/encodequeue.sh). The execdir variable will need to be changed in the shell scripts. Call enqueue.sh from Plex.
enqueue.sh
#!/bin/sh
execdir="/home/[user]/PlexPostProc"
if [ ! -z "$1" ]; then
echo "$execdir"/PlexPostProc.sh $1>>"$execdir"/queue.txt
else
echo "Usage: $0 FileName"
fi
encodequeue.sh
#!/bin/sh
execdir="/home/[user]/PlexPostProc"
#
timestamp=$(date "+%Y%m%d-%H%M%S")
if pgrep -x "HandBrakeCLI" > /dev/null
then
echo "HanBrakeCLI is already working"
else
echo "HanBrakeCLI stopped, let's do some work?"
# run first line of queue
encodejob=$(head -n 1 "$execdir/queue.txt")
if [ -n "$encodejob" ]; then
echo "$timestamp: $encodejob" >> "$execdir/encode.log"
echo "Running: $encodejob"
$encodejob
# remove line from queue
sed '1d' "$execdir/queue.txt" > "$execdir/tmpfile"; mv "$execdir/tmpfile" "$execdir/queue.txt"
fi
fi
Hello, can you please provide instructions on how to install ffmpeg inside a plex docker container? I haven't been able to figure this out on my own. Thanks in advance.
Does your post processing script allow for usage of intel quicksync?
If I follow the instructions as written, will this script execute on a windows 10 machine?
Not sure if you noticed this, but just wanted to point it out. https://forums.plex.tv/t/plex-media-server/30447/340
You think about possibly adding Comskip to this script, so it removes the commercials first than transcodes the file? That would be great. I'm still testing this out at the moment.
Thanks, keep up good work.
i'm missing something dumb here. When Plex runs the script it fails, when I run the script as my login user I get a permission denied on cleanup.
the containing folder of the .ts file is set to plex:plex and I added my login user to the plex group and still permission denied.
any help is much appreciated!
Script works (however I heavily customized ffmpeg string for my own needs, such as downconverting to stereo, AAC 112kbps and lowering framerate from 60 to 24 in order to save space).
However looking at the workaround function, mine was stuck in forever waiting loop waiting for .ppplock files to go away. I dont know how or why I had some in the directory (there was zero activity on Plex) but script only finished when I manually deleted them via ssh.
I modified this block in 2 ways:
# [WORKAROUND] Wait for any other post-processing scripts to complete before exiting.
timeout_counter=120
while [ true ] ; do
if ls "$TMPFOLDER/"*".ppplock" 1> /dev/null 2>&1; then
if [[ $timeout_counter -eq 0 ]]; then
echo "Timeout reached, ending wait" | tee -a $LOGFILE
break
fi
echo "$(date +"%Y%m%d-%H%M%S"): Looks like there is another scripting running. Waiting." | tee -a $LOGFILE
timeout_counter=$((timeout_counter-1))
sleep 60
else
echo "$(date +"%Y%m%d-%H%M%S"): It looks like all scripts are done running, exiting." | tee -a $LOGFILE
break
fi
done
Hi
I noticed that the script was actually writing the new file out as mkv rather than mp4 so checking the script I see that the below line:
mv -f "$TEMPFILENAME" "${FILENAME%.ts}.mkv" # Move completed temp to original filename
should be
mv -f "$TEMPFILENAME" "${FILENAME%.ts}.mp4" # Move completed temp to original filename
I'd love to be able to keep subtitles in my file after processing but I'm not sure how to keep them in. Any of the options I've found online for both handbrake and ffmpeg have both either caused it to not output a file or didn't output the file with subs. Any ideas?
i don't care about resolution for my dvr recordings - i just want them crushed down as much as possible - if i set res to 480 will that break the script?
i'm tinkering and trying to see if i can get it working - but currently am unable to test because my nvidia quadro is sitting on the shelf and won't be delivered until my buddy travels across contry - figured it would make life much easier when using h265 as your encoding choice
thought i might reach out to see if you are already looking at using hwaccel - but im a wicked ffmpeg novice and since i don't have a test bed yet ....
I'm having a weird issue where my DVR recordings are not complete. Each recording is missing chunks within the episode it records. The beginning and end are intact but there are plays where the video seems to skip several minutes of the show (almost as if ComSkip were running on the video and doing a terrible job - except I'm not using ComSkip). Can I set this script to NOT erase the original so that I can check where in the process the breakdown is happening?
I'm using the FFMPEG branch and the post processing script fails. Exits with an error code 127 and just copies the unconverted file into my library. Has anyone seen this before and know of a solution?
Nov 21, 2017 08:00:58.706 [0x70000c283000] DEBUG - Job running: '/Users/colinsteele/PlexPostProc/PlexPostProc.sh' '/Volumes/Plex/Plex/Videos/TV Shows/.grab/88ecb30f6e0a3c720622d9c92a6a8fb936094309/Parking Wars (2008) - S06E07 - Episode 7.ts'
Nov 21, 2017 08:00:58.718 [0x70000c283000] DEBUG - Jobs: '/Users/colinsteele/PlexPostProc/PlexPostProc.sh' exit code for process 62152 is 127
Nov 21, 2017 08:00:58.718 [0x70000c283000] ERROR - DVR:Recorder: Postprocessing script '/Users/colinsteele/PlexPostProc/PlexPostProc.sh' exited with error code 127.
Nov 21, 2017 08:00:58.722 [0x70000ccbf000] DEBUG - DVR:Grabber: Postprocessing, we're going to put `Parking Wars - E7 - Episode 7` in `/Volumes/Plex/Plex/Videos/TV Shows/Parking Wars (2008)/Season 06/Parking Wars (2008) - S06E07 - Episode 7.ts`
Nov 21, 2017 08:00:59.458 [0x70000ccbf000] DEBUG - DVR:Grabber: Operation for Parking Wars - E7 - Episode 7 completed with status error (An error occurred while postprocessing the recording)
Nov 21, 2017 10:32:07.957 [0x70000c71e000] DEBUG - Request: [127.0.0.1:55249 (Loopback)] PUT /livetv/dvrs/13/prefs?startOffsetMinutes=0&endOffsetMinutes=0&useUmp=false&postprocessingScript=%2FUsers%2Fcolinsteele%2FPlexPostProc%2FPlexPostProc.sh&increasedRefreshes=false (11 live) GZIP Signed-in Token (Man0f5tee1e)
Nov 21, 2017 10:32:07.979 [0x70000b63b000] DEBUG - Completed: [127.0.0.1:55249] 200 PUT /livetv/dvrs/13/prefs?startOffsetMinutes=0&endOffsetMinutes=0&useUmp=false&postprocessingScript=%2FUsers%2Fcolinsteele%2FPlexPostProc%2FPlexPostProc.sh&increasedRefreshes=false (11 live) GZIP 21ms 3066 bytes (pipelined: 1)
I just started using this script today.
I've noticed that it's converting my MPEG2 OTA recordings from 60fps down to 24. I'm guessing that's not the intended behavior?
Hi,
I am using Debian 10 / Not using Docker so directory install Plex Media Server version Version 1.20.1.3252
I am getting this error when I try and use this file.
20210802-220206: Starting transcode of /media/nas/TV/TV/.grab/7b923c65a4363383d3a2d730606ff161462de4d6-4488fda215b35da7d4567b111aaa1b37ed1039b1/T$
You have selected HandBrake
ERROR # 127 : Failed to convert using Handbrake.
What am I doing wrong here?
Thank you
Hi, I just forked the repo after finding this and am going to try to make some contributions.
What license is this software under? I would assume anything will do. GPL, MIT, Unlicense, CC. perhaps even the WTFPL?
I am using your script as it comes and it is working fine, with the exception that the .ts extension remains after it is converted to .mkv.
I'm having an issue with Plex and this script (the ffmpeg one). When I try and record 1 DVR channel this works. When I try to simultaneously record 2 different DVR channels, the second recorded episode folder has no file. Plex gives an error saying silly script deleted the file.
I can see that both files are being written to by Plex in the .grab folder, and then when the first file is converted and written it seems to kill off the second ffmpeg as the .grab file for the second recording just disappears.
I just switched to using the flatpak Handbrake so I could keep the subtitles and moved my Plex libraries to /Plex/TV Shows (or movies or music etc.). However, when I'm trying to use this script, I keep getting the error, "ERROR # 1 : Failed to move converted file: /tmp/tmp.lCUfgU3rAd.mkv" and plex says that it couldn't move the recorded media to the destination. The Handbrake log shows the file as completing its encoding, so it seems like it's an issue with the script moving the file back. Plex has ownership and I chmod 777 all the folders its working in, so it seems like it's not a permissions issue, not sure what could be the problem.
So I have got the script figured out the point where if i run it manually and put the location and filename of the file after the PlexPostProc.sh it will convert it without issues. If I put the location of the script in my Plex PostProcessing settings for the DVR (including the full Linux path and filename which has been chmod 777) it will error code 1 every time. When I look at the plex log it just seems like the filename is not being passed from plex to the script so how is that supposed to be done? I have googled until my eyes are bleeding for Plex Post Processing switches, parameters, etc and find nothing.
I don't know much about Handbrake, but I am trying to tweak your .sh to work for Windows using a VERY simple .bat.
Looking at the Handbrake parameters, will it pass thru the subtitles (aka - Closed Captioning) that PlexDVR/HDHomeRun put into the .ts?
Nice little script but it doesn't work for me. It never ends. The log just says Looks like there is another scripting running. Waiting,,,,,, and it never ends. this happens when it is just a single encode...no multiple streams going.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.