i've been working on setting up a nice DVR-system that works as automated/unsupervised as possible yet still doesnt mess up my PC (i'm using the same system for HTPC and normal home PC). for those of you who want smth to start with, here it is!
(had to split in into multiple posts)
(had to split in into multiple posts)
Quote:@echo off
Rem PostProcessing.bat
Rem This script will be run automatically by GBPVR (when found) after a recording is finished
Rem To enable it put this file inside your GBPVR default program directory (C:\Program Files\devnz\gbpvr\)
Rem The script is called with two parameters
Rem %1 is the fully qualified name of the recorded mpeg file.
Rem %2 is the channel number of the recording
REM Cancel any Shutdown session
psshutdown -a
set gbpvr_dir=%ProgramFiles%\devnz\gbpvr
set logfile="%gbpvr_dir%\logs\postproc.log"
SET checkfile="%gbpvr_dir%\progress.txt"
rem flags to be used for standby decision
set recording_pending=no
set time_to_recording=30
set transcoding_now=yes
echo finished recording... channel %2, file %1... checking if we need to sleep... >> %logfile%
date /t >> %logfile%
time /t >> %logfile%
REM clean up temporary files
if exist %checkfile% del %checkfile%
rem decide how to handle recordings based on chan rez and possibly name or other things like that
rem make sure HD recordings that you want to keep as HD do NOT go to conversion!
echo %2 %1
rem get the subtitles - but we need to sync them first (and that means pre-parse mpeg2 to mpeg2 remove bad frames before ccextractor - too much overhead for now and ccextractor samples were not that great - lots of missing chars or sync issues)
rem echo getting subtitles...
rem ".\Third Party\ccextractor\windows\ccextractorwin.exe" -nofc -srt %1 -o1 "%~dpn1.srt" >> "logs\%~n1ccextractor.log" 2>&1
rem ".\Third Party\ccextractor\windows\ccextractorwin.exe" -nofc -fp -srt %1 -o1 "%~dpn1.srt" >> "logs\%~n1ccextractor.log" 2>&1
rem check which type of compression based on channel and show
rem echo %~n1 > "%~dpn1name.txt"
rem set wide=0
rem compress 720
if "%2" == "0" call _720pws2avi %1
rem compress 1080
if "%2" == "1" call _1080iws2avi %1
rem fox2.1 == 80 // 99 // 2
if "%2" == "80" (
rem hd_ws_*.txt contains HD (widescreen) shows that we want to compress as wide screen (16:9)
echo %~n1 | FINDSTR /B /M /I /L /G:hd_ws_fox2.txt
if errorlevel 0 if not errorlevel 1 ( call _720pws2avi %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call _720p2sdavi %1
)
)
rem mytv20.1 == 86 // 21 // 20
if "%2" == "86" call _720p2sdavi %1
rem nbc 4.1 == 82 // 97 // 4 // 90
rem if "%2" == "90" call _1080i2sdavi %1
rem abc7.1 == 84 // 44 // 7 // 92
if "%2" == "92" (
rem hd_ws_*.txt contains HD (widescreen) shows that we want to compress as wide screen (16:9)
echo %~n1 | FINDSTR /B /M /I /L /G:hd_ws_abc7.txt
if errorlevel 0 if not errorlevel 1 ( call _1080iws2avi %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call _1080i2sdavi %1
)
)
rem cw50.1 == 87 // 14 // 67
if "%2" == "87" call _1080i2sdavi %1
rem pbs56.1 == 97
if "%2" == "97" call _1080iws2avi %1
rem pbs56.2 == 88 // 58 // 56 // 89
if "%2" == "89" call _480i2sdavi %1
rem pbs56.3 == 89 // 94 // 72 // 96
if "%2" == "96" call _480i2sdavi %1
rem cbs62.1 == 91 // 96 // 62 // 98
if "%2" == "98" (
rem hd_ws_*.txt contains HD (widescreen) shows that we want to compress as wide screen (16:9)
echo %~n1 | FINDSTR /B /M /I /L /G:hd_ws_cbs62.txt
if errorlevel 0 if not errorlevel 1 ( call _1080iws2avi %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call _1080i2sdavi %1
)
)
rem 38.1 == 92 // 41 // 38 // 94
if "%2" == "94" call _480i2sdavi %1
rem 38.2 == 93 // 43 // 102 // 95
if "%2" == "95" call _480i2sdavi %1
rem if exist "%~dpn1name.txt" del "%~dpn1name.txt"
rem dont standby if file no_sleep.txt exists - just exit - computer will run until user decides
if exist "no_sleep.txt" goto nosleep
rem wait for another consecutive recording to start (assuming we didnt transcode)
ping -n 5 127.0.0.1
REM Check for recording in progress
echo checking if another recording in progress...
"%gbpvr_dir%\gbpvrcli.exe" /inprogress 1 /mes "{Status}\n{Title}\n{DescriptionNoWrap}\n\n" > %checkfile%
rem wait for gbpvrcli.exe to finish... maybe add start /wait to upper option?
ping -n 5 127.0.0.1
rem see if anything is being recorded now (file of non zero length)
rem echo before running progress
rem we have "progress" so do nothing
find /c "progress" %checkfile% && goto data
rem echo after running progress
rem echo before running pslist
rem pslist /accepteula
rem REG ADD HKEY_CURRENT_USER\Software\Sysinternals\PsList /v EulaAccepted /t REG_DWORD /d 1 /f
rem make sure other ffmpeg tasks NOT running before shutting down
rem pslist ffmpeg | find /c "not found" && set transcoding_now=no
pslist ffmpeg > "%~dpn1running.txt"
find /c "not found" "%~dpn1running.txt" && set transcoding_now=no
rem echo after running pslist
rem del "%~dpn1running.txt"
rem check if any recording pending soon
for /F "tokens=1,2,3,4,5 delims=#" %%a in ('gbpvrcli.exe /pending 1 /message "{MinutesToStartWithPadding}#{MinutesToEndWithPadding}#{RecordingLengthWithPadding}#{StartTimeWithPadding}#{Title}"') do (
rem Setlocal EnableDelayedExpansion needed to get the current values inside for-loop
Setlocal EnableDelayedExpansion
if %%a LSS %time_to_recording% (
echo %%e pending recording in %%a minutes at %%d
echo %%e pending recording in %%a minutes at %%d >> %logfile%
rem Endlocal needs to be set inside the for-loop to preserve the pending_recording value beyond for-loop
Endlocal
set recording_pending=yes
)
)
if %transcoding_now%==no if %recording_pending%==no (
rem nothing happening now - sleep!
goto empty
)
rem any other case means its recording/transcoding/pending recording soon
GOTO data
:empty
echo not recording...
echo nothing is currently recording or transcoding... standby in 5 minutes... >> %logfile%
date /t >> %logfile%
time /t >> %logfile%
if exist "%~dpn1running.txt" del "%~dpn1running.txt"
if exist %checkfile% del %checkfile%
rem make sure we dont get double shutdown!
psshutdown -a
rem standby interactive 5 minutes
psshutdown -d -c -t 300
goto end
:data
echo recording or transcoding... do nothing
echo still recording or transcoding... no standby yet... >> %logfile%
if exist "%~dpn1running.txt" type "%~dpn1running.txt" >> %logfile%
if exist "%~dpn1running.txt" del "%~dpn1running.txt"
if exist %checkfile% type %checkfile% >> %logfile%
if exist %checkfile% del %checkfile%
date /t >> %logfile%
time /t >> %logfile%
goto end
GBPVR 1.4.7
3 x HVR-950Q USB OTA ATSC HD TUNER
T2250 @ 2.5 GB RAM + ASUS Moca-AR Calcite
Roku HD + XD
3 x HVR-950Q USB OTA ATSC HD TUNER
T2250 @ 2.5 GB RAM + ASUS Moca-AR Calcite
Roku HD + XD