Microsoft DirectX 8.1 (C++) |
Retrieves information about a media file, such as the number of streams and the type, duration, and frame rate of each stream. This object also contains methods for retrieving poster frames from a video stream.
To obtain information about a file, perform the following steps:
To retrieve poster frames, call WriteBitmapBits. This method puts the MediaDet object into a new mode, called bitmap grab mode. The informational methods described previously do not work in this mode. Therefore, obtain any information you need before retrieving poster frames, or else create new instances of the MediaDet object for each stream.
Code Example
Dim Det As New MediaDet
Const VideoGUID As String = "{73646976-0000-0010-8000-00AA00389B71}"
bFoundVidStream = False
Det.FileName = "C:\Media\Example.avi"
' Look for a video stream.
For i = 0 To Det.OutputStreams - 1
Det.CurrentStream = i
StreamType = Det.StreamTypeB
If StrComp(StreamType, VideoGUID, vbTextCompare) = 0 Then
bFoundVidStream = True
Exit For
End If
Next
If bFoundVidStream Then
' Update the label with the duration.
VideoInfo.Caption = Det.FileName + ": " + Str(Det.StreamLength) + " seconds"
' Load a poster frame.
TempFile = "C:\Temp.bmp"
Preview.ScaleMode = vbPixels ' Scale twips to pixels.
Det.WriteBitmapBits 0, Preview.ScaleWidth, Preview.ScaleHeight, TempFile
Preview.Picture = LoadPicture(TempFile)
End If
This object has the following properties and methods.
Property | Description |
CurrentStream | Stream number currently used by the MediaDet object. |
Filename | Name of the source file currently used by the MediaDet object. |
Filter | Not supported for Visual Basic. |
OutputStreams | Number of output streams contained in the media source. |
FrameRate | Frame rate of the current stream, in frames per second. |
StreamLength | Duration of the current stream, in seconds. |
StreamMediaType | Not supported for Visual Basic. |
StreamType | Not supported for Visual Basic. |
StreamTypeB | String representing the GUID of the media type for the current stream. |
Method | Description |
EnterBitmapGrabMode | Switches the MediaDet object to bitmap grab mode and seeks the filter graph to a specified time. |
GetBitmapBits | Not supported for Visual Basic. |
GetSampleGrabber | Not supported for Visual Basic. |
WriteBitmapBits | Retrieves a poster frame at the specified media time and writes it to a file. |
Requirements
Include a reference in your project to "Dexter 1.0 Type Library" (Qedit.dll).