|
||||
|
AVI Frame ExtractorCode for extracting individual frames from AVI Streams. The AVI Frame Extractor code provided here allows you to extract and display individual frames from AVIs. This can be useful if you're trying to create a derivative of an existing AVI as you can extract each of the frames and either edit them in a painting package or write a program to do it. There's also some code in there to save a 256 colour bitmap using Run-Length Encoding. About The CodeThe code provides the following main classes for working with AVI streams:
The following supplementary classes are also provided:
Extracting and Drawing AVI FramesThe following code demonstrates how to open an AVI and draw each of the frames: Dim cAVI As New cAVIFrameExtract ' Set the file name of the AVI to read: cAVI.Filename = sAVIFile ' Read the general properties: ' Number of frames: txtInfo(0).Text = m_cAVI.FrameCount ' Length of each frame in ms txtInfo(1).Text = m_cAVI.FrameDuration ' Bits/Pixel of the AVI: txtInfo(2).Text = m_cAVI.bitsPerPixel ' Size of the frames: txtInfo(3).Text = m_cAVI.Width txtInfo(4).Text = m_cAVI.Height ' Name of the AVI: txtInfo(5).Text = m_cAVI.Name ' Video Handler FourCC code (e.g. 'mrle'): txtInfo(7).Text = m_cAVI.VideoHandlerFourCCString ' Multimedia stream type (always 'vids'): txtInfo(8).Text = m_cAVI.VideoTypeFourCCString ' Now draw each of the frames onto the form: Dim i As Long Dim y As Long For i = 1 to m_cAVI.FrameCount DrawFrame Me.hDC, i, 8, y y = y + m_cAVI.Height Next i One of the most frequently needed operations is to draw an AVI frame transparently over an existing background. To make this easier, DrawFrame has a Transparent parameter. Setting this allows you to render the AVI over any existing background. Sources of AVIOther than the AVIs provided with the download, you can get some more to play with from the Graphics Library or by using the Resource Extractor application to extract AVIs from a DLL which contains them (Shell32.DLL is a good place to start). ConclusionThis article provides code for programmatically extracting frames from AVIs, allowing them to be displayed, saved and/or manipulated prior to display. You could use this code as part of an AVI editing application or to customise the display of an AVI in an application.
|
|||
|