AVI details

G

Greg

How to read AVI details such as TIME, WIDTH, HEIGHT etc and send it to
program as a string??!!
This info is avaible in windows: FILE PROPERTIES ON SUMMARY TAB of
every AVI file.
I know this is difficult but maybe someone had worked with AVIs and
know how to do that.
Please HELP ME.
Thanks in advice.
 
J

Jake Marx

Greg,

I saw your previous post and did not know the answer (as I'm sure most who
read it didn't). I think you'd have better luck in an API newsgroup like
microsoft.public.vb.winapi or similar. Or you could search for a 3rd-party
tool that reads file properties.

Regards,

Jake Marx
MS MVP - Excel
 
M

mows

Greg

Have a look here

http://www.mentalis.org/apilist/AVIFileInfo.shtml

The site also gives general API info, with code snippets.

This spot of VBA worked for me.

mows
Excel XP SP2 / inXP SP1
******************************
Option Explicit

Private Const ERROR_SUCCESS As Long = 0
Private Const OF_SHARE_DENY_WRITE As Long = &H20
Private Const MAXDWORD As Long = &HFFFFFFF
Private Const MAX_PATH As Long = 260
Private Const INVALID_HANDLE_VALUE As Long = -1

'Flags for AVIFILEINFO dwFlags
Private Const AVIFILEINFO_HASINDEX As Long = &H10
Private Const AVIFILEINFO_MUSTUSEINDEX As Long = &H20
Private Const AVIFILEINFO_ISINTERLEAVED As Long = &H100
Private Const AVIFILEINFO_WASCAPTUREFILE As Long = &H10000
Private Const AVIFILEINFO_COPYRIGHTED As Long = &H20000

'Flags for AVIFILEINFO dwCaps
Private Const AVIFILECAPS_CANREAD As Long = &H1
Private Const AVIFILECAPS_CANWRITE As Long = &H2
Private Const AVIFILECAPS_ALLKEYFRAMES As Long = &H10
Private Const AVIFILECAPS_NOCOMPRESSION As Long = &H20

Private Type AVIFILEINFO
dwMaxBytesPerSec As Long
dwFlags As Long
dwCaps As Long
dwStreams As Long
dwSuggestedBufferSize As Long
dwWidth As Long
dwHeight As Long
dwScale As Long
dwRate As Long
dwLength As Long
dwEditCount As Long
szFileType As String * 64
End Type

Private Declare Function AVIFileOpen Lib "avifil32" _
Alias "AVIFileOpenA" _
(ppfile As Long, _
ByVal szFile As String, _
ByVal mode As Long, _
pclsidHandler As Any) As Long

Private Declare Function AVIFileRelease Lib "avifil32" _
(ByVal pfile As Long) As Long

Private Declare Function AVIGetFileInfo Lib "avifil32" _
Alias "AVIFileInfoA" (ByVal pfile As Long, pfi As AVIFILEINFO, _
ByVal lSize As Long) As Long

Private Declare Sub AVIFileInit Lib "avifil32" ()
Private Declare Sub AVIFileExit Lib "avifil32" ()

Private Function GetAVIFileInfo(sAVIFile As String) As AVIFILEINFO
Dim hAvi As Long, AFI As AVIFILEINFO
AVIFileInit
If AVIFileOpen(hAvi, sAVIFile, OF_SHARE_DENY_WRITE, ByVal 0&) =
ERROR_SUCCESS Then
If AVIGetFileInfo(hAvi, AFI, Len(AFI)) = ERROR_SUCCESS Then
GetAVIFileInfo = AFI
Call AVIFileRelease(hAvi)
End If
End If
AVIFileExit
End Function

Private Sub GetSomeAVIInfo()
Dim AFI As AVIFILEINFO
Dim AVIFilePath As String
AVIFilePath = "c:\Windows\clock.avi"
AFI = GetAVIFileInfo(AVIFilePath)

Debug.Print AFI.dwMaxBytesPerSec
Debug.Print AFI.dwFlags
Debug.Print AFI.dwCaps
Debug.Print AFI.dwStreams
Debug.Print AFI.dwSuggestedBufferSize
Debug.Print AFI.dwWidth
Debug.Print AFI.dwHeight
Debug.Print AFI.dwScale
Debug.Print AFI.dwRate
Debug.Print AFI.dwLength
Debug.Print AFI.dwEditCount
Debug.Print AFI.szFileType

End Sub

******************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top