NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 16 17 18 19 20 … 93 Next »
PostProcessing.bat (sample)

 
  • 0 Vote(s) - 0 Average
PostProcessing.bat (sample)
pvruser
Offline

Member

Posts: 230
Threads: 42
Joined: May 2007
#1
2008-02-16, 07:19 PM (This post was last modified: 2008-02-16, 08:15 PM by pvruser.)
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)

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 Confused_720pws2avi %1

rem compress 1080
if "%2" == "1" call Confused_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 Confused_720pws2avi %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call Confused_720p2sdavi %1
)
)

rem mytv20.1 == 86 // 21 // 20
if "%2" == "86" call Confused_720p2sdavi %1

rem nbc 4.1 == 82 // 97 // 4 // 90
rem if "%2" == "90" call Confused_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 Confused_1080iws2avi %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call Confused_1080i2sdavi %1
)
)

rem cw50.1 == 87 // 14 // 67
if "%2" == "87" call Confused_1080i2sdavi %1

rem pbs56.1 == 97
if "%2" == "97" call Confused_1080iws2avi %1

rem pbs56.2 == 88 // 58 // 56 // 89
if "%2" == "89" call Confused_480i2sdavi %1

rem pbs56.3 == 89 // 94 // 72 // 96
if "%2" == "96" call Confused_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 Confused_1080iws2avi %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call Confused_1080i2sdavi %1
)
)

rem 38.1 == 92 // 41 // 38 // 94
if "%2" == "94" call Confused_480i2sdavi %1

rem 38.2 == 93 // 43 // 102 // 95
if "%2" == "95" call Confused_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
pvruser
Offline

Member

Posts: 230
Threads: 42
Joined: May 2007
#2
2008-02-16, 07:23 PM
this is part 2:

Quote:rem sub for compressing 480i to avi
Confused_480i2sdavi
echo transcode 480i avi %1
echo transcode 480i avi %1 >> %logfile%
psshutdown -a
rem convert low priority to allow normal use of windows
rem this does not work --- start /low /wait /b /d".\Third Party\FFmpeg\"
".\Third Party\FFmpeg\ffmpeg.exe" -y -i %1 -async 30 -ab 128k -r 29.97 -f avi -vcodec msmpeg4 -vtag MP43 -qscale 4 -aspect 4:3 -deinterlace "%~dpn1temp.mpg" >> "logs\%~n1ffmpeg.log" 2>&1
rem this keeps recording
ren %1 "x%~nx1"
rem use same name to avoid need for database updates
ren "%~dpn1temp.mpg" "%~nx1"

goto end


rem sub for converting 720p to sd (remove side pillars)
Confused_720p2sd
echo transcode 720p %1
echo transcode 720p %1 >> %logfile%
psshutdown -a
rem convert low priority to allow normal use of windows
rem this does not work --- start /low /wait /b /d".\Third Party\FFmpeg\"
".\Third Party\FFmpeg\ffmpeg.exe" -y -i %1 -async 30 -b 4000k -ab 128k -r 29.97 -s 1024x490 -f svcd -cropleft 160 -cropright 160 -croptop 10 -aspect 4:3 -threads 4 "%~dpn1temp.mpg" >> "logs\%~n1ffmpeg.log" 2>&1
rem this keeps recording
ren %1 "x%~nx1"
rem use same name to avoid need for database updates
ren "%~dpn1temp.mpg" "%~nx1"

goto end


rem sub for converting 720p to sd (remove side pillars) and compress avi
Confused_720p2sdavi
echo transcode 720p avi %1
echo transcode 720p avi %1 >> %logfile%
psshutdown -a
rem convert low priority to allow normal use of windows
rem this does not work --- start /low /wait /b /d".\Third Party\FFmpeg\"
".\Third Party\FFmpeg\ffmpeg.exe" -y -i %1 -async 30 -ab 128k -r 29.97 -s 1024x490 -f avi -vcodec msmpeg4 -vtag MP43 -qscale 6 -cropleft 160 -cropright 160 -croptop 10 -aspect 4:3 "%~dpn1temp.mpg" >> "logs\%~n1ffmpeg.log" 2>&1
rem this keeps recording
ren %1 "x%~nx1"
rem use same name to avoid need for database updates
ren "%~dpn1temp.mpg" "%~nx1"

goto end


rem sub for compressing 720p and keep widescreen (do NOT remove side pillars)
Confused_720pws2avi
echo transcode 720p ws avi %1
echo transcode 720p ws avi %1 >> %logfile%
psshutdown -a
rem convert low priority to allow normal use of windows
rem this does not work --- start /low /wait /b /d".\Third Party\FFmpeg\"
".\Third Party\FFmpeg\ffmpeg.exe" -y -i %1 -async 30 -ac 2 -ab 128k -r 29.97 -s 640x360 -f avi -vcodec msmpeg4 -vtag MP43 -qscale 6 -aspect 16:9 "%~dpn1temp.mpg" >> "logs\%~n1ffmpeg.log" 2>&1
rem this keeps recording
ren %1 "x%~nx1"
rem use same name to avoid need for database updates
ren "%~dpn1temp.mpg" "%~nx1"

goto end


rem sub for converting 1080i to sd (remove side pillars)
Confused_1080i2sd
echo transcode 1080i %1
echo transcode 1080i %1 >> %logfile%
psshutdown -a
rem convert low priority to allow normal use of windows
rem this does not work --- start /low /wait /b /d".\Third Party\FFmpeg\"
".\Third Party\FFmpeg\ffmpeg.exe" -y -i %1 -async 30 -b 4000k -ab 128k -ac 2 -r 29.97 -s 1184x500 -f svcd -cropleft 240 -cropright 240 -croptop 20 -aspect 4:3 -threads 4 "%~dpn1temp.mpg" >> "logs\%~n1ffmpeg.log" 2>&1
rem this keeps recording
ren %1 "x%~nx1"
rem use same name to avoid need for database updates
ren "%~dpn1temp.mpg" "%~nx1"

goto end


rem sub for converting 1080i to sd (remove side pillars) and compress avi
Confused_1080i2sdavi
echo transcode 1080i avi %1
echo transcode 1080i avi %1 >> %logfile%
psshutdown -a
rem convert low priority to allow normal use of windows
rem this does not work --- start /low /wait /b /d".\Third Party\FFmpeg\"
".\Third Party\FFmpeg\ffmpeg.exe" -y -i %1 -async 30 -ab 128k -ac 2 -r 29.97 -s 1184x500 -f avi -vcodec msmpeg4 -vtag MP43 -qscale 4 -cropleft 240 -cropright 240 -croptop 20 -aspect 4:3 "%~dpn1temp.mpg" >> "logs\%~n1ffmpeg.log" 2>&1
rem this keeps recording
ren %1 "x%~nx1"
rem use same name to avoid need for database updates
ren "%~dpn1temp.mpg" "%~nx1"

goto end


rem sub for compressing 1080i and keep widescreen (do NOT remove side pillars)
Confused_1080iws2avi
echo transcode 1080i ws avi %1
echo transcode 1080i ws avi %1 >> %logfile%
psshutdown -a
rem convert low priority to allow normal use of windows
rem this does not work --- start /low /wait /b /d".\Third Party\FFmpeg\"
".\Third Party\FFmpeg\ffmpeg.exe" -y -i %1 -async 30 -ab 128k -ac 2 -r 29.97 -s 640x360 -f avi -vcodec msmpeg4 -vtag MP43 -qscale 4 -aspect 16:9 "%~dpn1temp.mpg" >> "logs\%~n1ffmpeg.log" 2>&1
rem this keeps recording
ren %1 "x%~nx1"
rem use same name to avoid need for database updates
ren "%~dpn1temp.mpg" "%~nx1"

goto end


:nosleep
echo sleep disabled (found no_sleep.txt)... do nothing
echo sleep disabled (found no_sleep.txt)... do nothing >> %logfile%
date /t >> %logfile%
time /t >> %logfile%
if exist "%~dpn1running.txt" del "%~dpn1running.txt"
if exist %checkfile% del %checkfile%

goto end


:end

here are the widescreen flag files which will force widescreen 16:9 encoding instead of cutting off sides for old-style 4:3 (hd_ws_*.txt):

hd_ws_fox2.txt
Quote:House
Terminator
Back to you

hd_ws_abc7.txt:
Quote:Dance war
Lost

hd_ws_cbs62.txt
Quote:The new adventures
The big bang
How I met
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
pvruser
Offline

Member

Posts: 230
Threads: 42
Joined: May 2007
#3
2008-02-16, 07:30 PM (This post was last modified: 2008-02-16, 08:20 PM by pvruser.)
what it does:

encodes each show after it's done, then starts a 5 minute countdown for standby. if no user is present to cancel it, the PC goes to "sleep". it will restart for next recording or manually by the user.

using the special files as follows:
no_sleep.txt - empty text file in the gbpvr dir - if present will not start the 5 minute countdown for standby

hd_ws_* contain shows which you want to keep as widescreen. all other shows will be saved as 4:3.

to get the channel numbers from these statements:
rem mytv20.1 == 86
if "%2" == "86" call Confused_720p2sdavi %1

you need to go to the "config" popup, "channels" tab. it's the "channel number" value next to your real channel. steps work for versioon 0.99.12 which i'm using, may be different for others.
"20.1 WMYDDT" "86"


you need pstools from the M$ site.

you may also need the latest ffmpeg from here, or could get audio sync issues:
http://ffdshow.faireal.net/mirror/ffmpeg/

you may also need other utils available on the board like gbpvrcli.exe.

final result will be a MS MP43 compressed file (about 10 times smaller than HD broadcast size). the name is kept the same to avoid messing with the DB.

the original recordings are kept and renamed to "xName" (add "x" before the name) instead of deleting. i found it's safer to manually delete files every 2-3 days than have them disapper into nothingness due to some bug in the script Smile

hope you like it!

PS: credits to others from this board and around the net who provided various batch programming examples. M$ batch programming is terrible!
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
pvruser
Offline

Member

Posts: 230
Threads: 42
Joined: May 2007
#4
2008-02-29, 08:03 PM
new version inside zip file. added "delete_files" variable. if set to yes it will delete original files after compression instead of renaming to "xName". setting to no will keep the rename functionality.
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
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#5
2008-03-05, 08:36 AM
Drat. You beat me to it. I've been thinking of something like this for auto switching and ZProcess.

That batch is for good reading material... Big Grin
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
pvruser
Offline

Member

Posts: 230
Threads: 42
Joined: May 2007
#6
2008-03-09, 01:07 PM
zehd Wrote:Drat. You beat me to it. I've been thinking of something like this for auto switching and ZProcess.

That batch is for good reading material... Big Grin

it's always nice to give back to the community Smile
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
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#7
2009-01-24, 03:41 PM
Quote:After hours of testing (does testing ever only last moments?) I have determined that GBPVR version 1.3.11 is ignoring my postprocessing.bat
If you do a recording, then zip and attach your GBPVRRecording Service, I'll check for you.
keith_leitch
Offline

Senior Member

Posts: 510
Threads: 53
Joined: Nov 2008
#8
2009-01-26, 12:11 PM
sub Wrote:If you do a recording, then zip and attach your GBPVRRecording Service, I'll check for you.

Thanks, Sub. As I mentioned in a private email, postprocessing.bat is running after all. I was confused because it was running invisibly. This has caused me some related problems, as it does not seem to issue commands that interact with the UI (such as POWERCFG). This is despite the fact that I have this option ticked on the GB-PVR Recording Service.
pvruser
Offline

Member

Posts: 230
Threads: 42
Joined: May 2007
#9
2011-03-03, 04:31 PM
This is the latest version for those interested. it encodes mp4 for the Roku to be used as frontend. see my other topic regarding the Roku setup.

Part 1:

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 echo before running pslist for the first time
rem psshutdown /accepteula
rem REG ADD HKEY_CURRENT_USER\Software\Sysinternals\PsShutdown /v EulaAccepted /t REG_DWORD /d 1 /f
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=180
set transcoding_now=yes
set ccextract_now=yes

rem decide to delete or keep (and rename) files
set delete_files=yes
rem set delete_files=no

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%

echo finished recording... channel %2, file %1

rem echo getting subtitles if not already there...
if exist "%~dpn1.srt" goto checkchan
echo starting post subtitle extraction on channel %2, file %1... >> %logfile%
start /wait /low /min /b "ccextractorwin" ".\Third Party\ccextractor\windows\ccextractorwin.exe" -90090 --fixpadding --largegops --nofontcolor -out=srt --sentencecap %1 -o "%~dpn1.srt"


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!
rem check which type of compression based on channel and show
rem echo %~n1 > "%~dpn1name.txt"


:checkchan
rem need this to deal with special chars
set showname=%~n1

Setlocal EnableDelayedExpansion
echo showname is !showname!

rem compress as-is (zero changes) 480/720/1080
if "%2" == "000" call Confused_tv2mp4 %1

rem compress 1080 (cut sides to 4:3)
if "%2" == "001" call Confused_1080i2sdmp4 %1

rem compress 720 (cut sides to 4:3)
if "%2" == "007" call Confused_720p2sdmp4 %1

rem compress 480 (cut top/bottom)
if "%2" == "004" call Confused_sd2wsmp4 %1

rem fox2.1
if "%2" == "99021" (
rem hd_full_*.txt contains HD (widescreen) shows that we want to keep as HD (not compressed)
echo !showname! | FINDSTR /B /M /I /L /G:hd_full_fox2.txt
if errorlevel 0 if not errorlevel 1 (
echo keeping hd file !showname!... no extra conversion or rename... >> %logfile%
echo keeping hd file !showname!... no extra conversion or rename...
goto keephd
)
rem hd_ws_*.txt contains HD (widescreen) shows that we want to compress as wide screen (16:9)
echo !showname! | FINDSTR /B /M /I /L /G:hd_ws_fox2.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_tv2mp4 %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call Confused_720p2sdmp4 %1
)
)

rem mytv20.1
if "%2" == "99201" (
rem hd_full_*.txt contains HD (widescreen) shows that we want to keep as HD (not compressed)
echo !showname! | FINDSTR /B /M /I /L /G:hd_full_mytv20.txt
if errorlevel 0 if not errorlevel 1 (
echo keeping hd file !showname!... no extra conversion or rename... >> %logfile%
echo keeping hd file !showname!... no extra conversion or rename...
goto keephd
)
rem hd_ws_*.txt contains HD (widescreen) shows that we want to compress as wide screen (16:9)
echo !showname! | FINDSTR /B /M /I /L /G:hd_ws_mytv20.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_tv2mp4 %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call Confused_720p2sdmp4 %1
)
)

rem nbc 4.1
if "%2" == "99041" (
rem hd_full_*.txt contains HD (widescreen) shows that we want to keep as HD (not compressed)
echo !showname! | FINDSTR /B /M /I /L /G:hd_full_nbc4.txt
if errorlevel 0 if not errorlevel 1 (
echo keeping hd file !showname!... no extra conversion or rename... >> %logfile%
echo keeping hd file !showname!... no extra conversion or rename...
goto keephd
)
rem hd_ws_*.txt contains HD (widescreen) shows that we want to compress as wide screen (16:9)
echo !showname! | FINDSTR /B /M /I /L /G:hd_ws_nbc4.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_tv2mp4 %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call Confused_1080i2sdmp4 %1
)
)

rem THIS 4.2
rem if "%2" == "99042" call Confused_tv2mp4 %1
if "%2" == "99042" (
rem sd_ws_*.txt contains SD (widescreen) shows that we want to compress as wide screen (16:9) by cutting upper/lower borders
echo !showname! | FINDSTR /B /M /I /L /GConfusedd_ws_this42.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_sd2wsmp4 %1 ) else (
rem all other shows will compress keeping the same size
call Confused_tv2mp4 %1
)
)

rem abc7.1 == 62
if "%2" == "99071" (
rem hd_full_*.txt contains HD (widescreen) shows that we want to keep as HD (not compressed)
echo !showname! | FINDSTR /B /M /I /L /G:hd_full_abc7.txt
if errorlevel 0 if not errorlevel 1 (
echo keeping hd file !showname!... no extra conversion or rename... >> %logfile%
echo keeping hd file !showname!... no extra conversion or rename...
goto keephd
)
rem hd_ws_*.txt contains HD (widescreen) shows that we want to compress as wide screen (16:9)
echo !showname! | FINDSTR /B /M /I /L /G:hd_ws_abc7.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_tv2mp4 %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call Confused_720p2sdmp4 %1
)
)

rem RTN7.2
rem if "%2" == "99072" call Confused_tv2mp4 %1
if "%2" == "99072" (
rem sd_ws_*.txt contains SD (widescreen) shows that we want to compress as wide screen (16:9) by cutting upper/lower borders
echo !showname! | FINDSTR /B /M /I /L /GConfusedd_ws_rtn72.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_sd2wsmp4 %1 ) else (
rem all other shows will compress keeping the same size
call Confused_tv2mp4 %1
)
)

rem cw50.1 == 67
if "%2" == "99501" (
rem hd_full_*.txt contains HD (widescreen) shows that we want to keep as HD (not compressed)
echo !showname! | FINDSTR /B /M /I /L /G:hd_full_cw50.txt
if errorlevel 0 if not errorlevel 1 (
echo keeping hd file !showname!... no extra conversion or rename... >> %logfile%
echo keeping hd file !showname!... no extra conversion or rename...
goto keephd
)
rem hd_ws_*.txt contains HD (widescreen) shows that we want to compress as wide screen (16:9)
echo !showname! | FINDSTR /B /M /I /L /G:hd_ws_cw50.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_tv2mp4 %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call Confused_1080i2sdmp4 %1
)
)

rem pbs56.1
if "%2" == "99561" (
rem hd_full_*.txt contains HD (widescreen) shows that we want to keep as HD (not compressed)
echo !showname! | FINDSTR /B /M /I /L /G:hd_full_pbs56.txt
if errorlevel 0 if not errorlevel 1 (
echo keeping hd file !showname!... no extra conversion or rename... >> %logfile%
echo keeping hd file !showname!... no extra conversion or rename...
goto keephd
) else (
call Confused_tv2mp4 %1
)
)

rem pbs56.2 - always 16:9 ws 480i
rem if "%2" == "99562" call Confused_tv2mp4 %1
if "%2" == "99562" (
rem sd_ws_*.txt contains SD (widescreen) shows that we want to compress as wide screen (16:9) by cutting upper/lower borders
echo !showname! | FINDSTR /B /M /I /L /GConfusedd_ws_pbs562.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_sd2wsmp4 %1 ) else (
rem all other shows will compress forcing 16:9 Roku resolution without cutting (special case)
call Confused_sd2wspressmp4 %1
)
)

rem pbs56.3
rem if "%2" == "99563" call Confused_tv2mp4 %1
if "%2" == "99563" (
rem sd_ws_*.txt contains SD (widescreen) shows that we want to compress as wide screen (16:9) by cutting upper/lower borders
echo !showname! | FINDSTR /B /M /I /L /GConfusedd_ws_pbs563.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_sd2wsmp4 %1 ) else (
rem all other shows will compress keeping the same size
call Confused_tv2mp4 %1
)
)

rem cbs62.1
if "%2" == "99621" (
rem hd_full_*.txt contains HD (widescreen) shows that we want to keep as HD (not compressed)
echo !showname! | FINDSTR /B /M /I /L /G:hd_full_cbs62.txt
if errorlevel 0 if not errorlevel 1 (
echo keeping hd file !showname!... no extra conversion or rename... >> %logfile%
echo keeping hd file !showname!... no extra conversion or rename...
goto keephd
)
rem hd_ws_*.txt contains HD (widescreen) shows that we want to compress as wide screen (16:9)
echo !showname! | FINDSTR /B /M /I /L /G:hd_ws_cbs62.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_tv2mp4 %1 ) else (
rem all other shows will compress and cut off sides (4:3)
call Confused_1080i2sdmp4 %1
)
)

rem 38.1
rem if "%2" == "99381" call Confused_tv2mp4 %1
if "%2" == "99381" (
rem sd_ws_*.txt contains SD (widescreen) shows that we want to compress as wide screen (16:9) by cutting upper/lower borders
echo !showname! | FINDSTR /B /M /I /L /GConfusedd_ws_381.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_sd2wsmp4 %1 ) else (
rem all other shows will compress keeping the same size
call Confused_tv2mp4 %1
)
)

rem 38.2
rem if "%2" == "99382" call Confused_tv2mp4 %1
if "%2" == "99382" (
rem sd_ws_*.txt contains SD (widescreen) shows that we want to compress as wide screen (16:9) by cutting upper/lower borders
echo !showname! | FINDSTR /B /M /I /L /GConfusedd_ws_382.txt
if errorlevel 0 if not errorlevel 1 ( call Confused_sd2wsmp4 %1 ) else (
rem all other shows will compress keeping the same size
call Confused_tv2mp4 %1
)
)

Endlocal
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
pvruser
Offline

Member

Posts: 230
Threads: 42
Joined: May 2007
#10
2011-03-03, 04:32 PM
Part 2:

Quote::keephd

rem if exist "%~dpn1name.txt" del "%~dpn1name.txt"

rem rename recording here (show - episode) & save metadata
rem WizRenameRecording %1 "({episode}{or}{show})"

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 above 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 for the first time
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
rem pslist ffmpeg > "%~dpn1running.txt"
pslist HandBrakeCLI > "%~dpn1running.txt"
find /c "not found" "%~dpn1running.txt" && set transcoding_now=no
rem echo after running pslist
rem del "%~dpn1running.txt"

rem need to wait for ccextractorwin to finish stream waiting (in case we don't transcode and keep the TS file)
ping -n 15 127.0.0.1
pslist ccextractorwin > "%~dpn1running.txt"
find /c "not found" "%~dpn1running.txt" && set ccextract_now=no


rem check if any recording pending soon
for /F "tokens=1,2,3,4,5 delims=#" %%a in ('gbpvrcli.exe /pending 1 /orderby "{StartTime}" /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 %ccextract_now%==no 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 countdown started... >> %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 minutes
psshutdown -d -c -t 1800
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




rem Start Transcoding functions

rem sub for compressing tv mp4 (no cutting or aspect change) works with HD and SD
Confused_tv2mp4
echo transcode tv2 mp4 %1
echo transcode tv2 mp4 %1 >> %logfile%
psshutdown -a

rem max 720 x 480 for the Roku
start /wait "tv2mp4 conv" /belownormal ".\Third Party\HandBrakeCLI\HandBrakeCLI.exe" -i %1 -o "%~dpn1temp.mp4" -b 1500 -B 128 -R 48 -w 720 -Y528 -O -r 29.97 -d --crop 5:5:0:0 --loose-anamorphic 1>> "logs\%~n1handbrk.log" 2>&1

if errorlevel 0 (
echo transcode was fine... delete file
set nodel=0
) else (
echo transcode error!
set nodel=1
)

call Confused_renamerec %1 %nodel%

goto end


rem for SD channels we may want to cut upper and lower bars and get widescreen (similar to side bars in HD)
Confused_sd2wsmp4
echo transcode sd2ws mp4 %1
echo transcode sd2ws mp4 %1 >> %logfile%
psshutdown -a

rem max 720 x 400 for the Roku
start /wait "sd2wsmp4 conv" /belownormal ".\Third Party\HandBrakeCLI\HandBrakeCLI.exe" -i %1 -o "%~dpn1temp.mp4" -b 1500 -B 128 -R 48 -w 720 -Y 400 -O -r 29.97 -d --crop 60:60:0:0 --loose-anamorphic 1>> "logs\%~n1handbrk.log" 2>&1

if errorlevel 0 (
echo transcode was fine... delete file
set nodel=0
) else (
echo transcode error!
set nodel=1
)

call Confused_renamerec %1 %nodel%

goto end


rem for SD channels broadcast as widescreen - force widescreen rez
Confused_sd2wspressmp4
echo transcode sd2ws press mp4 %1
echo transcode sd2ws press mp4 %1 >> %logfile%
psshutdown -a

start /wait "sd2wspressmp4 conv" /belownormal ".\Third Party\HandBrakeCLI\HandBrakeCLI.exe" -i %1 -o "%~dpn1temp.mp4" -b 1500 -B 128 -R 48 -w 720 -Y 400 -O -r 29.97 -d --crop 0:0:0:0 --loose-anamorphic 1>> "logs\%~n1handbrk.log" 2>&1

if errorlevel 0 (
echo transcode was fine... delete file
set nodel=0
) else (
echo transcode error!
set nodel=1
)

call Confused_renamerec %1 %nodel%

goto end


rem sub for compressing 720p2sd mp4 (cut sides to 4:3)
Confused_720p2sdmp4
echo transcode 720p2sd mp4 %1
echo transcode 720p2sd mp4 %1 >> %logfile%
psshutdown -a

start /wait "720p2sdmp4 conv" /belownormal ".\Third Party\HandBrakeCLI\HandBrakeCLI.exe" -i %1 -o "%~dpn1temp.mp4" -b 1500 -B 128 -R 48 -w 720 -Y528 -O -r 29.97 -d --crop 5:5:165:165 --loose-anamorphic 1>> "logs\%~n1handbrk.log" 2>&1

if errorlevel 0 (
echo transcode was fine... delete file
set nodel=0
) else (
echo transcode error!
set nodel=1
)

call Confused_renamerec %1 %nodel%

goto end


rem sub for compressing 1080i2sd mp4 (cut sides to 4:3)
Confused_1080i2sdmp4
echo transcode 1080i2sd mp4 %1
echo transcode 1080i2sd mp4 %1 >> %logfile%
psshutdown -a

start /wait "1080i2sdmp4 conv" /belownormal ".\Third Party\HandBrakeCLI\HandBrakeCLI.exe" -i %1 -o "%~dpn1temp.mp4" -b 1500 -B 128 -R 48 -w 720 -Y528 -O -r 29.97 -d --crop 5:5:250:250 --loose-anamorphic 1>> "logs\%~n1handbrk.log" 2>&1

if errorlevel 0 (
echo transcode was fine... delete file
set nodel=0
) else (
echo transcode error!
set nodel=1
)

call Confused_renamerec %1 %nodel%

goto end

rem End Transcoding functions



rem rename function
Confused_renamerec
rem echo inside s_renamerec
if %delete_files%==yes (
rem if "%2" == "0" (
if "%2" == "0" if exist "%~dpn1temp.mp4" (
echo transcoding is fine... deleting file >> %logfile%
echo transcoding is fine... deleting file
del %1
) else (
echo something was wrong with transcoding... not deleting... exiting... >> %logfile%
echo something was wrong with transcoding... not deleting... exiting...
goto end
)
) else (
rem this keeps recording
echo deleting option disabled... renaming/keeping original file >> %logfile%
echo deleting option disabled... renaming/keeping original file
ren %1 "x%~nx1"
)
rem use same name to avoid need for database updates
rem ren "%~dpn1temp.mpg" "%~nx1"
ren "%~dpn1temp.mp4" "%~n1.mp4"

rem this points to the new mp4 (apparently auto-rename doesnt always work properly and files go missing)
set db=GBPVR.DB3
set oid=
for /f "usebackq tokens=1,2 delims=," %%v in (`sqlite3 "%db%" "SELECT oid FROM recording_schedule where filename like '%%%~nx1'; " `) do set oid=%%v
sqlite3.exe -separator "," "%db%" "UPDATE RECORDING_SCHEDULE SET filename = '%~dpn1.mp4' where oid = '%oid%';"

ping -n 15 127.0.0.1

rem rename recording here (show - episode) & save metadata
rem WizRenameRecording %1 "({episode}{or}{show})"
rem WizRenameRecording %1 "({show}{[-]}{episode}{or}{show}){[_]}{year}{month}{day}"
WizRenameRecording "%~dpn1.mp4" "({show}{[-]}{episode}{or}{show}){[_]}{year}{month}{day}"

goto end


:nosleep
echo sleep disabled (found no_sleep.txt)... do nothing
echo sleep disabled (found no_sleep.txt)... do nothing >> %logfile%
date /t >> %logfile%
time /t >> %logfile%
if exist "%~dpn1running.txt" del "%~dpn1running.txt"
if exist %checkfile% del %checkfile%

goto end


: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
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  sample video overlay plugin source code? reven 2 2,326 2011-10-03, 12:42 AM
Last Post: reven
  NPVR Popup sample mvallevand 3 1,577 2010-07-14, 07:54 PM
Last Post: mvallevand
  ParallelProcessing.bat to get NTSC & ATSC subtitles (sample) pvruser 0 1,234 2009-08-28, 02:53 AM
Last Post: pvruser
  anyone got a sample IInfoPanel plugin? reven 0 1,522 2004-11-01, 07:35 PM
Last Post: reven
  PostProcessing Dvr-MS files to remove comercial breaks 0 441 Less than 1 minute ago
Last Post:

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode