eagle4life69 Posted December 5, 2006 Share Posted December 5, 2006 How can I get the Length of a Video file. I know you can get it on sound but I need to get the Video length of all video formats (mov, wmv, m4v, mp4) Can anyone help. Also does the _soundlength work with all audio sources (mp3, wma, m4a) Thanks Link to comment Share on other sites More sharing options...
Zedna Posted January 6, 2007 Share Posted January 6, 2007 Create Object with embeded MediaPlayer then open your file and you can get it's length. I don't know exactly how but I think this technique I saw somewhere on this forum ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 7, 2007 Moderators Share Posted January 7, 2007 See if this works for you (You could use StringFormat() to do the time properly):$File = "C:\Documents and Settings\Ron\My Documents\beta\Examples\GUI\sampleAVI.avi" _GetMediaLen('Open ' & FileGetShortName($File) & ' alias MediaFile') _GetMediaLen('Set MediaFile time format milliseconds') $iTime = _GetMediaLen('Status MediaFile length') _GetMediaLen('Close MediaFile') MsgBox(0, '', $iTime / 1000 & ' seconds') Func _GetMediaLen($sString) Local $aDLL $aDLL = DllCall('winmm.dll','int', 'mciSendString', 'str', $sString, 'str', '', 'int', 65534, 'hwnd', 0) If Not @error Then Return $aDLL[2] EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Zedna Posted January 7, 2007 Share Posted January 7, 2007 See if this works for you (You could use StringFormat() to do the time properly) Nice solution SmOke_N I tested it and works fine. only little suggestion for name of function: Func _mciCommand($sString) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
leecole Posted January 8, 2007 Share Posted January 8, 2007 See if this works for you (You could use StringFormat() to do the time properly):$File = "C:\Documents and Settings\Ron\My Documents\beta\Examples\GUI\sampleAVI.avi" _GetMediaLen('Open ' & FileGetShortName($File) & ' alias MediaFile') _GetMediaLen('Set MediaFile time format milliseconds') $iTime = _GetMediaLen('Status MediaFile length') _GetMediaLen('Close MediaFile') MsgBox(0, '', $iTime / 1000 & ' seconds') Func _GetMediaLen($sString) Local $aDLL $aDLL = DllCall('winmm.dll','int', 'mciSendString', 'str', $sString, 'str', '', 'int', 65534, 'hwnd', 0) If Not @error Then Return $aDLL[2] EndFuncIt works for AVI files, but not mpg files. Talking Clockhttp://www.autoitscript.com/forum/index.php?showtopic=20751Talking Headlineshttp://www.autoitscript.com/forum/index.php?showtopic=20655Sometimes, I sits and thinkssometimes, I just sits 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