Followers 0

# 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 on other sites

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

##### 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)

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