kluge9 wrote: ↑
Thu Feb 21, 2019 7:48 am
jman311 wrote: ↑
Thu Jan 31, 2019 7:01 am
- Plex Media Server, using an HDHomeRun w/PlexPass DVR (to replace my Tivo)
- Handbrake CLI in Docker for encoding Plex recordings to MKV in DVR post-processing
Question, jman. Any advice you have on setting this up? I'm learning my way through some Linux (I'm GUI-spoiled) as these 2GB DVR files are unnecessary with PlexDVR.
So it sounds like you already have Plex DVR set up. I realized I misspoke, am currently using the QPKG version of the HandBrake_CLI (I am using the version 1.1.2, found here: https://www.qnapclub.eu/en/qpkg/320
). There is also a docker option for Handbrake I referred to, I originally started down that path and will probably go back to it when I have some time, but I am not using it currently.
I pieced together how to set this up mostly from posts on this and the Plex site, and combined them with my own notes during install. I originally tried to create my script file in Windows and copy it over to the NAS, that caused all sorts of formatting issues, so I found it much better to install and use the QNAP Text Editor app. I am learning Linux as well!
Create a script called plex_pp.sh using UTF-8 (without BOM) encoding in Text Editor on the QNAP interface directly.
Save the file here: /share/Config/Plex/Scripts/plex_pp.sh
Navigate to the location and set file permissions on the script:
Then right-click the file in QNAP File Manager, and enable Execute permissions. File should now appear with an asterick at the end when viewed with ls command (e.g. plex_pp.sh*).
Here is the script. Adjust for any path variations and encoder preset options, if necessary:
Code: Select all
time=`date '+%Y-%m-%d %H:%M:%S'`
echo "'$time' Plex DVR Postprocessing script started" | tee $dvrPostLog
# Check if post processing is already running
while [ -f $lockFile ]
echo "'$time' $lockFile' exists, sleeping processing of '$inFile'" | tee -a $dvrPostLog
# Create lock file to prevent other post-processing from running simultaneously
echo "'$time' Creating lock file for processing '$inFile'" | tee -a $dvrPostLog
# Encode file to MKV with HandBrakeCLI
echo "'$time' Transcoding file '$inFile' to new file '$outFile'" | tee -a $dvrPostLog
$handbrake -i "$inFile" -o "$outFile" --preset="HQ 1080p30 Surround"
# Remove original .ts. file
echo "'$time' Removing original file '$inFile'" | tee -a $dvrPostLog
rm -f "$inFile"
#Remove lock file
echo "'$time' Complete! Removing lock for '$inFile'" | tee -a $dvrPostLog
Finally, set the Post-Processing Script path in Plex under the DVR & List TV settings (/share/Config/Plex/Scripts/plex_pp.sh)
Once a recording is complete, the script should kickoff and create an MKV version of the file, and delete the original. Then Plex will then move the folder to the Plex DVR library. While the script is running, you'll see that the recording sits at a 100% complete status until the encoding is done.
Hope this helps!