Many video playback software or video editing software provides the function of gripping frame, using this kind of software, the video worker can easily grab a frame of a movie a moment and save it as a picture file, then how can we program to achieve this function? If you are familiar with MPEG or AVI and other common video formats, you can directly to the movie file to operate, if you do not know these video formats, and want to use a more simple way to crawl the movie frame, Microsoft's DirectShow will give you a great surprise.
DirectShow belongs to the DirectX family (DirectX also includes Direct3D, DirectInput, DirectDraw, DirectSound, and other components), and before you use DirectShow to develop a crawl frame program, You must install the DirectX SDK, which can be downloaded from Microsoft's Web site, the latest version is 9.0b, and because the DirectX SDK is published in COM, it is important for developers to understand the fundamentals of COM. If you have not used COM, you can start from the Internet to find some introductory tutorials on COM to see
The setup of programming tools:
First of all, I use the VC 6.0 settings, in general, after the installation of DirectX 9.0b SDK, will automatically set the VC, users do not need manual intervention, if the compilation process errors, please check whether VC contains the DirectX SDK header files and library files, the method is to select the menu " tools->options ... ", select the Directories tab in the Options dialog that pops up, and see if the Include Files and library files contain DirectX The Include and LIB paths for the SDK, and if not, add the two paths up.
Second, the main implementation steps:
In the process of capturing movie frames, the DirectShow Imediadet interface will be the protagonist, which includes methods to extract important information from the media source files, such as media type, frame rate, or even a single frame of the video stream.
• Note
To properly use the Imediadet interface, the following files are required for the project:
Header file: Dshow.h, Qedit.h
Library files: strmiids.lib
Because you use the CComPtr template to declare an interface instance, you also include the atlbase.h header file in your project.
We will use the Imediadet interface step-by-Step to implement the capture movie frame function.
Step one: Create a new dialog based application that adds two edit controls and three button controls to your application, as shown in the diagram: