dynamitemedia Posted March 4, 2015 Share Posted March 4, 2015 Sorry, I misunderstood who was asking the question. You asked a question of wakillon who last posted in this topic over 4 years ago. My experience is with Media Info, not ffprobe. Going by your last line in Post #11 format_duration="22.168000" You could just use StringSplit with a double quote. $line = 'format_duration="22.168000"' $duration = StringSplit($line, '"') $duration = $duration[2] this is what is coming back in console for script tho: format_duration="22.168000" format_tags_length="25992064" format_tags_language="eng" format_tags_timescale="48000" format_tags_sampletype="mp4a" format_tags_audiochannels="2" format_tags_videoframerate="25" format_tags_aacaot="2" format_tags_avclevel="30" format_tags_avcprofile="66" format_tags_frameWidth="876" format_tags_frameHeight="480" format_tags_displayWidth="853" format_tags_displayHeight="480" format_tags_moovposition="57041862" format_tags_encoder="Lavf56.12.103" Link to comment Share on other sites More sharing options...
iamtheky Posted March 4, 2015 Share Posted March 4, 2015 (edited) my original ffmpeg answer still works for me (tested just now on mp3, avi, and flv) even if it didnt for the OP 4 years ago. Here it is straight from the console rather than using a pipe #include <AutoItConstants.au3> Global $sFile = FileOpenDialog("Pick Media" , @ScriptDir & "\" , "ALL (*.*)") If @Error Then exit $sCommands = "ffmpeg -i " & '"' & $sFile & '"' $iPID = Run("cmd /c " & $sCommands, @ScriptDir , @SW_SHOW , $stderr_child + $stdout_child) $sOutput = "" While 1 $sOutput &= StderrRead($iPID) If @error Then ; Exit the loop if the process closes or StderrRead returns an error. ExitLoop EndIf WEnd msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)[0]) Edited March 4, 2015 by boththose dynamitemedia 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 4, 2015 Share Posted March 4, 2015 hey fellow, you can use StringRegExp for the job #include <Array.au3> $aRex=StringRegExp($stdout,'^(.+?)="(.+?)$"',3) local $aOutput[1][2] For $i = 0 to ubound($aRex)-1 Step 2 Redim $aOutput[$i/2+1][2] $aOutput[$i/2][0]=$aRex[$i] $aOutput[$i/2][1]=$aRex[$i+1] Next _ArrayDisplay($aOutput) Exit This Is not bring back anything at all either.... here is the code: Global $recordings = @ScriptDir & "\www\recordings" Global $ffprobe = @ScriptDir & "\www\bin\ffprobe.exe" $rName = "World of Martial Arts Television_11_11_02_32_2014.flv" $rVideo = $recordings & "\" & $rName $ffmpegProbe = '"' & $ffprobe & '" -v error -show_format -of flat=s=_ -show_entries format=duration "'& $rVideo &'" ' $command = 'cmd /k "' & $ffmpegProbe & '" ' ;local $PID = Run($command, @ScriptDir, @SW_show, $STDERR_CHILD) ;$line = StdoutRead($PID) ;read stdout local $PID = Run($command, @ScriptDir, @SW_show, $STDERR_CHILD) $stdout = StdoutRead($PID) ;read stdout $aRex=StringRegExp($stdout,'^(.+?)="(.+?)$"',3) local $aOutput[1][2] For $i = 0 to ubound($aRex)-1 Step 2 Redim $aOutput[$i/2+1][2] $aOutput[$i/2][0]=$aRex[$i] $aOutput[$i/2][1]=$aRex[$i+1] Next _ArrayDisplay($aOutput) Exit In the console i am getting this: format_duration="22.168000" format_tags_length="25992064" format_tags_language="eng" format_tags_timescale="48000" format_tags_sampletype="mp4a" format_tags_audiochannels="2" format_tags_videoframerate="25" format_tags_aacaot="2" format_tags_avclevel="30" format_tags_avcprofile="66" format_tags_frameWidth="876" format_tags_frameHeight="480" format_tags_displayWidth="853" format_tags_displayHeight="480" format_tags_moovposition="57041862" format_tags_encoder="Lavf56.12.103" Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 4, 2015 Share Posted March 4, 2015 my original ffmpeg answer still works for me (tested just now on mp3, avi, and flv) even if it didnt for the OP 4 years ago. Here it is straight from the console rather than using a pipe #include <AutoItConstants.au3> Global $sFile = FileOpenDialog("Pick Media" , @ScriptDir & "\" , "ALL (*.*)") If @Error Then exit $sCommands = "ffmpeg -i " & '"' & $sFile & '"' $iPID = Run("cmd /c " & $sCommands, @ScriptDir , @SW_SHOW , $stderr_child + $stdout_child) $sOutput = "" While 1 $sOutput &= StderrRead($iPID) If @error Then ; Exit the loop if the process closes or StderrRead returns an error. ExitLoop EndIf WEnd msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)[0]) LOVE it! thanks But what i am having issues doing when my ffmpeg is not in same folder and my script looks like this: Global $ffmpeg = @ScriptDir & "\www\bin\ffmpeg.exe" Global $recordings = @ScriptDir & "\www\recordings" $rName = "World of Martial Arts Television_11_11_02_32_2014.flv" $rVideo = $recordings & "\" & $rName $sCommands = '"' & $ffmpeg & '" -i "'& $rVideo &'" ' $iPID = Run("cmd /c " & $sCommands, @ScriptDir , @SW_SHOW , $STDERR_CHILD + $stdout_child) $sOutput = "" While 1 $sOutput &= StderrRead($iPID) If @error Then ; Exit the loop if the process closes or StderrRead returns an error. ExitLoop EndIf WEnd msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)[0]) i get the following error: ==> Variable used without being declared $iPID = Run("cmd /c " & $sCommands, @ScriptDir , @SW_SHOW , $STDERR_CHILD + $stdout_child) $iPID = Run("cmd /c " & $sCommands, @ScriptDir , @SW_SHOW , ^ ERROR Link to comment Share on other sites More sharing options...
iamtheky Posted March 4, 2015 Share Posted March 4, 2015 that variable is declared in autoitconstants. I would guess you left off the include line... ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 4, 2015 Share Posted March 4, 2015 that variable is declared in autoitconstants. I would guess you left off the include line... i added #include <AutoItConstants.au3> and now i get this error: ==> Subscript used on non-accessible variable.: msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)[0]) msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)^ ERROR >Exit code: 1 Time: 0.3011 Link to comment Share on other sites More sharing options...
iamtheky Posted March 5, 2015 Share Posted March 5, 2015 (edited) While your testing stuff, msgbox $sOutput prior to the regex, you may find cases where duration is not returned, maybe some where there is just a start and end, I'm sure you have a variety to look at. it certainly needs some error checking. Maybe if $sOutput still equals an empty string then msgbox that duration was not found. If duration is there confirm the format of the string. if it has the colons and the dot and still fails the regex then the hunt is on. Edited March 5, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 5, 2015 Share Posted March 5, 2015 (edited) when i use your code and search for the video file it works... as in Gives me a duration in msgbox when i hard code where it is located, it gives that error.... I also checked to see if it was cause ffmpeg was in another folder by putting in same dir and still same issue Edited March 5, 2015 by dynamitemedia Link to comment Share on other sites More sharing options...
iamtheky Posted March 5, 2015 Share Posted March 5, 2015 (edited) Global $ffmpeg = @ScriptDir & "\www\bin\ffmpeg.exe" Global $recordings = @ScriptDir & "\www\recordings" $rName = "World of Martial Arts Television_11_11_02_32_2014.flv" $rVideo = $recordings & "\" & $rName $FFmpeg = FileGetShortName($FFmpeg) $rVideo = FileGetShortName($rVideo) $sCommands = $FFmpeg & " -i " & '"' & $rVideo & '"' $iPID = Run("cmd /c " & $sCommands, @ScriptDir , @SW_SHOW , $stderr_child + $stdout_child) $sOutput = "" While 1 $sOutput &= StderrRead($iPID) If @error Then ; Exit the loop if the process closes or StderrRead returns an error. ExitLoop EndIf WEnd msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)[0]) Its totally something to do with spaces in a path, but rather than play with quotation configurations, just 8.3 the names and drive on. Edited March 5, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 5, 2015 Share Posted March 5, 2015 yesp still same thing.... have you tested there at all? again the fileopen works just fine on same file... is it a error in the ffmpeg line? Link to comment Share on other sites More sharing options...
iamtheky Posted March 5, 2015 Share Posted March 5, 2015 I saw the issue when i placed ffmpeg and the target in paths with spaces, it went way with filegetshortname. **though you may have been typing during my edit ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 5, 2015 Share Posted March 5, 2015 I saw the issue when i placed ffmpeg and the target in paths with spaces, it went way with filegetshortname. **though you may have been typing during my edit ha prob was! still getting same error I HATE the quotes in autoit, they mess me up for hours sometimes lol Link to comment Share on other sites More sharing options...
iamtheky Posted March 5, 2015 Share Posted March 5, 2015 (edited) with the latest code can you post the contents of a consolewrite($sOutput), in lieu of the msgbox? Edited March 5, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 5, 2015 Share Posted March 5, 2015 with the latest code can you post the contents of a consolewrite($sOutput), in lieu of the msgbox? Not sure what ya mean? i got the quotes around the ffmpeg so they are quoated $sCommands = '"' & $FFmpeg & '" -i "' & $rVideo & '"' ConsoleWrite($sCommands & @CRLF) shows this in console window: "C:\Documents and Settings\admin\Desktop\Ffmpeg tests\www\bin\ffmpeg.exe" -i "C:\Documents and Settings\admin\Desktop\Ffmpeg tests\www\recordings\World of Martial Arts Television_11_11_02_32_2014.flv" can you give me an example of what you mean tho? have you been able to test and works? Link to comment Share on other sites More sharing options...
iamtheky Posted March 5, 2015 Share Posted March 5, 2015 (edited) what i posted works, with whatever path i throw at either the exe or the arguments. This is your error: ==> Subscript used on non-accessible variable.: msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)[0]) msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)^ ERROR >Exit code: 1 Time: 0.3011 I want to see just $sOutput, so you can consolewrite($sOutput) and copy that stuff then paste it here. If there is no $sOutput its the command, if there is $sOutput its the expression, this just confirms that the actual issue is being addressed. Edited March 5, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 5, 2015 Share Posted March 5, 2015 what i posted works, with whatever path i throw at either the exe or the arguments. This is your error: ==> Subscript used on non-accessible variable.: msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)[0]) msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)^ ERROR >Exit code: 1 Time: 0.3011 I want to see just $sOutput, so you can consolewrite($sOutput) and copy that stuff then paste it here. If there is no $sOutput its the command, if there is $sOutput its the expression, this just confirms that the actual issue is being addressed. hmmm same error and no output so is in the ffmpeg command looks like Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 5, 2015 Share Posted March 5, 2015 in console i see the ffmpeg command as this: "C:\Documents and Settings\admin\Desktop\Ffmpeg tests\www\bin\ffmpeg.exe" -i "C:\Documents and Settings\admin\Desktop\Ffmpeg tests\www\recordings\World of Martial Arts Television_11_11_02_32_2014.flv" I don't see a error there... the quotes should fix any spacing's in the addressees to both ffmpeg and the video file Link to comment Share on other sites More sharing options...
iamtheky Posted March 5, 2015 Share Posted March 5, 2015 (edited) put them in a separate folder, but one in a path that has no spaces.... not as a solution, just scratching things off the board. and when you type those strings into the command prompt manually, alles klar? and just did some more testing: you just have to filegetshortname on the ffmpeg path as the file was already wrapped. I cant figure out why it doesnt like quotes around the ffmpeg path, yet, but this works with all ive thrown at it. #include <AutoItConstants.au3> Global $FFmpeg = "C:\Users\Me\Desktop\DEV\Media\FFMPEG scripts\ffmpeg.exe" $FFmpeg = FileGetShortName($FFmpeg) Global $sFile = FileOpenDialog("Pick Media" , @ScriptDir & "\" , "ALL (*.*)") If @Error Then exit $sCommands = $FFmpeg & " -i " & '"' & $sFile & '"' $iPID = Run("cmd /c " & $sCommands, @ScriptDir , @SW_SHOW , $stderr_child + $stdout_child) $sOutput = "" While 1 $sOutput &= StderrRead($iPID) If @error Then ; Exit the loop if the process closes or StderrRead returns an error. ExitLoop EndIf WEnd msgbox(0, '' , $sOutput) msgbox(0, '' , stringregexp($sOutput , "Duration: (\d\d\:\d\d\:\d\d.\d\d)\," , 3)[0]) Edited March 5, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 5, 2015 Share Posted March 5, 2015 i put into a Bat file it works just ine in console i see the ffmpeg command as this: "C:\Documents and Settings\admin\Desktop\Ffmpeg tests\www\bin\ffmpeg.exe" -i "C:\Documents and Settings\admin\Desktop\Ffmpeg tests\www\recordings\World of Martial Arts Television_11_11_02_32_2014.flv" I don't see a error there... the quotes should fix any spacing's in the addressees to both ffmpeg and the video file I put that code in a bat file and works Link to comment Share on other sites More sharing options...
dynamitemedia Posted March 5, 2015 Share Posted March 5, 2015 Ok after checking the output i am seeing this error now "C:\Documents and Settings\admin\Desktop\Video App\www\bin\ffmpeg.exe" -i "C:\Documents and Settings\admin\Desktop\Video App\www\recordings\XTreme4.flv" 'C:\Documents' is not recognized as an internal or external command, operable program or batch file. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now