I use a bit of powershell for work, so when it came to configuring postprocessing stuff for a freshly installed OS and new configuration of NPVR, I opted to rewrite in Powershell.
Not so much looking for support (I have everything in my configuration working (knock on wood) that I can tell) - but I figured I'd post up what I wrote just in case anyone else is interested. As usual, use at your own risk. Oh, and I wrote and tested all of this on Powershell 4 in Windows 7.
Here's what my main postprocessing.bat file looks like:
StreamFix.ps1: This one runs the .ts files generated by my HDHR through VideoRedo to fix junky timelines and kicks out a .mpg file.
and Comskip.ps1:
Not so much looking for support (I have everything in my configuration working (knock on wood) that I can tell) - but I figured I'd post up what I wrote just in case anyone else is interested. As usual, use at your own risk. Oh, and I wrote and tested all of this on Powershell 4 in Windows 7.
Here's what my main postprocessing.bat file looks like:
Code:
REM use the below line for logging output
REM powershell -NonInteractive -ExecutionPolicy unrestricted -NoLogo -NoProfile -f "C:\Users\Public\NPVR\Scripts\StreamFix.ps1" %1 >> C:\logs\postprocessing.log
REM Use this one for no log
powershell -NonInteractive -ExecutionPolicy unrestricted -NoLogo -NoProfile -f "C:\Users\Public\NPVR\Scripts\StreamFix.ps1" %1
SET _oldfile=%1
SET _newfile=%_oldfile:.ts=.mpg%
REM Comskip
powershell -NonInteractive -ExecutionPolicy unrestricted -NoLogo -NoProfile -f "C:\Users\Public\NPVR\Scripts\Comskip.ps1" %_newfile% %2
StreamFix.ps1: This one runs the .ts files generated by my HDHR through VideoRedo to fix junky timelines and kicks out a .mpg file.
Code:
trap {
Write-Host $_
exit 1
}
$ErrorActionPreference = "Stop" #stop on all errors
#Make sure this path is correct
$vrdPath = "C:\Program Files (x86)\VideoReDoPlus"
$vpPath = $vrdPath + "\vp.vbs"
$origFile = $args[0]
$newFile = $args[0].split('.')
$newFileFull = $newFile[0] + ".mpg"
$renamedFile = $newFile[0] + "_orig.ts"
Write-Host "Original File:" $origFile
Write-Host "New File:" $newFileFull
#$nologo = "//nologo"
cscript.exe //nologo $vpPath $origFile $newFileFull /t1 /q /na
Write-Host "Exit Code:" $LASTEXITCODE
#Check that the output file exists before continuing
$fileExists = Test-Path $newFileFull
if ($fileExists -eq $true) {
Rename-Item $origFile $renamedFile
Write-Host "Deleting renamed original ts file:" $renamedFile
Remove-Item $renamedFile
}
Write-Host " "
and Comskip.ps1:
Code:
trap {
Write-Host $_
exit 1
}
$ErrorActionPreference = "Stop" #stop on all errors
$file = $args[0]
$channel = $args[1]
$comskipExe = "C:\comskip\comskip.exe"
#Functions
function numInstances([string]$process)
{
@(Get-Process $process -ErrorAction 0).Count
}
#Main script execution starts here
#Skipping channels that don't need comskip, i.e. PBS
if ($channel -match "21" -or
$channel -match "22" -or
$channel -match "23" -or
$channel -match "24") {
Write-Host "Not running Comskip on channel" $channel
Write-Host "Exiting..."
break }
#Sleep a number of seconds equal to the channel nbr,
#prevents multiple postprocessing files from running at exactly the same time
Write-Host "Sleeping" $channel "seconds before starting comskip"
Start-Sleep -s $channel
#Check if comskip is running
$comskips = 2
while ($comskips -gt "1") {
$comskips = numInstances comskip
Write-Host "Two or more comskip instances running, sleeping 15 seconds"
Start-Sleep -s 15 }
$curDatetime = Get-Date
Write-Host $curDatetime
Write-Host "Invoking comskip on" $file
& $comskipExe $file
$curDatetime = Get-Date
Write-Host "Comskip finished."
Write-Host $curDatetime
NPVR Client Machine: AMD Athlon x4 610e, 4 GB DDR3, Asus M4A785TD-M Evo (using onboard ATI RadeonHD 4250), Win7 Home x32
500GB SATA Seagate MomentusXT system disk
Snapstream Firefly remote
NPVR Server: AMD Athlon X4, 16 GB DDR3, Asus M4A88TD-V Evo, Win7 Pro x64
Intel 530 SSD (system)
2 TB Media/recordings disk
SiliconDust HDHomeRun Plus on OTA ATSC
Drobo 5N network storage for archives
500GB SATA Seagate MomentusXT system disk
Snapstream Firefly remote
NPVR Server: AMD Athlon X4, 16 GB DDR3, Asus M4A88TD-V Evo, Win7 Pro x64
Intel 530 SSD (system)
2 TB Media/recordings disk
SiliconDust HDHomeRun Plus on OTA ATSC
Drobo 5N network storage for archives