VideoHelp Forum




+ Reply to Thread
Results 1 to 21 of 21
  1. Hi ****
    please consider a c:\duration.txt file that contain only this text:

    0:00:35.368667

    or 00:00:35.368667

    0 hours, 0 minutes, 35 sec and 368667 millisec
    now I would like convert this value in framenumber @ 25fps

    I try:

    Code:
    for /f "tokens=1-4 delims=:," %%a in ('c:\duration.txt') do set /a "number_Of_Frames=((%%a00)*3600 + (%%b00)*60 + (%%c00) + (%%d0)/10 ) * 25 / 100"
    
    echo number_Of_Frames is %number_Of_Frames%
    but it don't work

    How can I resolve? thanks
    Quote Quote  
  2. Member
    Join Date
    May 2014
    Location
    Memphis TN, US
    Search PM
    I don't know. But 368667 milliseconds is the same thing as 368.667 seconds, or just over 6 minutes and 8 seconds all by itself. So add that to 35 seconds in your posted figure and you have a total of 6 minutes and 41.7 seconds -- or 00:06:41.667

    1000 milliseconds = 1 second. I should think that someone who lives in Europe should know what "milli" means.
    - My sister Ann's brother
    Quote Quote  
  3. because this is a unit of misure in catSecond ^^
    are slightly different
    Quote Quote  
  4. I try also put the content of txt file in a variable %waveduration% = 0:00:35.368667

    but if nececessary fot notation, I can set %waveduration% = 00:00:35.368667 (if "%%~g"=="duration" set "waveDuration=0%%~h")

    however

    Code:
      SET /a result=((1%waveduration:~0,2%00^) * 3600^) + ((1%waveduration:~3,2%00^) * 60^) + ((1%waveduration:~6,2%00^)^) + ((1%waveduration:~-2%0^)/10) * 25 / 100
    ) ELSE (SET "result=NOT defined")
    but it wont' work

    however I should get 884 from 0:00:35.368667 or 00:00:35.368667

    Quote Quote  
  5. Member
    Join Date
    May 2014
    Location
    Memphis TN, US
    Search PM
    Even if your cat-math 6 minutes and 41.667 seconds could work, at 25 frames per second you would have 10,042 frames.

    The notation you're using isn't used for video timing by anyone in the world, including cats. Video timing is stated in two ways:
    Code:
    hh.mm:ss.ms
    hh:mm:ss.frames
    25fps video plays at 40ms per frame. So if your formula were stated in the correct format, you want 25fps frames that play for 35 seconds plus 1/368667 seconds. 25fps video frames can't play for only a part of a millisecond.
    35 seconds @ 25fps = 875 frames
    0.358667 seconds = 358.667 milliseconds. If 25fps plays at 40 milliseconds per frame, you would need another 8.967 frames. There's no way you can get a fractional part of a video frame to play, so you have to settle for an additional 8 frame or an additional 9 frames. But 8.967 frames is not possible.
    875 + 8 frames = 883 frames. At 25 FPS, it will play for 35 seconds and 320 milliseconds -- or as your cats seem to have their own timing notation, 35.32 seconds
    Last edited by LMotlow; 5th Nov 2014 at 12:17.
    - My sister Ann's brother
    Quote Quote  
  6. Code:
    for /f "tokens=1-4 delims=:." %%a in (duration.txt) do set /a "number_Of_Frames=((%%a00)*3600 + (%%b00)*60 + (%%c00) + (%%d)/10000) * 25 / 100"
    echo number_Of_Frames is %number_Of_Frames%
    Quote Quote  
  7. Originally Posted by LMotlow View Post
    Even if your cat-math 6 minutes and 41.667 seconds could work, at 25 frames per second you would have 10,042 frames.

    The notation you're using isn't used for video timing by anyone in the world, including cats. Video timing is stated in two ways:
    Code:
    hh.mm:ss.ms
    hh:mm:ss.frames
    25fps video plays at 40ms per frame. So if your formula were stated in the correct format, you want 25fps frames that play for 35 seconds plus 1/368667 seconds. 25fps video frames can't play for only a part of a millisecond.
    35 seconds @ 25fps = 875 frames
    0.358667 seconds = 358.667 milliseconds. If 25fps plays at 40 milliseconds per frame, you would need another 8.967 frames. There's no way you can get a fractional part of a video frame to play, so you have to settle for an additional 8 frame or an additional 9 frames. But 8.967 frames is not possible.
    875 + 8 frames = 883 frames. At 25 FPS, it will play for 35 seconds and 320 milliseconds -- or as your cats seem to have their own timing notation, 35.32 seconds
    mm a little complicated to understand for cats, hoewver I get the "duration" with:

    Code:
      for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\virtualdub\FFProbe -hide_banner -loglevel fatal -pretty  -show_streams -show_entries stream^=codec_type^,duration^,r_frame_rate^,width^,height^,sample_aspect_ratio:stream_disposition^=:format_tags^=timecode^,company_name^,product_name^,product_version "%~dp1%~n1_gen_SD.wav" 2^>^&1') DO (
           if "%%~g"=="duration" set "waveDuration=0%%~h")          	 
    
           echo waveduration is %waveduration%
    I don't know is right this duration string
    Quote Quote  
  8. thanks jagabo
    Quote Quote  
  9. Originally Posted by jagabo View Post
    Code:
    for /f "tokens=1-4 delims=:." %%a in (duration.txt) do set /a "number_Of_Frames=((%%a00)*3600 + (%%b00)*60 + (%%c00) + (%%d)/10000) * 25 / 100"
    echo number_Of_Frames is %number_Of_Frames%
    thanks, it seems working

    only a thing: and if instead of the .txt I have the duration value in %waveduration% how can I put it on the command?

    I have try:

    Code:
     for /f "tokens=1-4 delims=:." %%a in ('%waveduration%') do set /a "number_Of_Frames=((%%a00)*3600 + (%%b00)*60 + (%%c00) + (%%d)/10000) * 25 / 100"
           echo number_Of_Frames is %number_Of_Frames%
    but shure I mistake, how can i modify it?
    Quote Quote  
  10. Set /p waveduration=Enter Duration.

    If you need to correct a mistake create a loop to confirm the entry before you commit

    Code:
    :Test
    Set /p waveduration=Enter Duration
    cls
    echo.
    echo.
    echo The duration you entered is %waveduration%
    echo.
    set /p Te$t=Is this correct, y or n
    if not %Te$t%*=y* goto :Test
    Or you can combine TXT file and manual override

    Code:
    goto :Check
    :Test
    Set /p waveduration=Enter Duration
    echo %waveduration%>duration.txt
    :Check
    cls
    echo.
    echo.
    echo The duration is %waveduration%
    echo.
    set /p Te$t=Is this correct, y or n
    if not %Te$t%*=y* goto :Test
    And follow through with Jagabo's code. If there is no TXT file you will be given the chance to enter a value and a TXT file will be created.
    Last edited by nic2k4; 5th Nov 2014 at 13:54.
    Quote Quote  
  11. set /p ?
    Quote Quote  
  12. mmmmm

    set /p "number_Of_Frames"?
    Quote Quote  
  13. Originally Posted by LMotlow View Post
    Even if your cat-math 6 minutes and 41.667 seconds could work, at 25 frames per second you would have 10,042 frames.

    The notation you're using isn't used for video timing by anyone in the world, including cats. Video timing is stated in two ways:
    Code:
    hh.mm:ss.ms
    hh:mm:ss.frames
    25fps video plays at 40ms per frame. So if your formula were stated in the correct format, you want 25fps frames that play for 35 seconds plus 1/368667 seconds. 25fps video frames can't play for only a part of a millisecond.
    35 seconds @ 25fps = 875 frames
    0.358667 seconds = 358.667 milliseconds. If 25fps plays at 40 milliseconds per frame, you would need another 8.967 frames. There's no way you can get a fractional part of a video frame to play, so you have to settle for an additional 8 frame or an additional 9 frames. But 8.967 frames is not possible.
    875 + 8 frames = 883 frames. At 25 FPS, it will play for 35 seconds and 320 milliseconds -- or as your cats seem to have their own timing notation, 35.32 seconds
    mmmm

    Click image for larger version

Name:	OHM.jpg
Views:	403
Size:	137.6 KB
ID:	28394
    Quote Quote  
  14. Originally Posted by nic2k4 View Post
    Set /p waveduration=Enter Duration.

    If you need to correct a mistake create a loop to confirm the entry before you commit

    Code:
    :Test
    Set /p waveduration=Enter Duration
    cls
    echo.
    echo.
    echo The duration you entered is %waveduration%
    echo.
    set /p Te$t=Is this correct, y or n
    if not %Te$t%*=y* goto :Test
    Or you can combine TXT file and manual override

    Code:
    goto :Check
    :Test
    Set /p waveduration=Enter Duration
    echo %waveduration%>duration.txt
    :Check
    cls
    echo.
    echo.
    echo The duration is %waveduration%
    echo.
    set /p Te$t=Is this correct, y or n
    if not %Te$t%*=y* goto :Test
    And follow through with Jagabo's code. If there is no TXT file you will be given the chance to enter a value and a TXT file will be created.
    ah ok, but really, I need to batch automate. Possibly I would like do a script that don't need a manual input and that calculate the correct value, a part the case of %duration%==""

    so that if %duration%=="" -->goto :eof and pause
    Quote Quote  
  15. Originally Posted by marcorocchini View Post
    so that if %duration%=="" -->goto :eof and pause
    Should be "%duration%"==""

    Code:
    if exist duration.txt goto :Next
    :Test
    Set /p waveduration=Enter Duration
    echo %waveduration%>duration.txt
    cls
    echo.
    echo.
    echo The duration is %waveduration%
    echo.
    set /p Te$t=Is this correct, y or n
    if not %Te$t%*=y* goto :Test
    :Next
    Obviously your requirement for total automation takes away any correction possibility (if there's a TXT file).
    Quote Quote  
  16. Originally Posted by nic2k4 View Post
    Originally Posted by marcorocchini View Post
    so that if %duration%=="" -->goto :eof and pause
    Should be "%duration%"==""

    ops, I have the cat's paw when I type in the keyboard ^^
    Quote Quote  
  17. Actually, I think it's a bit ugly to append a couple zeros to the values. I'd just multiply by an extra 100:

    Code:
    for /f "tokens=1-4 delims=:." %%a in (duration.txt) do set /a "number_Of_Frames=((%%a)*360000 + (%%b)*6000 + (%%c)*100 + (%%d)/10000) * 25 / 100"
    Or if you wanted to be more explicit:

    Code:
    for /f "tokens=1-4 delims=:." %%a in (duration.txt) do set /a "number_Of_Frames=((%%a)*100*3600 + (%%b)*100*60 + (%%c)*100 + (%%d)*100/1000000) * 25 / 100"
    Using an environment variable rather than a file:

    Code:
    for /F "tokens=1-4 delims=:." %%a in ("%DURATION%") do set /a "number_Of_Frames=((%%a)*100*3600 + (%%b)*100*60 + (%%c)*100 + (%%d)*100/1000000) * 25 / 100"
    One caveat: This code treats the digits to the right of the decimal point as microseconds. And it requires that there be six digits. If a program reports the time with fewer or more digits to the right of the decimal place the calculation will be wrong.
    Last edited by jagabo; 6th Nov 2014 at 10:57.
    Quote Quote  
  18. Image
    [Attachment 28394 - Click to enlarge]

    maybe this (working in windows 32)

    Code:
    set "wavDuration=0:09:35.368667"
    
    for /f  "tokens=1-4 delims=:."  %%a in ('echo %wavDuration%') do (
    for /f "delims=" %%x in ('powershell ^(0.%%d + ^(%%a * 3600^) + ^(%%b * 60^) + %%c^)*25') do Set "FrameCountAudio=%%x")
    
    echo return FrameCount is %FrameCountAudio%
    Quote Quote  
  19. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Dear god... I've been meaning to tell you to use Powershell instead of damn batch, you can set ffprobe AND MediaInfoCLI to output in xml format and load them AS xml structures in Powershell.

    In fact, as I clicked on this thread I was planning on just writing "POWERSHELL" and walking away, or maybe I'd have just left a link to the Powershell section of SS64.com...

    I do some pretty stupid things with batch, but even I know when to switch to a better language.
    Quote Quote  
  20. Originally Posted by ndjamena View Post
    Dear god...

    Dear CAT please !!
    Quote Quote  
  21. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    "C:\Windows\System32\WindowsPowerShell\v1.0\powers hell_ise.exe"

    If I had a god, it wouldn't be a damn cat!
    Quote Quote  
Visit our sponsor! Try DVDFab and backup Blu-rays!