Hi please, in the 25fps case
of the attached c0029.wav file
I have try
for /f "tokens=1,2 delims=^=" %%g in ('FFProbe.exe -hide_banner -loglevel fatal -pretty -select_streams a:0 -show_streams "%~1"') DO ( if "%%~g"=="duration_ts" set "NumberOfFrame=%%~h")
but I don't know, seems that duration_ts and NumberOfFrame are empty![]()
+ Reply to Thread
Results 1 to 21 of 21
-
-
file attachment
it should be 234 frames, please I need of a procedure that put "234" into a variable -
I won't download it, but getting the number 234 from a 1.71MB wav file seems a bit far fetched. Maybe I'm just missing something, I'll see what the answer is in the morning.
-
"samples / second" * #seconds = # samples (audio)
"frames / second" * # seconds = # frames (video)
25fps * 9.36 = 234 check!
BUT,
"frames" is a video concept (disregarding packet and/or FFT compressed audio frame groupings which have no bearing on this).
What I think you are wanting to ask is: if I have this much time, how many frames would it line up with if I were to match it up with 25fps video?
And you are wanting to automatically generate this from the internal properties of the audio, right?
Well, you can't - not completely. There is nothing in the file that prefers one video framerate over another, nor even a place to store that data in standard WAV files (except as a custom, user-generated metadata comment/tag). And of course the "duration_ts" and "Number_of_frames" fields are empty: they don't exist for audio streams! And you don't YET have a video stream to place those field values into.
Scott -
-
mm great effort of cat but maybe I have found
Code:rem #### check duration of avi file #### 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 "%~1" 2^>^&1') DO ( if "%%~g"=="duration" set "catDuration=%%~h") echo duration is %catduration% pause
Last edited by marcorocchini; 30th Oct 2014 at 13:47.
-
but is a problem of notation:
I would like have in a variable: 9,36 or 9.36 and not 00:00:09.36
is there a way to have from ffproble, the 9.36 so I can use directly? thanks -
No, you will have to do some string processing yourself.
Understand that things which make use of frame-based timing will always use either Absolute Integer framecounts (film-based, usually), e.g. "234", or use SMPTE/EBU timecode numbering, which is designated to be "HH:MM:SS:FF" (AudioCDframes, FILM, PAL & non-drop NTSC) or "HH:MM:SS;FF" (dropframe NTSC) - note the colons & semi-colon positioning.
Things which are NOT frame-based (audio samples, some midi stuff, old-school event-based interactive media) are denoted along the lines of "HH:MM:SS.msec" (usually to the 3 full decimal places) - note the period/dot/fullstop/comma positioning.
So, ffmpeg is giving you the appropriate nomenclature/designators/notation, whether you want them that way or not.
ScottLast edited by Cornucopia; 31st Oct 2014 at 01:24.
-
This works for a single file, but is probably easily broken.
Code:@echo off for %%a in (*.wav) do ffprobe -report %%a for %%a in (*.log) do find "Duration:" <"%%a" >temp.txt for /f "tokens=1,2,3,4,* delims=:, " %%a in (temp.txt) do set length=%%d set pause del *.log *.txt
-
This is better. Multiple input files. (handles spaces in the file names)
Will still probably break
Code:::@echo off for %%a in (*.wav) do set FFREPORT=file=%%~na.log && ffprobe -report "%%a" for %%a in (*.log) do find "Duration:" <"%%a"> "%%~na.txt" && for /f "usebackq tokens=1,2,3,4,5,* delims=:," %%b in ("%%~na.txt") do set %%~na=%%e set pause del *.log *.txt
Last edited by pcspeak; 31st Oct 2014 at 01:21.
-
pcspeack sorry but only now maybe I understand that, for example, in file C0029.wav I have do extract duration (09 sec 36 millisec) and do 9.36 X 25= 234
my target is get this 234 in a batch
but notation of ffprobe/ffmpeg seems 00:00:09.36 (and not 9.36)
please is there a way to get 234 and put on a variable?
consider I'm already in a batch, and the C0029.wav become %~dp1%~n1.wav
thanks -
No.
Floating point math, to my knowledge, cannot be done in a batch file. -
-
I have integrate the ndjamena's frame count calculator to my batch, but seems to me not for all files it recognize framecount
But for example, in the case of mp4 gopro it work perfectly.
I try to modify my megabatch so that, if the this (ndjamena) don't recognize the framecount ----> another procedure get me the frame count and this procedure, I think, maybe is this of (example) do duration * 25 = 234 frames
Code:rem #### Find TimeCode Info #### Set AUCount=0; Set VDCount=0; Set STCount=0; Set "V_Number_Of_Frames=" for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\virtualdub\FFProbe -hide_banner -loglevel fatal -pretty -show_format -show_streams "%~f1" 2^>^&1') DO ( CALL :Process_Item "%%~g" "%%~h" ) if NOT "%V_Time_Base%"=="" ( for /F "tokens=1,2 delims=/" %%g in ("%V_Time_Base%") do ( set "V_Time_Base_Denom=%%~g" set /a "V_Time_Base_Num=%%~h*10000" ) ) if NOT "%V_Frame_Rate%"=="" ( for /F "tokens=1,2 delims=/" %%g in ("%V_Frame_Rate%") do ( set /a "V_Frame_Rate_Num=%%~g*10000" set "V_Frame_Rate_Denom=%%~h" ) ) if "%V_Number_Of_Frames%"=="" Set /a "V_Number_Of_Frames=V_Duration/((V_Time_Base_Num/V_Time_Base_Denom)/(V_Frame_Rate_Num/V_Frame_Rate_Denom))" set "FPSforVirtualdub=%V_Number_Of_Frames%" echo "%FPSforVirtualdub%" goto :eof :Process_Item <item_field> <item_data> if "%~2"=="N/A" goto :eof if "%~1"=="[/STREAM]" ( set "CType=" goto :eof ) if "%~1"=="[/FORMAT]" ( set "CType=" goto :eof ) if "%~1"=="[FORMAT]" ( set "CType=FORMAT" goto :eof ) if "%~1"=="index" Set "cur_index=%~2" if "%~1"=="codec_name" Set "cur_codec=%~2" if "%~1"=="codec_type" ( if "%~2"=="audio" ( set /a AUCount+=1 set "CType=audio" ) if "%~2"=="video" if NOT "%cur_codec%"=="mjpeg" ( Set /a VDCount+=1 set "CType=video" ) if "%~2"=="subtitle" ( Set /a STCount+=1 set "CType=subtitle" ) goto :eof ) if "%CType%"=="FORMAT" ( if "%~1"=="TAG:company_name" set "T_Company_Name=%~2" if "%~1"=="TAG:product_name" set "T_Product_Name=%~2" if "%~1"=="TAG:product_version" set "T_Product_Version=%~2" if "%~1"=="TAG:timecode" set "TIMECODE=%~2" goto :eof ) if "%CType%"=="video" ( if %VDCount% GTR 1 ( echo Multiple Video Streams!!!! pause ) if "%~1"=="time_base" set "V_Time_Base=%~2" if "%~1"=="r_frame_rate" set "V_Frame_Rate=%~2" if "%~1"=="duration_ts" set "V_Duration=%~2" if "%~1"=="width" set "V_Width=%~2" if "%~1"=="height" set "V_Height=%~2" if "%~1"=="sample_aspect_ratio" set "V_PAR=%~2" if "%~1"=="nb_frames" set "V_Number_Of_Frames=%~2" goto :eof ) goto :eof
-
This will give you the number you wanted in a variable.
Code:@echo off if exist "eval.vbs" goto script @echo Set objArgs = WScript.Arguments>"eval.vbs" @echo wscript.echo eval(objArgs(0))>>"eval.vbs" :script for %%a in (*.wav) do set FFREPORT=file=%%~na.log && ffprobe -report "%%a" for %%a in (*.log) do find "Duration:" <"%%a"> "%%~na.txt" && for /f "usebackq tokens=1,2,3,4,5,* delims=:," %%b in ("%%~na.txt") do for /f %%i in ('eval //nologo %%e*25') do set %%~na_count=%%i set pause del *.log *.txt *.vbs
-
thanks pcspeack, for kindness only 2 things:
1) I'm already in a batch file and I would like integrate this framecount into the batch
so my source is %4 (e.g. c:\cats\goprofile.mp4 or wav ecc.)
I have do this and seems work
Code:echo Set objArgs = WScript.Arguments>"eval.vbs" echo wscript.echo eval(objArgs(0))>>"eval.vbs" v:\automazioneclip\virtualdub\FFProbe -i %4 2>>c:\ffprobe.txt for %%a in (c:\ffprobe.txt) do find "Duration:" <"%%a"> "%%~na.txt" && for /f "usebackq tokens=1,2,3,4,5,* delims=:," %%b in ("%%~na.txt") do for /f %%i in ('eval //nologo %%e*25') do set %%~na_count=%%i
so I wonder: can the output is outputted in a variable (e.g. "thisframecountis")
3) is there a way to round the value into the lower integer? for example if the output is 144,5 frames ----> rounded is 144 ?
thanks -
echo Set objArgs = WScript.Arguments>"eval.vbs"
echo wscript.echo eval(objArgs(0))>>"eval.vbs"
v:\automazioneclip\virtualdub\FFProbe -i %4 2>>c:\ffprobe.txt
for %%a in (c:\ffprobe.txt) do find "Duration:" <"%%a"> "%%~na.txt" && for /f "usebackq tokens=1,2,3,4,5,* delims=:," %%b in ("%%~na.txt") do for /f %%i in ('eval //nologo %%e*25') do set %%~na_count=%%i
This is the variable created by my batch file.
I used WAVname_count. Please call it whatever you wish
Rounding down. I have to investigate.Last edited by pcspeak; 31st Oct 2014 at 17:31.
-
a little kindness, for what I should do I don't need that appear the "windows script host" window that report the calculated output
is enought that the output is putted on a variable, for example "fnum"
so that in the case C0029.wav ---> %fnum% = 234 (does not matter the rouding down)
then in the batch I use the %fnum% for other processes
can you do this? ^^ thanks -
To create variable %fnum%
Code:@echo off if exist "eval.vbs" goto script @echo Set objArgs = WScript.Arguments>"eval.vbs" @echo wscript.echo eval(objArgs(0))>>"eval.vbs" :script for %%a in (*.wav) do set FFREPORT=file=%%~na.log && ffprobe -report "%%a" for %%a in (*.log) do find "Duration:" <"%%a"> "%%~na.txt" && for /f "usebackq tokens=1,2,3,4,5,* delims=:," %%b in ("%%~na.txt") do for /f %%i in ('eval //nologo %%e*25') do set fnum=%%i
Last edited by pcspeak; 1st Nov 2014 at 16:41. Reason: Can't spell. :o)
-
Code:
@echo off if exist "eval.vbs" goto script @echo Set objArgs = WScript.Arguments>"eval.vbs" @echo wscript.echo eval(objArgs(0))>>"eval.vbs" :script for %%a in (*.wav) do set FFREPORT=file=%%~na.log && ffprobe -loglevel quiet -report "%%a" >nul for %%a in (*.log) do find "Duration:" <"%%a"> "%%~na.txt" && for /f "usebackq tokens=1,2,3,4,5,* delims=:," %%b in ("%%~na.txt") do for /f %%i in ('eval //nologo %%e*25') do set fnum=%%i