Key words: video capture; sdk; vfw; avi; MCI Currently, develop video applications under Windows platforms generally use two ways: one is the secondary software development package included with video capture card (Software Development Kit) )get on. The advantage of this way is that the application is convenient, easy to get, the disadvantage is that the hardware is strong, flexible, and the function is uneven, and the development needs of various video applications cannot be fully met; another way is based on VFW Video for Windows. VFW is Microsoft to develop a software toolkit provided by video applications under Windows platforms, providing a Series Application Programming Interface (API), users can easily implement video capture through them [1], video editing and video playback Alternatively, you can also develop more complex video applications using a callback function. It is characterized by playing a private hardware device when playing video, and the application is flexible, and the needs of video applications can be met. The Windows operating system itself carries the VFW, and the system is automatically installed, the VFW is installed. VC supports VFW since 4.0, greatly simplifies the development of video applications. At present, the video part of the multimedia application on the PC is mostly developed using the VFW API. 1 VFW architecture
VFW Access to the video device in a messaging method, which can easily control the work of the device data stream. Currently, most video capture card drivers support VFW interfaces, which mainly include multiple dynamic connection libraries, through coordinated cooperation between these components, to complete video capture, video compression, and playback. The VFW architecture is shown in Figure 1. 1) Vicap.dll: The video capture function is mainly implemented, including functions for video capture, providing an advanced interface for audio-interlace AVI (Audio Video Interleaved) format files and videos. 2) MsVideo.dll: You can connect the video capture window with the drive device to support ICM video encoding services. 3) mciavi.drv: Contains the MCI (Media Control Interface command interpreter to implement playback function. 4) AVIFILE.DLL: Provides file management functions such as read and write operations for AVI files. 5) ICM (Installable Compression Manager): The compression manager provides compression, unpacking service for video image data stored in the AVI file. 6) ACM (AUDIO Compression Manager): That is, the audio compression manager provides real-time audio compression and decompression.
Capture Application
Playback Application
Edit Application
Avicap.dll
Avicap
MsVideo.dll
McIWnd
ACM
McIavi.drv
MCI Command
Interpreter
MsVideo.dll
Video in ICM
Channel
Avifile.dll
File / stream
Handler
MsVideo.dll
DrawDIB ICM
Capture Application
Playback Application
Edit Application
Avicap.dll
Avicap
MsVideo.dll
McIWnd
ACM
McIavi.drv
MCI CommandInterpreter
MsVideo.dll
Video in ICM
Channel
Avifile.dll
File / stream
Handler
MsVideo.dll
DrawDIB ICM
Capture Application
Playback Application
Edit Application
Avicap.dll
Avicap
MsVideo.dll
McIWnd
ACM
McIavi.drv
MCI Command
Interpreter
MsVideo.dll
Video in ICM
Channel
Avifile.dll
File / stream
Handler
MsVideo.dll
DrawDIB ICM
2 video capture
Real-time acquisition of video data is mainly done by messages, macro functions, structures, and callback functions in the Avicap module. The general process of video capture is as follows: 2. Building a capture window
Using the AvicAP component function CapCreateCaptureWindow () establishes a video capture window, it is the basis of all capture work and settings, including: 1 dynamically connect or disconnect with video and audio inputs; 2 Set video capture rate; 3 Provide video Source, video format, and whether to use a video compressed dialog; 4 Set the display mode of the video acquisition is overlay or for preview; 5 real time to get each frame video data; 6 to capture a video stream and audio stream and save to an AVI file Capture a frame digital video data and save the single frame image in DIB format; 8 Specify the file name captured data, and copy the captured content to another file. 2.2 Register the callback function [2]
Register the callback function to achieve some special needs of the user. In some real-time monitoring systems or video conferencing systems, it is necessary to process the data stream before writing to the disk, reaching real-time energy. The application can use the capture window to register the callback function in time to process the following: Capture window status change, error, use video or audio cache, abandon control, etc., corresponding callback functions are CapStatusCallback (), CAPERRORCALLBACK (), CapvideStreamCallback (), CapVideoStreamCallback CapwavestreamCallback (), CAPYIELDCALLBACK ().
2.3 Get the default settings for capture windows
By macro CapCapturegetSetup (HWNDCAP, & M_PARMS, SIZEOF (M_PARMS)). 2.4 Set the relevant parameters of the capture window
Perform it through macro CapCaptureetSetup (HWNDCAP, & M_PARMS, SIZEOF (M_PARMS)). 2.5 Connection Capture Window and Video Capture Card
Perform it through macro CapdriveConnect (HWNDCAP, 0). 2.6 Get the function and status of acquisition equipment
The ability to obtain the video device is obtained by macro CapdrivergeTCaps (HWNDCAP, & M_CAPDRVCAP, SIZEOF (CAPDRIVERCAPS)), and the status of the video device is obtained by macro CapGetStatus (HWNDCAP, & M_CAPSTATUS, SIZEOF (M_CapStatus). 2.7 Set capture window display mode
The video displays two modes of Overlay and Preview (preview). In the superposition mode, capture the video data exhibition system resource, the display speed is fast, the video acquisition format is YUV format, and can be set by capoverlay (hwndcap, true); in the preview mode, the system resource is taken, and the video is called the GDI function in capture. The window is displayed, the display speed is slow, it supports the RGB video format. 2.8 capture images to cache or files and processed
To perform real-time processing of the acquisition data, the callback mechanism should be used to complete single frame video acquisition by CapSetCallbackonFrame (HWNDCAP, FRAMECALL-BACKPROC); the video stream acquisition is completed by CapsetCallbackonvideStream (HWNDCAP, VideoCallbackProc). If you want to save the acquisition data, you can call CapCaptureSequence (HWND); you want to specify the file name, you can call CapFileSetCap-Ture (HWND, FileName). 2.9 Termination Video Capture Disconnects CAPCATURESTOP (HWNDCAP) to disconnect CAPCATURESTOP (HWNDCAP), call CapDriverDisconnect (HWNDCAP), disconnect the video window and capture the driver. 3 video editing and play
With VFW, you can not only realize real-time collection of video streams, but also provide editing and playback, but also completed by collaboration between Avifile, ICM, ACM, MCIWND. 1) avifileinit (); // initialization; 2) avifileopen (); // Open an AVI file and a handle of the file; 3) AVILEINFO (); // Get information about the file, such as Width and Height, etc. 4) AvifilegetStream (); // Establish a pointer to the data stream that needs to be accessed; 5) AvistreamInfo (); // Get the AvistreamInfo structure of the stored data flow information; 6) AvistreamRead (); // Read the data stream Original data, the editing process required for the AVI file; 7) AvistreamRelease (); // Release points to the pointer to the video stream; 8) AVIFileRelease (); avifileExit (); // Release the AVI file. If the data is compressed, use AVistreamGetFrameOpen (), avistreamgetframe (), and avistreamgetframeclose (), you can complete the frame-by-frame decomposition of the video stream. 3.2 Video Play
For the playback of the video stream, VFW provides the MCIWND window class [4], primarily used to create a video player, control, and modify the properties of the MCI window currently loaded media. A library consisting of functions, messages, and macros is associated with mciwnd, which can make the application to complete video playback feature through them. 1) MCIWNDCREATE (); // Register the MCIWND window class, create the MCIWND window, and specify a window style; 2) avifileinit (); // initialization; 3) avifileopen (); // Open the AVI file; 4) avifilegetStream (); 4) avifilegetstream () // Get a video stream; 5) Use the related function to make a variety of play tasks: mciWndPlay () is playing the avi file content, mciWndPlayReverse () reverse play, mciWndResume () resumes playback, mciWndplayPause () Pause Play, mciWndStop () stop Play, etc. 6) AvistreamRelease (); // Release video stream; 7) avifilerease (); avifileexit (); // Disconnect the connection with the AVI file to release the video source. As can be seen from the above steps, video playback is one of the video editing. 4 Conclusion
With the development of society, people's demand for multimedia technology is getting higher and higher. They have not met a single communication function, requiring image and sound synchronous services, such as video calls, video conferencing, various real-time monitoring systems, alarm systems The digital video technology is one of the cores of multimedia technology. Microsoft's digital video processing software development package Video for Windows, liberates developers from the bottom of the hardware, greatly simplifies the digital video capture, using it, can be used to simulate video signal digitization And support further processing and playback, open up the road to develop real-time video applications. Reference: [1] Zhou Changfa. VC Multimedia Programming Technology and Example [M]. Beijing: Electronic Industry Press, 1999.
[2] Zhang Xingming. Implementation of video capture and motion detection technology [J]. Computer Engineering, 2002, 28 (8): 130-132.
[3] Xiao Yonglong, Wang 理. Using VFW library function to quickly decompose AVI data [J]. Journal of Information Engineering University, 2001, 2 (3): 39-42.
[4] 炳 炳. Application of Multimedia Information Processing in Windows [J] .Journal of Chongqing Business University, 2003, 20 (1): 64-66.