Results 1 to 5 of 5

Thread: Help with batch file

  1. #1
    Join Date
    Aug 2016
    Location
    Davis, CA
    Posts
    17

    Help with batch file

    Below is my batch file. To be clear I modified a batch file from the NPVR wiki created by javawiz. I use it to specify different ini files for different channels. I want to have an ini for football games. I often watch one game live while recording another and it would be great to have the commercials processed when I watch the second game. The channel specific ini are ok but the football specific one does a better more reliable job on detecting show vs commercial. However, when I remove the REM for the football if statement all I get is notification the recording is complete and comskip is NOT run on the file no matter what type of program I record.

    I was contemplating using the same approach to having show specific ini but now it seems my approach doesn't work or at least I don't know how to make it work. Also below is the log, I've been recording random shows for testing purposes but the make a change wait 30-60 minutes and see if it works approach isn't going so well so I am asking for help.

    Thanks,

    Craig

    @Echo off
    GoTo :BEGIN
    ================================================== ===============================================
    PostProcessing.bat
    Run as soon as a recording ends. Commonly used for adding commercial skipping functionality
    (comskip) or transcoding.
    -------------------------------------------------------------------------------------------------
    Arguments:
    1.filename - the full path and file name of the recording file.
    2.channelNumber - the channel number it was recorded from.
    3.oid - unique identifier to the scheduled_recordings table, applicable even if
    filename (%1) changes
    4.capture Oid - unique identifier to the device used for recording
    5.recording title - the title of the recording
    6.comskip ini - the name of the comskip ini file for commercial skip
    -------------------------------------------------------------------------------------------------
    Modification History
    Date By Description
    ------ ---------- -------------------------------------------------------------------------------
    11132017 CD Initial Template
    ================================================== ===============================================
    :BEGIN
    SETLOCAL
    Set SCRIPTNAME=%0
    Set BASEDIR=c:\Users\Public\NPVR
    Set LOGFILE=%BASEDIR%\Logs\PostProcessing.log

    Set FILENAME=%1
    Set CH_NUM=%2
    Set OID=%3
    Set DEV_OID=%4
    Set REC_TITLE=%5

    Call :LOGMSG Recording complete - filename: %FILENAME% ChannelNUM: %CH_NUM% OID: %OID% DeviceOID: %DEV_OID% Title: %REC_TITLE%

    cd /d "C:\comskip"

    if "%2" == "6.1" goto skip
    if "%2" == "6.2" goto skip
    if "%2" == "6.3" goto skip
    goto next

    :skip:
    echo skipping comskip on %1; channel %2 because it is in skip list >> %LOGFILE%
    goto continue

    :next

    rem if "%5" == "Football" goto Football
    rem if "%5" == "College Football" goto Football
    if "%2" == "3.1" goto channel_3.1
    if "%2" == "10.1" goto channel_10.1
    if "%2" == "13.1" goto channel_13.1
    if "%2" == "40.1" goto channel_40.1
    goto generic



    :channel_3.1

    echo %date%,%time% - invoking comskip on %1 channel %2 ini >> %LOGFILE%
    comskip --ini=channel_3.1.ini %1
    echo %date%,%time% - comskip finished with %1 channel %2 ini >> %LOGFILE%
    goto continue

    :channel_10.1

    echo %date%,%time% - invoking comskip on %1 channel %2 ini >> %LOGFILE%
    comskip --ini=channel_10.1.ini %1
    echo %date%,%time% - comskip finished with %1 channel %2 ini >> %LOGFILE%
    goto continue

    :channel_13.1

    echo %date%,%time% - invoking comskip on %1 channel %2 ini >> %LOGFILE%
    comskip --ini=channel_13.1.ini %1
    echo %date%,%time% - comskip finished with %1 channel %2 ini >> %LOGFILE%
    goto continue

    :channel_40.1

    echo %date%,%time% - invoking comskip on %1 channel %2 ini >> %LOGFILE%
    comskip --ini=channel_40.1.ini %1
    echo %date%,%time% - comskip finished with %1 channel %2 ini >> %LOGFILE%
    goto continue

    :Football

    echo %date%,%time% - invoking comskip on %1 channel %2 ini >> %LOGFILE%
    comskip --ini=Football.ini %1
    echo %date%,%time% - comskip finished with %1 channel %2 ini >> %LOGFILE%
    goto continue


    :generic

    echo %date%,%time% - invoking comskip on %1 >> %LOGFILE%
    comskip %1
    echo %date%,%time% - comskip finished with %1 >> %LOGFILE%

    :continue

    :eof

    GoTo :EXITJOB

    --------------------------------------------------------------
    :LOGMSG
    echo %*
    echo %date:~4% %time% %* >> %LOGFILE%
    rem echo %date:~4% %time% [%SCRIPTNAME%] %* >> %LOGFILE%
    Goto :EOF

    --------------------------------------------------------------
    :EXITJOB
    Exit /b


    Below is the output logfile

    12/05/2017 10:00:01.37 Recording complete - filename: "D:\Loving Spoonfuls\Loving.Spoonfuls.S03E08.Yvonne,.JFK.and. the.Rabbit.ts" ChannelNUM: 29.3 OID: 22744 DeviceOID: 20 Title: "Loving Spoonfuls"
    Tue 12/05/2017,10:00:01.38 - invoking comskip on "D:\Loving Spoonfuls\Loving.Spoonfuls.S03E08.Yvonne,.JFK.and. the.Rabbit.ts"
    Tue 12/05/2017,10:00:56.67 - comskip finished with "D:\Loving Spoonfuls\Loving.Spoonfuls.S03E08.Yvonne,.JFK.and. the.Rabbit.ts"
    12/05/2017 10:01:00.48 Recording complete - filename: "D:\ABC 10 News Mornings at 9am\ABC 10 News Mornings at 9am_20171205_09001000.ts" ChannelNUM: 10.1 OID: 22743 DeviceOID: 22 Title: "ABC 10 News Mornings at 9am *"
    Tue 12/05/2017,10:01:00.49 - invoking comskip on "D:\ABC 10 News Mornings at 9am\ABC 10 News Mornings at 9am_20171205_09001000.ts" channel 10.1 ini
    Tue 12/05/2017,10:06:16.91 - comskip finished with "D:\ABC 10 News Mornings at 9am\ABC 10 News Mornings at 9am_20171205_09001000.ts" channel 10.1 ini
    12/05/2017 10:31:00.99 Recording complete - filename: "D:\Global 3000\Global 3000_20171205_10001030.ts" ChannelNUM: 6.3 OID: 22745 DeviceOID: 20 Title: "Global 3000"
    skipping comskip on "D:\Global 3000\Global 3000_20171205_10001030.ts"; channel 6.3 because it is in skip list


    Below is after removing the rem from the batch file.

    12/05/2017 11:01:00.72 Recording complete - filename: "D:\The View\The View_20171205_10001100.ts" ChannelNUM: 10.1 OID: 22746 DeviceOID: 22 Title: "The View"
    12/05/2017 11:01:00.78 Recording complete - filename: "D:\Priscillas Yoga Stretches\Priscillas Yoga Stretches_20171205_10451100.ts" ChannelNUM: 6.2 OID: 22747 DeviceOID: 20 Title: "Priscilla's Yoga Stretches"
    skipping comskip on "D:\Priscillas Yoga Stretches\Priscillas Yoga Stretches_20171205_10451100.ts"; channel 6.2 because it is in skip list

  2. #2
    Join Date
    Apr 2006
    Location
    United States - Massachusetts
    Posts
    386
    If you look at the output from your logfile, you'll see that the Title already has double quotes. When you have 'if "%5" == ', that gets treated as 'if ""The View"" == '. You could probably just remove the double quotes from around the %5.
    Tuners: Ceton InfiniTV quad cable card tuner (PCIe). SD HDHR Connect Quatro Tuner (HDHR5-4US). Use only QAM on HDHR. HDPVR - for Fox owned channels.
    Viewing: Usually an NMT connected via MoCA. Sometimes directly on the server below. Sometimes when I travel I use an NMT served from my laptop with a portable hard-drive.
    EPG: XML from SchedulesDirect via MC2XML
    Provider: Verizon Fios
    Server: Dell XPS 8700 with Windows 8.1

  3. #3
    Join Date
    Dec 2006
    Location
    St. Johns, Florida USA
    Posts
    2,396
    Made a few updates to your version for simplification, I've lightly tested this but not sure that it's 100%

    Code:
    @Echo off
    GoTo :BEGIN
    ================================================== ===============================================
    PostProcessing.bat 
    Run as soon as a recording ends. Commonly used for adding commercial skipping functionality 
    (comskip) or transcoding. 
    -------------------------------------------------------------------------------------------------
    Arguments: 
    1.filename - the full path and file name of the recording file. 
    2.channelNumber - the channel number it was recorded from. 
    3.oid - unique identifier to the scheduled_recordings table, applicable even if 
    filename (%1) changes 
    4.capture Oid - unique identifier to the device used for recording 
    5.recording title - the title of the recording 
    6.comskip ini - the name of the comskip ini file for commercial skip
    -------------------------------------------------------------------------------------------------
    Modification History
    Date By Description
    ------ ---------- -------------------------------------------------------------------------------
    11132017 CD Initial Template
    ================================================== ===============================================
    :BEGIN
        SETLOCAL
        Set SCRIPTNAME=%0
        Set BASEDIR=c:\Users\Public\NPVR
        Set LOGFILE=%BASEDIR%\Logs\PostProcessing.log
    
        Set FILENAME=%1
        Set CH_NUM=%2
        Set OID=%3
        Set DEV_OID=%4
        Set REC_TITLE=%5
    
        Call :LOGMSG Recording complete - filename: %FILENAME% ChannelNUM: %CH_NUM% OID: %OID% DeviceOID: %DEV_OID% Title: %REC_TITLE%
    
        cd /d "C:\comskip"
        Call :LOGMSG Channel skip check...
        if "%CH_NUM%" == "6.1" GoTo :CHANNEL_SKIP
        if "%CH_NUM%" == "6.2" GoTo :CHANNEL_SKIP
        if "%CH_NUM%" == "6.3" GoTo :CHANNEL_SKIP
    
        Call :LOGMSG Football check...
        if %REC_TITLE% == "Football"           GoTo :FOOTBALL
        if %REC_TITLE% == "College Football"   GoTo :FOOTBALL
    
        Call :LOGMSG Specific channel check...
        if "%CH_NUM%" == "3.1"  GoTo :CHANNEL_SPECIFIC
        if "%CH_NUM%" == "10.1" GoTo :CHANNEL_SPECIFIC
        if "%CH_NUM%" == "13.1" GoTo :CHANNEL_SPECIFIC
        if "%CH_NUM%" == "40.1" GoTo :CHANNEL_SPECIFIC
    
     :DEFAULT
        Call :LOGMSG Default Comskip selected...
        Call :COMSKIP 
        GoTo :EXITJOB
        
    :CHANNEL_SKIP
        Call :LOGMSG - skipping comskip on %FILENAME%; channel %CH_NUM% because it is in skip list
        GoTo :EXITJOB
    
    :CHANNEL_SPECIFIC
        Call :COMSKIP CHANNEL_%CH_NUM%.ini
        GoTo :EXITJOB
     
    :FOOTBALL
        Call :COMSKIP Football.ini
        GoTo :EXITJOB
    
    -------------------------------------------------------------- 
    :COMSKIP
        if %1.==. (
            Set iniFile=
        ) else (
            Set iniFile=--ini=%1
        )
        Call :LOGMSG - invoking comskip on %FILENAME%  %iniFile%
        comskip %FILENAME% %iniFile%
        Call :LOGMSG - comskip finished with %FILENAME% 
        GoTO :EOF
    
    -------------------------------------------------------------- 
    :LOGMSG
        echo %*
        echo %date:~4% %time% %* >> %LOGFILE%
        rem echo %date:~4% %time% [%SCRIPTNAME%] %* >> %LOGFILE%
        GoTo :EOF
    
    -------------------------------------------------------------- 
    :EXITJOB
    Exit /b
    NPVR Server: Win10 / AMD Phenom II X4 965 / 8gRAM / ATI Radeon 7700 Series / Hauppauge 2250
    Misc: HDHR Prime, rPI LibreElec & Amazon FireStick Kodi clients

  4. #4
    Join Date
    Aug 2016
    Location
    Davis, CA
    Posts
    17
    I believe you are onto something. I removed the double quotes and it appears to be working though I won't know for sure until I record a football game.

    JavaWiz went above and beyond and rewrote a custom batch file.

  5. #5
    Join Date
    Aug 2016
    Location
    Davis, CA
    Posts
    17
    JavaWiz,

    Wow, I sort of understand your upgrade. Pretty impressive. I spent way more time over the past 2 days accomplishing next to nothing and you rewrote the code in no time. Best I stick to my day job.

    Just recorded a PBS channel thus no comskip and a regular channel. Both processed appropriately with log entries.

    I really appreciate your help.

    Thanks,

    Craig
    Last edited by CDinger; 2017-12-06 at 05:06 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •