----1. introduction
----The bank's digital surveillance and monitoring system is currently a development project with relatively promising market and application prospects. Surveillance and surveillance systems developed based on different MPEG capture cards and hardware peripherals have relatively mature technologies at home and abroad. In order to meet the specific requirements of real-time monitoring, real-time acquisition and compression, playback at any time, and transmission of compressed data streams, a video data acquisition card for network video/audio multipoint transmission (video broadcast) is used in this system to provide AVI (MPEGIFrame compression encoding) collection, MPG collection. The sending end broadcasts the MPEG stream, the receiving end accepts the MPEG stream and displays it, and the network transmission uses WinSock2ip-Multicast. If this machine is the sender, any other PC on the network can be the receiver. As long as different port numbers are specified, multiple PCs can be used as senders at the same time, and multiple PCs can be used as receivers to receive video data from different senders. The data can also be saved as MPEG files locally while transmitting data. This article mainly introduces some programming techniques for developing Audio/Video data playback captured by MPEG cards in a VB environment.
----2. Introduction to the content and development of MPEG
----Multimedia information mainly includes three categories: images, sounds and text. Among them, the amount of information in video, audio and other signals is very large, and the expression, input and output requirements of this information are also different. It is very important to effectively express and properly process these data, which makes multimedia information compression technology one of the key technologies in the field of multimedia communications. MPEG (Moving Picture Expert Group), jointly established by ISO and IEC in 1988, is committed to the global standardization of moving pictures and their accompanying audio coding. It includes MPEG systems: MPEG video, MPEG audio. In order to promote the transition of society from the text information era to the multimedia information era, ISO launched MPEG-7 after MPEG-1, 2 and 4.
----MPEG-1 was formulated in 1993 (ISO/IEC11172). It is an international standard for digital storage media moving images and their accompanying audio coding for data transmission rates below 1.5Mbit/s. Video compression ratio is 26:1. MPEG-2 was formulated in 1995 (ISO/IEC13818). It is an international standard for 3-10Mbit/s moving image and accompanying audio coding recommended by CCIR601 for image quality DVB, HDTV and DVD. Different from the previous MPEG standard based on waveform coding theory based on information theory and targeting video and audio coding at a certain bit rate, the international standard MPEG-4, announced in November 1998, pays more attention to the interactivity and flexibility of multimedia systems. It introduces AV objects (Audio/VisualObjects), making more interactive operations possible. In October 1998, the International Organization for Standardization launched the MPEG-7 concept, which is expected to be finalized and announced in early 2001. Its official name is "MultimediaContentDescriptionInterface". It proposes a standardized description scheme suitable for various multimedia contents in real life, based on extracting various characteristics of the object to be described, to facilitate people to quickly and effectively retrieve the required multimedia materials.
----3. VB develops MPEG--Audio/Video data stream playback technology
----3.1. Disadvantages of MultimediaMCI control and MediaPlayer control in VB for playing MPEG data stream
----The commonly used multimedia control in VB is the MultimediaMCI control, which manages the recording and playback of multimedia files on the Media Control Interface (MCI) device. It is used to issue MCI commands to devices such as sound cards, MIDI sequencers, CD-ROM drives, video CD players, and video tape recorders and players. It also supports playback of Windows (*.avi) video files. Using the MultimediaMCI control to play the collected MPEG data stream, the playback speed is faster than the real-time monitoring display. During the test, it was also found that when the MPEG file length is shortened to 500k-600k, the broadcast image cannot be seen. Switch to using the MediaPlayer control in VB and the above-mentioned shortcomings still exist. The analysis reason is: because the MPEG file length is too short, the playback device has been closed as soon as it is turned on, which cannot be controlled by programming. Moreover, for some information about compressed data streams that users require and some functions they wish to implement, such as graph line size, CopmressionRate, graphic zoom display, interface beauty, etc., the above-mentioned controls provide convenience for program development. The high-level interfaces used by personnel are no longer applicable. It is understandably difficult to implement some operations on the bottom layer on this basis. When solving the practical problems mentioned above, we called the dynamic link library Quatrz.dll.
----3.2. Dynamic link library Quatrz.dll that provides convenient low-level operations and high-level interfaces for MPEG streams
----You can find a dynamic link library Quatrz.dll under Windows/System. This is a type library in Windows used to control the playback of moving images. Just add it in the "Reference" menu of VB Ready to use. This library defines IBasicAudio, IBasicVideo and IBasicVideo2, IMediaEvent, IMediaEventEx, IMediaPosition and other classes, which can be easily added to the Cl of the CommandButton control. Add code to set and read related values of Audio in events such as ick, set or read related parameters of Video input and output sources, directly call parameterless functions Run, Pause, Stop, etc. to control the playback event process, and use the IMediaPosition class to control specific playback Operate in detail. No special controls are required for the output display of compressed MPEG data streams. In Visual Basic, you can select a form as the container or the PictureBox control on the form as the container. For the sake of the beauty of the interface and the convenience for users to retrieve relevant information, we use the PictureBox control as a container to display the played MPEG data stream.
----3.3. Display MPEG data stream using PictureBox control
----The PictureBox control in VisualBasic can display graphics from bitmaps, icons or metafiles, as well as from enhanced metafiles, JPEG or GIF files. You can also manipulate graphics properties and methods in code to create animations or perform simulations. Place a PictureBox control picTV on the form. Based on calling the dynamic link library Quatrz.dll under Windows/System, define a global Object object pMC, let pMC point to a new instance of FilgraphManager, and open the M for playback. PEG file; then define a local object pVW as a new instance of IVideoWindow, and open a window to play Video; set pVW=pMC, assign a value to the object reference pVW, and assign the attribute value hWnd of picTV to the Owner of pVW, so that picTV can be displayed The MPEG data stream is received. The specific operations are as follows:
SetpMC=NewFilgraphManager
pMC.RenderFile"C:/Bank/Montior/Example.MPG"
SetpVW=pMC
pVW.WindowStyle=CLng(&H6000000)
pVW.Left=0
pVW.Top=0
OldWidth=pVW.width
OldHeight=pVW.Height
picTV.width=pVW.width*15
picTV.Height=pVW.Height*15
pVW.Owner=picTV.hWnd
----You can define a separate function to include these codes, or you can put it in the Click event of the CommandButton control.
----3.4. Zoom display of MPEG data stream
----Enlarging or reducing MPEG images is a commonly used image display processing method in various multimedia playback software. In Visual Basic, you can use the Image control to scale static pictures. Set the Stretch property of the control to True, and the loaded picture will change the proportion to adapt to the range of the Image control. Therefore, the scaling of the picture becomes the Height and Height of the Image control. The size of the Width attribute value changes. As the size of the control changes, the displayed point pitch cannot be changed, resulting in the pixels of the display points not being completely one-to-one correspondence with the picture, and the display quality being significantly deteriorated. Only the Image control can scale the picture. If the PictureBox control is not large enough to display the entire image, the image will be cropped to fit the size of the control. If you want to use the PictureBox control to scale the output MPEG image, you must change the output ratio of the MPEG data stream and adjust the size of the PictureBox control to adapt to the output MPEG image. In fact, this was already done in section 3 above for displaying the output MPEG image. It just uses the read OldWidth and OldHeight of the MPEG image. Here is an example of outputting the MPEG image at 1/2 the original size.
pVW.width=OldWidth/2
pVW.Height=OldHeight/2
picTV.Left=135
picTV.Top=135
picTV.width=pVW.width*15
picTV.Height=pVW.Height*15
pVW.Owner=picTV.hWnd
----When enlarging or reducing the size of MPEG images, pay attention to keeping the ratio of Width and Height consistent to avoid deformation of the output image.
----3.5. Drag the mouse to play MPEG data stream
----Using the mouse to drag the scroll bar to play the MPEG data stream at will is a common technology for multimedia players in Windows to play VCD. The Slider control in VB is a window containing a slider and optional tick marks. You can drag the slider, click either side of the slider with the mouse, or use the keyboard to move the slider. The Slider control is useful when selecting discrete values or a set of continuous values within a range. By moving the slider to the tick mark, the MPEG data stream can be positioned and played. Place a Slider control Slider1 on the form, set the maximum step size for cursor movement LargeChange=5, the minimum step size SmallChange=1, and the maximum movement range Max=50. The implementation procedure is as follows:
PRivateSubSlider1_Scroll()
'
DimpMPAsIMediaPosition
DimvAsDouble
IfNotbOpenThenExitSub
bSeeking=True
pMC.Pause
SetpMP=pMC
v=Slider1.Value-Slider1.Min
v=v/Slider1.Max*pMP.Duration
pMP.CurrentPosition=v
SetpMP=Nothing
pMC.Run
'
EndSub
----3.6. Acquisition of MPEG data stream acquisition time
----VisualBasic provides a function FileDateTime that can be used to obtain the date and time of file creation or update. Define a local object pMP as a new instance of IMediaPosition, set pMP=pMC, and assign a value to the object reference pMP; then define two Double-type variables curpos and length, assign pMP.CurrentPosition to curpos, and obtain the current relative position of the MPEG data stream. Time, assign pMP.Duration to length to obtain the time length value of the MPEG data stream; you can obtain the relative collection time of the MPEG data stream. According to the characteristics of MPEG acquisition file creation, the acquisition time of the MPEG data stream can be obtained by adding or subtracting two dates and times.
----During the entire MPEG playback process, it is required to display the collection time of the MPEG data stream in real time. You can define a function to obtain the collection time and use the Timer event of the Timer control to drive it. By triggering the Timer event, the Timer control can regularly execute a function at intervals to obtain the collection time of the MPEG data stream.
----4. Conclusion
----It is of great significance to use mature image compression technology in the field of TV surveillance. For example: In a bank's surveillance system, due to the particularity of the identity of the customer (bank), during the investigation and processing of incidents that disrupt the normal working order of the bank, such as impersonating other people's deposits, bank theft or robbery, etc., the collected data will be compressed. Data flow is very important clues and evidence for handling cases. In this system, not only the monitoring picture is required to be clear and the collected data redundant, but also the MPEG data stream playback technology is very important. This article introduces the use of Visual Basic's own conditions and original controls to develop the playback technology of Audio/Video data collected by MPEG cards in the Windows environment. Taking full advantage of the superior conditions of VB and flexibly combining it with various existing controls in VB, the developed MPEG media player has complete functions. The playback MPEG picture can clearly reproduce the scene during data collection, achieving "hearing the sound" , see the person" and be able to accurately determine the time and moment when the event occurred. Audio/Video data streams that only record a single frame can also be played back in the same way. The above technology has been used in monitoring systems with good results. ->