First off, I am by no means a script genius, it took me ages to get this far and people with more knowledge than me will no doubt find loads of faults in what I have written. Anyway, since I couldn't find anything on the forums related to this and I had to go to so many places to find all this info, I thought I would share it, hope this is the right place.
I have provided all the respective .exes in the accompanying zip file. Hope this is ok, anybody who maintains these exes and dont want them zipped here, please contact me via PM and I will remove them.
To use, extract the zip to some where. Enable the comskip plugin in TVServer, in the configuration of the plugin choose the pp1.bat file as the file to run and make sure you choose to run it after the recording ENDS.
You'll no doubt have to edit it a bit, but I have tried to indicate what you should edit.
More details will be found on my website, putting the no back in technology | pruperting, I'll add the direct link in a bit and it will include the script I run on my Ubuntu server (where the cleaned file is moved to) to convert the file to something smaller.
Here is the bat code:
I have provided all the respective .exes in the accompanying zip file. Hope this is ok, anybody who maintains these exes and dont want them zipped here, please contact me via PM and I will remove them.
To use, extract the zip to some where. Enable the comskip plugin in TVServer, in the configuration of the plugin choose the pp1.bat file as the file to run and make sure you choose to run it after the recording ENDS.
You'll no doubt have to edit it a bit, but I have tried to indicate what you should edit.
More details will be found on my website, putting the no back in technology | pruperting, I'll add the direct link in a bit and it will include the script I run on my Ubuntu server (where the cleaned file is moved to) to convert the file to something smaller.
Here is the bat code:
Code:
@ECHO off
Rem pp1.bat
Rem v0.1 09.07.09
Rem more details found on www.prupert.co.uk
Rem my first attempt at a batch file to be called by the comskip plugin in TVServer
Rem
Rem it cleans a TS file with mpeg2repair, then it runs comskip on it (the .ini has UK TV settings), then it cuts the TS file with mencoder based on the comskip's edl file, then it transfers it to my network folder and cleans up the crud
Rem %1 is the fully qualified name of the recorded mpeg file.
Rem I start VLC here since it is one of the processes that I have set the Powerscheduler to prevent system standby, thus it ensures the system does not shutdown whilst the bat file is running
START "" "C:\Program Files\VideoLAN\VLC\vlc.exe"
Rem this is because where I eventually move the cleaned file to, is on a USB hardrive on another computer, and this helps spin up the drive, you can delte this
%SystemRoot%\explorer.exe "Z:\"
ECHO ************************** >> "%~dpn1.PostLog.txt"
ECHO Post Processing started on %date% %time% >> "%~dpn1.PostLog.txt"
ECHO Post Processing started on %date% %time%
Rem Sadly, I just couldnt get ProjectX to work properly, I have left this in for intersts sake
Rem ECHO ProjectX cleanup started on %date% %time% >> "%~dpn1.PostLog.txt"
Rem ECHO ProjectX cleanup started on %date% %time%
Rem Echo %TIME% - Demultiplexing %~nx1
Rem echo "# Project-X INI" > "%TEMP%\X.ini"
Rem the original command that I found to actually get ProjectX to do something
Rem start "Demultiplexing %~1" /WAIT /LOW /MIN "C:\scripts\comskip\projectX\ProjectX.jar" -name "%~n1" -out "%~dp1" "%~1" -ini "%TEMP%\X.ini" -demux
Rem start "Demultiplexing %~1" /WAIT /LOW /MIN "C:\scripts\comskip\projectX\ProjectX.jar" -out "%TEMP%\rec2mpg" "%~1" -ini "%TEMP%\X.ini" -tots
Rem so instead I am using mpeg2repair, but since it has no CLI, I have to use mpeg2repairHelper
ECHO Starting mpeg2repair %date% %time% >> "%~dpn1.PostLog.txt"
mpeg2repairHelper.exe %1 %1-fixed.ts
ECHO mpeg2repair finished on %date% %time% >> "%~dpn1.PostLog.txt"
ECHO.
ECHO Commercial Detection...
ECHO Comskip started on %date% %time% >> "%~dpn1.PostLog.txt"
comskip %1-fixed.ts >>"%~dpn1.PostLog.txt"
ECHO Comskip finished on %date% %time% >> "%~dpn1.PostLog.txt"
REM ** Check for completion of ComSkip again...
REM ** If there's no txt file, ComSkip didn't run, don't continue...
IF EXIST "%1-fixed.edl" GOTO ComClean
ECHO ComSkip did not run right, PostProcess.bat will end now...
ECHO Comskip failed on %date% %time%. Ending PostProcessing.bat >> "%~dpn1.PostLog.txt"
GOTO EOF
:ComClean
ECHO %date% %time% >> "Z:\new_files.log"
ECHO Commercial removal...
ECHO ComClean started on %date% %time% >> "%~dpn1.PostLog.txt"
mencoder "%1-fixed.ts" -edl "%1-fixed.edl" -alang eng,nar -noskip -vf harddup -oac copy -ovc copy -of mpeg -o "%~dpn1_clean.ts"
REM mencoder "%~dpn1.ts" -edl "%~dpn1.edl" -alang eng -noskip -vf harddup -oac copy -ovc copy -of mpeg -o "%~dpn1_clean.ts"
ECHO ComClean finished on %date% %time% >> "%~dpn1.PostLog.txt"
Rem this is another call to keep the USB drive that the file is moved to going,you can delete this
ECHO New file %~n1_clean.ts being moved to Server >> "Z:\new_files.log"
REM ** Check for completion of ComClean...
REM ** If there's no original MPG file, comclean didn't run, don't continue...
IF EXIST "%~dpn1_clean.ts" GOTO Move
ECHO ComClean did not run right, PostProcess.bat will end now...
ECHO ComClean failed on %date% %time%. Ending PostProcessing.bat >> "%~dpn1.PostLog.txt"
GOTO EOF
:Move
ECHO Tidying up...
ECHO Tidying started on %date% %time% >> "%~dpn1.PostLog.txt"
Rem this is another call to keep the USB drive that the file is moved to going,you can delete this
%SystemRoot%\explorer.exe "Z:\"
REM ** if there isn't an '_clean.ts', comclean didn't run and so tidying should cease
IF not EXIST "%~dpn1_clean.ts" GOTO EOF
ECHO Moving Clean TS to Server directory on %date% %time% >> "%~dpn1.PostLog.txt"
IF EXIST "%~dpn1_clean.ts" del "%1"
REM you should change the location where you want the cleaned file to be moved, but keep this part: %~n1_clean.ts
move "%~dpn1_clean.ts" "Z:\%~n1_clean.ts"
ECHO Clean TS moved to Server directory on %date% %time% >> "%~dpn1.PostLog.txt"
Rem more logging and USB drive stuff
ECHO %~n1_clean.ts moved to Server on %date% %time% >> "Z:\new_files.log"
del "%1-fixed.txt"
del "%1-fixed.edl"
del "%1-fixed.ts"
del "%1-fixed.ts.txt"
:EOF
Rem this kills the vlc.exe, thus allowing the server to shutdown via the powersheduler plugin
TASKKILL /IM vlc.exe