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:
but it don't workCode: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%
How can I resolve? thanks
+ Reply to Thread
Results 1 to 21 of 21
-
-
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 -
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
but it wont' workCode: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")
however I should get 884 from 0:00:35.368667 or 00:00:35.368667
-
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:
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.Code:hh.mm:ss.ms hh:mm:ss.frames
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 secondsLast edited by LMotlow; 5th Nov 2014 at 13:17.
- My sister Ann's brother -
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%
-
mm a little complicated to understand for cats, hoewver I get the "duration" with:
I don't know is right this duration stringCode: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% -
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:
but shure I mistake, how can i modify it?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% -
Set /p waveduration=Enter Duration.
If you need to correct a mistake create a loop to confirm the entry before you commit
Or you can combine TXT file and manual overrideCode::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
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.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
Last edited by nic2k4; 5th Nov 2014 at 14:54.
-
-
Should be "%duration%"==""
Obviously your requirement for total automation takes away any correction possibility (if there's a TXT file).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
-
-
Actually, I think it's a bit ugly to append a couple zeros to the values. I'd just multiply by an extra 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)*360000 + (%%b)*6000 + (%%c)*100 + (%%d)/10000) * 25 / 100"
Using an environment variable rather than a file: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"
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.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"Last edited by jagabo; 6th Nov 2014 at 11:57.
-
[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% -
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. -
"C:\Windows\System32\WindowsPowerShell\v1.0\powers hell_ise.exe"
If I had a god, it wouldn't be a damn cat!



Quote

