Sign in to follow this  
Followers 0
eagle4life69

Video Length

5 posts in this topic

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

Share this post


Link to post
Share on other sites



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


[center]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.[/center]

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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
It 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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0