So, Now that I’ve got Plex DVR setup, I want to be able to use Handbrake and to some conversion and compression afterwards. However, all I seem to be finding online is other people sharing their scripts… but I want to learn more about what is available for the post processing?
Are there any documents that explain how it’s best used? I’ll still learning Bash so trying to read through scripts made by others doesn’t help me as much as I’d like it to.
Not sure I understand question 1. The script would run against the recorded file in the .grab folder.
Handbrake would be passed the -i “$1” parameter that was passed into the script. When Plex calls your post processing script it calls it with something along the lines of:
myscript.bat “G:\TV_DVR.grab\512ef5d6e621ad05b721bb88547c20a6b7ad4e68Law & Order Special Victims Unit (1999) - S06E07 - Charisma.ts”
where myscript.bat is my post processing script that is executed and “G:\TV_DVR.grab\512ef5d6e621ad05b721bb88547c20a6b7ad4e68Law & Order Special Victims Unit (1999) - S06E07 - Charisma.ts” is the file to be processed.
I am not sure how Plex handles if you change the extension of the file for example from the ts to a mkv. I believe other just have their post processing drop the newly converted file in the .grab folder the recording was made in and believe Plex moves it.
I personally use mcebuddy since it is available for Windows. I have mcebuddy moving the files to the appropriate drive and folders in my library and deletes the original ts file.
The script runs in whatever directory you have placed it.
DVR Post processing simply calls your script and passes it a single variable of the full path and filename of the recorded video in the .grab processing folder. That variable (file name) can be referenced in your script with standard input variable names:
Windows: %1
Linux/Unix/Android/Apple: $1
So anywhere in your script where you need to refer to the full path and filename you can use the standard variable. You can also use standard modifiers to refer to pieces of the drive/path/filename with or without the extension:
Windows:
%~d1 = drive only
%~p1 = path only
%~n1 = filename only without path or extension
In Windows %1 should not be in quotes, but you’ll need to quote any partial reference as the path/filename will have spaces in it.
You should do any processing in a temp folder/directory. The easiest way is to put the output of all operations on the %1/$1 source file (and subsequent input/output files) in that temp directory.
When you’ve finished processing, copy your new file back to the original path/name. You do that with a copy or rename/move command with the final path/filename construct:
forgive me if I’m being thick, but is this line something I can paste directly into the post processing field or is this what should be in a bat file? And should that bat be in the .grab folder?
forgive me if I’m being thick, but is this line something I can paste directly into the post processing field or is this what should be in a bat file? And should that bat be in the .grab folder?
Thanks for sharing what you know here!
This would be in the bat file you fill in path to call from the post-process part of plex dvr’s menu
Thank. I’ve been trying to use some sample scripts I found after asking this but not sure about the paths. I’m trying to use the external drive for everything (including temp) but not sure if Plex is.
@aLanManT
In Linux if I’m wanting to change the file extension from .ts to .mkv at the end of the post processing script I have. How would i go about doing that? I’m a bit confused on this part
my current variables are:
set origFile = “$1”
set tmpFile = “$1.tmp”
set tmpEncode = “$1.mkv”
set tmpSrt = “$1.srt”
@ShottotheDome said: @aLanManT
In Linux if I’m wanting to change the file extension from .ts to .mkv at the end of the post processing script I have. How would i go about doing that? I’m a bit confused on this part
You cant. The postprocessing script is run on the file before it is copied into your your library. Once the postprocessing script is done the file with the original name is copied from the TMP location and into the library destination folder. Any other files in that folder are deleted alont with the TMP folder.
Actually, in Windows I do exactly that by deleting/archiving the original .ts from the grab/TMP location and replacing it with the exact same filename with an .mkv extension. When post processing is completed, Plex moves the .mkv into the TV library folder.
For those who find this and are curious or whatever, here’s a link to the script that I ended up creating. It’s a modification of a few scripts I found and simply learning Bash