PostProccessing: Usage Examples

Now that Postprocessing is here, see: DVR Beta Three: DVR Hard With A Vengeance - Plex Features - Plex Forum
I thought I would share one way to use it.
I wanted this to accomplish two task;
1: Set the AUDIO to the correct language as currently the recordings are stored with AUDIO: Unknown instead of AUDIO: English
2: Identify and remove the commercials

**Prerequisites: **
MKVToolNix: https://mkvtoolnix.download/
FFMPEG & Comskip: GitHub - erikkaashoek/Comskip: A free commercial detector
(Note: if you are on Windows you can also install from : http://www.comskip.org/)
PlexComskip.py: Clone the PlexComskip repo: GitHub - ekim1337/PlexComskip
Copy PlexComskip.conf.example to PlexComskip.conf and edit as necessary (defaults should be pretty good)

Once all the above is installed, here is a sample script that will set the language to English and remove commercials
Sample Linux script:

#!/bin/sh
/usr/bin/mkvpropedit "$1" --edit track:a1 --set language=eng --edit track:v1 --set language=eng
sleep 5
/usr/bin/python /path/to/PlexComskip.py "$1" 

Windows Powershell Script to remove Commercials, (by @sGarver )

Additionally, here are some other user submitted links on how to just mark the location of the commercials as chapter marks so you can just skip past them.

Perl version (by @“ml@kg6sed.com”):
Can ffmpeg write comskip info into the video file? - #7 by ml_kg6sed.com - Plex Features - Plex Forum

Windows Batch File verison (by @Ethre):

Bash Script (by @bjs1400):

Can this be done in windows?

sure, you can get comskip from it’s main site.
Then you just need to install ffmpeg, python, & git

I have been using MCEBuddy to handle the removing of commercials and converting of files. Simple frontend and easy to use. I believe its only avail for windows.

Alright, I’ve read through the python script and am looking to use MCEBuddy (paid) with ComSkip (paid). What I can’t figure out is where the “file” variable is passed, or what environment variable it is on Windows so I can pass it to MCEBuddy.UserCLI and add it to the processing queue.

So, is it %1, or etc?

Or am I missing some documentation somewhere.

@mkmorris said:
Alright, I’ve read through the python script and am looking to use MCEBuddy (paid) with ComSkip (paid). What I can’t figure out is where the “file” variable is passed, or what environment variable it is on Windows so I can pass it to MCEBuddy.UserCLI and add it to the processing queue.

So, is it %1, or etc?

Or am I missing some documentation somewhere.

Yes, I believe, in Windows, the 1st ARG is %1

Gotcha, ok, it is %1 - what I mean is that the filename is passed to the postproc script in the first argument?

As in, this is what I have now in Plex_PostProcess.bat:
“C:\Program Files\MCEBuddy2x\MCEBuddy.UserCLI.exe” --command=addfile --action="%1"

(which runs, standalone but obviously complains no file ni %1 was passed to it)

And the DVR config shows this inthe XML now:

So in theory, I should be good to go? (btw “Program Files” == “Progra~1”)

@mkmorris said:
What I can’t figure out is where the “file” variable is passed, or what environment variable it is on Windows so I can pass it to MCEBuddy.UserCLI and add it to the processing queue.
That’s exactly my logic problem as well. I’m currently just using
MCEBuddy.UserCLI.exe --command=engine --action=start
to start the scan process and let MCEBuddy scan the .grab subfolders for new files.

@mkmorris said:
Gotcha, ok, it is %1 - what I mean is that the filename is passed to the postproc script in the first argument?

As in, this is what I have now in Plex_PostProcess.bat:
“C:\Program Files\MCEBuddy2x\MCEBuddy.UserCLI.exe” --command=addfile --action=“%1”

(which runs, standalone but obviously complains no file ni %1 was passed to it)

And the DVR config shows this inthe XML now:

So in theory, I should be good to go? (btw “Program Files” == “Progra~1”)

So let’s say you have a file at /path/to/file.mkv
What happens is you run your .bat manually

C:\path	o\batchfile\Plex_PostProcessing.bat "\path	o\file.mkv"

What error is returned?

@hthighway said:

@mkmorris said:
Gotcha, ok, it is %1 - what I mean is that the filename is passed to the postproc script in the first argument?

As in, this is what I have now in Plex_PostProcess.bat:
“C:\Program Files\MCEBuddy2x\MCEBuddy.UserCLI.exe” --command=addfile --action=“%1”

(which runs, standalone but obviously complains no file ni %1 was passed to it)

And the DVR config shows this inthe XML now:

So in theory, I should be good to go? (btw “Program Files” == “Progra~1”)

So let’s say you have a file at /path/to/file.mkv
What happens is you run your .bat manually

C:\path	o\batchfile\Plex_PostProcessing.bat "\path	o\file.mkv"

What error is returned?

No error, works like a charm (running manually, not launched from plex). So I suspect I should be good to go?

@mkmorris said:

@hthighway said:

@mkmorris said:
Gotcha, ok, it is %1 - what I mean is that the filename is passed to the postproc script in the first argument?

As in, this is what I have now in Plex_PostProcess.bat:
“C:\Program Files\MCEBuddy2x\MCEBuddy.UserCLI.exe” --command=addfile --action=“%1”

(which runs, standalone but obviously complains no file ni %1 was passed to it)

And the DVR config shows this inthe XML now:

So in theory, I should be good to go? (btw “Program Files” == “Progra~1”)

So let’s say you have a file at /path/to/file.mkv
What happens is you run your .bat manually

C:\path	o\batchfile\Plex_PostProcessing.bat "\path	o\file.mkv"

What error is returned?

No error, works like a charm (running manually, not launched from plex). So I suspect I should be good to go?

Yes it should work then inside of Plex.

If Plex just completed recording shows on multiple tuners, is it going to queue these up, or is it going to kick off multiple instances of the script? I don’t want to over task my server, it is only a dual core.

It will kickoff multiple instances of the script
Actually, I’m not sure. Let me check

Option to queue seems important. Also to clarify, if you automate post process through the post process step, will the newly created converted files be automatically deleted according to the keep x episodes rules? Will the gracenote meta data be retained on the newly converted files?

@drsalomon said:
will the newly created converted files be automatically deleted according to the keep x episodes rules?
YES

Will the gracenote meta data be retained on the newly converted files?
YES

@hthighway said:
It will kickoff multiple instances of the script
Actually, I’m not sure. Let me check
According to my taskmanager it does launch multiple instances of the script, one for each file.

@Wiidesire said:

@hthighway said:
It will kickoff multiple instances of the script
Actually, I’m not sure. Let me check
According to my taskmanager it does launch multiple instances of the script, one for each file.

Yes I am seeing the same thing. Hope those with that 6-tuner DVR have enough CPU to handle it :slight_smile:

@hthighway said:
Hope those with that 6-tuner DVR have enough CPU to handle it :slight_smile:
My script is intelligent enough to make a queue based on the MCEBuddy settings for concurrent transcodings so for me only one at a time :slight_smile:

I don’t want to wait that long :slight_smile:

At most I would have 4 tuners (two Connect devices) once they support multiple DVRs and I don’t foresee a problem processing 4 at once

When MCEBuddy transcodes, I see around 40-70% CPU usage for FFMPEG. So maybe I’ll change it to two at once to maximize time efficiency.