Jump to content

Recommended Posts

Posted

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

  • 1 month later...
  • Moderators
Posted

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.

Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...