VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Hi

    and however


    I'm inside a batch where I get the video duration in a string called %aviGenDuration%

    Code:
    FFProbe.exe -loglevel fatal -show_entries format=duration -of csv="p=0" -sexagesimal "%~nx1.ts">aviGenDuration.txt   
    
    set /p aviGenDuration=<aviGenDuration.txt
    for example the result is:

    Code:
    0:01:30.680000
    I wonder how can I do a mathematical subtraction so that the result is 4 millisecond less than the result. In this case the final result have to be
    Code:
    0:01:30.640000
    is there a way? thanks
    Quote Quote  
  2. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    You must parse it into its elements, convert from string to numerical, build it up into one figure of the smallest element, do the math, convert back to string, then re-separate into segments with delimiters re-added in. DONE.


    Scott
    Quote Quote  
  3. This is the clearest example I've found.

    https://stackoverflow.com/questions/605522/print-time-in-a-batch-file-milliseconds

    Code:
    @echo off
    setlocal
    
    rem The format of %TIME% is HH:MM:SS,CS for example 23:59:59,99
    set STARTTIME=%TIME%
    
    rem here begins the command you want to measure
    dir /s > nul
    rem here ends the command you want to measure
    
    set ENDTIME=%TIME%
    
    rem output as time
    echo STARTTIME: %STARTTIME%
    echo ENDTIME: %ENDTIME%
    
    rem convert STARTTIME and ENDTIME to centiseconds
    set /A STARTTIME=(1%STARTTIME:~0,2%-100)*360000 + (1%STARTTIME:~3,2%-100)*6000 + (1%STARTTIME:~6,2%-100)*100 + (1%STARTTIME:~9,2%-100)
    set /A ENDTIME=(1%ENDTIME:~0,2%-100)*360000 + (1%ENDTIME:~3,2%-100)*6000 + (1%ENDTIME:~6,2%-100)*100 + (1%ENDTIME:~9,2%-100)
    
    rem calculating the duratyion is easy
    set /A DURATION=%ENDTIME%-%STARTTIME%
    
    rem we might have measured the time inbetween days
    if %ENDTIME% LSS %STARTTIME% set set /A DURATION=%STARTTIME%-%ENDTIME%
    
    rem now break the centiseconds down to hors, minutes, seconds and the remaining centiseconds
    set /A DURATIONH=%DURATION% / 360000
    set /A DURATIONM=(%DURATION% - %DURATIONH%*360000) / 6000
    set /A DURATIONS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000) / 100
    set /A DURATIONHS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000 - %DURATIONS%*100)
    
    rem some formatting
    if %DURATIONH% LSS 10 set DURATIONH=0%DURATIONH%
    if %DURATIONM% LSS 10 set DURATIONM=0%DURATIONM%
    if %DURATIONS% LSS 10 set DURATIONS=0%DURATIONS%
    if %DURATIONHS% LSS 10 set DURATIONHS=0%DURATIONHS%
    
    rem outputing
    echo STARTTIME: %STARTTIME% centiseconds
    echo ENDTIME: %ENDTIME% centiseconds
    echo DURATION: %DURATION% in centiseconds
    echo %DURATIONH%:%DURATIONM%:%DURATIONS%,%DURATIONHS%
    
    endlocal
    goto :EOF
    Unfortunately it's only precise to 2 decimal places. It should be pretty easy to modify to 3 (or more).
    Quote Quote  
  4. interesting ***

    but maybe my specific question is well explained here:
    https://forum.videohelp.com/threads/406954-How-to-get-the-wav-pcm_s16-from-this-mp4

    thanks
    Quote Quote  
  5. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    No clearer than the original question, both of which have been answered multiple times (by me, genericly, and by jack_666 and jagabo specificly).

    Scott
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!