Microsoft DirectX 8.0 |
Retrieves information about a media file, such as the number of streams and the type, duration, and frame rate of each stream. This interface 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.
The following code example shows how to use this object:
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
Properties
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.
Methods
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.
Stream number currently used by the MediaDet object. Read/write.
Syntax
object.CurrentStream As Long
Parts
- object
- Object expression that evaluates to a MediaDet object.
Name of the source file currently used by the MediaDet object. Read/write.
Syntax
object.Filename As String
Parts
- object
- Object expression that evaluates to a MediaDet object.
Not supported for Visual Basic.
Syntax
object.Filter As Unknown
Frame rate of the current stream, in frames per second. Read-only.
Syntax
object.FrameRate As Double
Parts
- object
- Object expression that evaluates to a MediaDet object.
Remarks
The stream must be a video stream. This property is not valid for ASF files. The property is not valid if the MediaDet object is in bitmap grab mode (see EnterBitmapGrabMode).
Before retrieving this property, set the Filename and CurrentStream properties.
Number of output streams contained in the media source. Read-only.
Syntax
object.OutputStreams As Long
Parts
- object
- Object expression that evaluates to a MediaDet object.
Remarks
Before retrieving this property, set the Filename property.
This property is not valid if the MediaDet object is in bitmap grab mode (see EnterBitmapGrabMode).
Duration of the current stream, in seconds.
Syntax
object.StreamLength As Double
Parts
- object
- Object expression that evaluates to a MediaDet object.
Remarks
Before retrieving this property, set the Filename and CurrentStream properties.
This property is not valid if the MediaDet object is in bitmap grab mode (see EnterBitmapGrabMode).
Not supported for Visual Basic.
Syntax
object.get_StreamMediaType As _AMMediaType
Not supported for Visual Basic.
Syntax
object.StreamType As GUID
String representing the GUID of the media type for the current stream. Read-only.
Syntax
object.StreamTypeB As String
Parts
- object
- Object expression that evaluates to a MediaDet object.
Remarks
The string formatted like the following: {73647561-0000-0010-8000-00AA00389B71}
Before retrieving this property, set the Filename and CurrentStream properties. This property is not valid if the MediaDet object is in bitmap grab mode (see EnterBitmapGrabMode).
Switches the MediaDet object to bitmap grab mode and seeks the filter graph to a specified time.
Syntax
object.EnterBitmapGrabMode( SeekTime As Double )
Parts
- object
- Object expression that evaluates to a MediaDet object.
- SeekTime
- Time, in seconds, to which the graph seeks.
Error Codes
If the method fails, an error is raised, and Err.Number can be set to one of the following values:
E_INVALIDARG Invalid argument. VFW_E_INVALIDMEDIATYPE File does not have a video stream. VFW_E_TIME_EXPIRED Could not seek.
Remarks
Before calling this method, set the Filename and CurrentStream properties.
This method inserts the Sample Grabber filter into the filter graph. Once the MediaDet object enters bitmap grab mode, the various informational methods in MediaDet do not work.
The GetBitmapBits or WriteBitmapBits methods also put the object into bitmap grab mode.
Not supported for Visual Basic.
Syntax
object.GetBitmapBits( StreamTime As Double, pBufferSize As Long, pBuffer As Byte, Width As Long, Height As Long )
Not supported for Visual Basic.
Syntax
object.GetSampleGrabber( ppVal As SampleGrabber )
Retrieves a poster frame at the specified media time and writes it to a file.
Syntax
object.WriteBitmapBits( StreamTime As Double, Width As Long, Height As Long, Filename As String )
Parts
- object
- Object expression that evaluates to a MediaDet object.
- StreamTime
- Time at which to retrieve the poster frame, in seconds.
- Width
- Width of the poster frame image, in pixels.
- Height
- Height of the poster frame image, in pixels.
- Filename
- Path of the file in which to save the poster frame. If the file already exists, this method overwrites it.
Error Codes
If the method fails, an error is raised, and Err.Number can be set to one of the following values:
E_NOINTERFACE Could not add the Sample Grabber filter to the graph. E_FAIL Failure. E_OUTOFMEMORY Insufficient memory. E_UNEXPECTED Unexpected error. STG_E_ACCESSDENIED Cannot overwrite file. VFW_E_INVALIDMEDIATYPE Invalid media type.
Remarks
Before calling this method, set the Filename and CurrentStream properties.
This method puts the MediaDet object into bitmap grab mode. Once this method has been called, the various stream information methods in IMediaDet do not work, unless you create a new instance of the object.