PDA

View Full Version : request: {MinutesToStart} for gbpvrcli



pvruser
2007-09-25, 11:58 PM
great addon for this great gbpvr app :) but i've also got a request:

{MinutesToStart} for gbpvrcli which should display the number of minutes remaining till the next recording.

why do i need this? because i'm transcoding with ffmpeg in the PostProcessing.bat and i need to make sure i dont shut down 2-3 minutes before the next recording starts! i've noticed that the computer comes out of standby about 5 minutes before a recording so that would cause it to miss a recording.

Thanks!

HtV
2007-09-26, 06:10 AM
I think this already is covered. I think gbpvr will keep the system awake a certain amount of time before a recording starts. I've never seen reports on this.

K.S.
2007-09-26, 08:16 AM
you can use {StartTimeWithPadding} to get that value, see my example here (http://forums.gbpvr.com/showpost.php?p=148740&postcount=4)

pvruser
2007-09-26, 12:41 PM
I think this already is covered. I think gbpvr will keep the system awake a certain amount of time before a recording starts. I've never seen reports on this.

i'm using this to standby after each recording/encoding:

psshutdown -d -c -t 300

i managed to manually stand-by the machine less than 2 minutes before a recording without being stopped by slimm or the actual gbpvr. however it never happened (yet afaik) to do this automatically and miss a recording.

i've only upgraded a week ago and still updating my conversion scripts thats why i wanted to account for all cases...

pvruser
2007-09-26, 12:42 PM
you can use {StartTimeWithPadding} to get that value, see my example here (http://forums.gbpvr.com/showpost.php?p=148740&postcount=4)

nice batch! thanks i'll give it a try! it sure looks very complex. wish gbpvrcli would just have that option (or any other way by running a command not a batch).

K.S.
2007-09-26, 01:20 PM
nice batch! thanks i'll give it a try! it sure looks very complex. wish gbpvrcli would just have that option (or any other way by running a command not a batch).

if you stumble into any problems i can post the current version of the batch that's been in use on my machine the last months. yeah, it's a little bit of a hack (learned a lot during creating that batch regarding DOS & batching) expecially the part around "Setlocal EnableDelayedExpansion". i would never again try to do such a thing (date arithmetics) inside batches, it's been a PITA ;)
vbs and probably every any "real" skripting language are more powerfull in that area

pvruser
2007-09-30, 05:24 AM
finally got the time to read/understand your date script. i just now realized that {MinutesToEndWithPadding} returns actual minutes till the end of the recording starting from now. i always assumed it would just contain the length of recording or smth like that.

i guess this makes it even easier for Slimm to add the new {MinutesToStart} parameter to gbpvrcli - no need to mess with new date functions :p

but until he adds it i'll use {MinutesToEndWithPadding} with some calculations. this is so much fun!

Mister Slimm
2007-10-01, 10:37 AM
{MinutesToStart} and {MinutesToStartWithPadding} tokens added. Hope this does the trick.

For information regarding features and bug fixes new to this release, please see my announcement post (http://misterslimm.wordpress.com/2007/10/01/slimm-gb-pvr-version-16283018691-released/) on my blog (http://misterslimm.wordpress.com/).

For all details regarding current version, please see documentation which is installed alongside the utility and is available in the GBPVR start menu group.

pvruser
2007-10-01, 11:46 PM
{MinutesToStart} and {MinutesToStartWithPadding} tokens added. Hope this does the trick.

For information regarding features and bug fixes new to this release, please see my announcement post (http://misterslimm.wordpress.com/2007/10/01/slimm-gb-pvr-version-16283018691-released/) on my blog (http://misterslimm.wordpress.com/).

For all details regarding current version, please see documentation which is installed alongside the utility and is available in the GBPVR start menu group.

wow great! i did update my scripts with the other variable but i'll get this new version asap!
hmm... right now i have Version: 1.6.2746.21588 with GB-PVR v0.99.12 and i was wondering if upgrading will work fine. is it still compatible with 0.99.12?

Thanks!

Mister Slimm
2007-10-02, 12:14 AM
Is it still compatible with 0.99.12?

Should be.

pvruser
2007-10-02, 11:14 PM
yes works great! added it to the script instead of K.S.'s calculations (though still using the for to get the tokens).
i'll probably need to refine it a bit but for now it serves its purpose :D

thanks again!

K.S.
2007-10-04, 03:54 PM
yes works great! added it to the script instead of K.S.'s calculations (though still using the for to get the tokens).

shame on you! you've dared to drop my hack in favor of a newly-built-in feature! :D
glad you found the time to muse over my batch, it's the fun part where you learn something new ;)

pvruser
2007-10-05, 01:56 AM
i know it can be improved but anyway here's my PostProcessing.bat script:



@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
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 fox2 == 80
if "%2" == "80" call :s_720p2sd %1
rem cw50 == 87
if "%2" == "87" call :s_1080i2sd %1
rem cbs62 == 91
if "%2" == "91" call :s_1080i2sd %1

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 make sure other ffmpeg tasks NOT running before shutting down
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}#{MinutesToEndWithPaddi ng}#{RecordingLengthWithPadding}#{StartTimeWithPad ding}#{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%
del "%~dpn1running.txt"
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%
type "%~dpn1running.txt" >> %logfile%
del "%~dpn1running.txt"
type %checkfile% >> %logfile%
del %checkfile%

date /t >> %logfile%
time /t >> %logfile%

goto end


rem sub for converting 720p to sd (remove side pillars)
:s_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 -b 4000k -ab 128k -r 29.97 -s 1024x490 -f svcd -cropleft 160 -cropright 160 -croptop 10 -aspect 4:3 -async 15 -threads 8 "%~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)
:s_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 -b 4000k -ab 128k -r 29.97 -s 1184x500 -f svcd -cropleft 240 -cropright 240 -croptop 20 -aspect 4:3 -async 15 -threads 8 "%~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%
del "%~dpn1running.txt"
del %checkfile%

goto end


:end