Post Processing on Windows Help

When setting the post processing script in the DVR settings for windows, I am setting the full path to my .bat file that works great by itself.

My question is how does the .bat file know the file and location of the DVR’d .ts file? I currently looking for the first parameter sent in which works great like (c: emp\plex.bat “e:\videos est.ts”). This runs great from the command line with any file sent in.

Thanks

I assume Plex just passes it as a parameter to the bat.

I wondered the same thing but didn’t dig into it

Yes, Plex passes the recorded file as a parameter to the script.

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.

1 Like

I have a follow up question to the windows post processing. Does the script/bat file need to decide where to place the new file after the post processing has been completed or does it put it back in the .grab folder for plex to move it to the correct tv show directory?

Example: DVR records to .grab, post processing works on .ts file and converts to .mp4, puts mp4 file back in .grab folder for plex to copy and paste to Show/season 1 folder and deletes the old .ts file

OR

Example: DVR records to .grab, post processing works on .ts file and converts to .mp4, script/bat has to figure out where to put mp4 (Show/season 1) and outputs the converted file there, goes back and deletes .ts file from .grab folder.

There doesn’t seem to be a lot of documentation on the workflow post-processing.

Thanks!

You should be able to place the converted file back in the grab folder, remove the recorded file and Plex will should move the converted file to the correct location in your library.

Quick question. I’ve set up a post processing script on windows:

D:\Media\PlexCache\Tools\handbrakecli.exe -i %1 -o "%~d1%~p1%~n1.mp4" --preset="Very Fast 720p30" -O
mv %1 D:\Media\PlexCache\Archive

The script works fine for the transcode but not the move. After the script finishes, I see both the original captured .ts file and my newly created .mp4 file in the recordings directory library. Can you tell me why the file did not get moved?

Also can you tell me if Plex will remove the commercials before it runs the post processing script if set to remove commercials for DVR?

EDIT Wow! I spend too much time using linux. Command should be ‘move’ not ‘mv’ … I’ll leave this here just in case others might want to use this simple script

1 Like

Hi guys-- was trying to solve the problem of reencoding OTA recorded shows to a tighter compression and saw this post.

  1. Is a post-processing script still the way to get this done? (I couldn’t find anything built into the Plex UI)

  2. How is Plex told to invoke the post-processing script?

TIA,

  1. Yes. If you want to transcode the video to a different codec.
  2. You tell Plex where your Post Processing Script is located In DVR Settings. After a recording ends before Plex would move it from the grab folder Plex will then call your script passing the path/filename of the recording to your script.