Implementation of an Embedded MPEG-2 Remote Network Video Surveillance System
2026-04-06 06:42:31··#1
1. System Introduction The Vstar MPEG-2 series remote digital video monitoring system is an embedded remote image monitoring system based on a TCP/IP network. Adopting an embedded design, the system boasts high stability. Utilizing MPEG-2 video compression technology, it delivers high-definition images with DVD-quality finish. It supports single-screen sequential monitoring and simultaneous monitoring of 1 to 16 screens, supports remote and local PTZ control, and multi-tasking. Image storage, monitoring, and remote control can be performed simultaneously, and the monitoring distance increases with network expansion. The system consists of three parts: remote site, communication network, and monitoring service, as shown in Figure 1. Both the remote site and monitoring service parts are equipped with MPEG-2 image processing equipment and wired network interface devices. The software uses a client/server architecture; the server-side software runs on the wired network interface at the remote site, while the client-side software runs at the monitoring center. The remote site software must register with the monitoring center after system startup. As a monitoring system, it must have the names of the monitoring points and descriptions of their characteristics. Before authenticating a monitoring point, the monitoring center must first check if a monitoring point with the same name already exists online to avoid confusion caused by identical names. If so, the user will be prompted to change the name. After successful authentication, the client can establish a TCP/IP connection with the server via the network. Communication between the two ends includes image data and control command communication. Within the scope of permissions, the client can adjust the server's parameter settings and operating mode through the monitoring center as needed. The server then sends an encoded MPEG-2 video stream to the client. The client software runs on the monitoring center's PC and provides the corresponding user control interface. Users can establish different types of connections with the server via the network to obtain different services. The server software runs on the remote field PC104 and has rich functionality, including hardware driver control, communication line management, image data transmission, system control, camera and pan/tilt adjustment, etc. 2 System Hardware Design The core hardware component is the design of the MPEG-2 video processing equipment. Figure 2 briefly illustrates the structure of the MPEG-2 hardware video compression processing. The MPEG-2 video acquisition and compression module, based on the Fujitsu MB86390 chip, performs A/D conversion of standard video signals (PAL or NTSC signals), MPEG-2 compression, and communication with the PC104 host. In Figure 2, the video decoding A/D converter transforms the analog video signal input from the camera into a digital video signal, followed by encoding preprocessing. This preprocessing converts the received video signal into a specified format, specifically converting the CCIR601 format signal output from the video decoder into a CIF or QCIF format that the encoder can process, before performing MPEG-2 compression encoding. The SRAM shown in the figure serves as frame storage for encoding and stores the encoded bitstream data. The software on the PC104 controls the encoder's parameter settings and reads the encoded and compressed bitstream data through the bus interface unit. This module includes the following functional units: a video A/D unit based on the SAA6252, an MPEG-2 video compression unit based on the MB86390, and a control logic and bus interface unit composed of the AT89C51 and EPM7128 (EPLD). The bus interface unit is implemented in the EPLD. It serves as the channel for interaction between this module and the host (PC104), enabling the exchange of video streams and control data. The control logic is the core of the video acquisition and compression module. It controls and coordinates the work of each module, providing control signals. Through EPLD programming, it implements the necessary gating, buffering, read/write enable, and switching between the data bus and address bus for each module. Lens PTZ control is performed through the RS232 port of the PC104 host, allowing users to adjust the system according to their requirements. Users can adjust the image quality by adjusting the lens's zoom, focus, and aperture, and can also acquire images from different angles by adjusting the PTZ up, down, left, and right. The client software at the monitoring center sends adjustment information to the server via the SOCKET network interface. After receiving the control command, the server identifies the command and then sends the command to the corresponding RS232 port to control the PTZ and complete the adjustment task. 3 System Software Design Traditional applications are single-threaded, meaning that during program execution, a single thread exclusively controls the CPU. In this situation, the program cannot respond to user operations in a timely manner when performing time-consuming tasks, affecting the real-time performance of the application. In monitoring systems, especially remote monitoring systems, applications often need to not only promptly feed back the latest information of the monitored objects to the monitoring client (through graphical display), but also handle communication between the local and remote machines and real-time control of the controlled objects. Clearly, a single thread cannot meet the real-time requirements of the monitoring system. Therefore, a multi-threading mechanism can be introduced. The main thread is dedicated to message response, enabling the program to respond to commands and other events. Auxiliary threads can be used to complete other time-consuming tasks, such as communication, graphical display, and background printing, without affecting the operation of the main thread. In short, introducing a multi-threading mechanism into communication improves the real-time performance of the application and makes full use of system resources. For large-scale engineering applications, different threads performing different tasks also improve the modularity of the program, facilitating maintenance and expansion. The software adopts a Client/Server architecture, with both ends establishing a TCP/IP connection over a network and exchanging data according to a custom data communication protocol to complete data communication and system control functions. The monitoring center's client requests a connection from the server. Upon receiving the request, the server establishes a SOCKET connection with the client. The client sends control signals to the server, and the server sends video streams back to the client. The server-side software runs on a PC104. Since the encoding part uses hardware compression, it does not consume PC104 system resources. Therefore, a well-designed server software structure running on the PC104 is crucial for improving the overall system efficiency, and system performance is closely related to it. The main design principles are as follows: synchronization between the reading thread, the sending thread, and the control thread to prevent waste of limited resources. During the processing of control commands, stream reading, and transmission, there may be time redundancy. Taking stream reading as an example, if the CPU reads video data from the EPLD's FIFO faster than the encoder, it may be in a waiting state for encoder hardware response. Although the CPU is occupied, the system is not actually performing a valid task, resulting in wasted computer system resources, which are already very limited in embedded systems. To fully utilize CPU computing power and improve overall system performance, multi-threading technology is used for task scheduling in this system. The following analysis is based on the remote field data processing process: (1) Reading thread: responsible for controlling the hardware and reading image data from the encoder into the host memory; (2) Sending thread: responsible for the transmission of video stream; (3) Control thread: responsible for the control of the pan-tilt unit, camera and the parameter setting of the encoder. In video transmission, the server requires that the reading and sending of the stream do not interfere with each other, and avoid the situation where reading and sending wait for each other or conflict with each other. Similarly, the client decoding and receiving also have this relationship. This design adopts a multi-threaded video transmission technology based on a circular buffer, which solves this problem well. In addition to achieving data separation and mutual exclusion, the host's circular buffer can also play the role of smoothing the stream. The reading thread and the sending thread are mutually exclusive. The read video data is processed by the transmission thread. This is a simple consumer and producer relationship problem. As long as they do not enter the critical section, the two threads can work at the same time. The synchronization problem of the two threads can be completely solved by using a circular buffer and a mutex lock. The synchronization between threads realizes the reasonable allocation of CPU time slices, as well as hardware access management, memory buffer access management, etc., which greatly improves the processing performance of the system. The client provides a control interface for users, allowing them to request various services. Users can connect to the service host and modify the system's operation and status according to their needs. Users with the highest privileges can adjust the server's operation, modify system management information, and access all different types of services. The system defines its own command system and command transmission protocol. Commands can be categorized as follows: operation control (transmission start, transmission stop, storage control, etc.), lens pan/tilt control (focal length, aperture, auto-rotation, etc.), and system settings (user management, communication parameter settings, etc.). Each command has a unique identifier, which the server uses to distinguish it from other commands. The server's IP address is fixed. The main thread creates a socket connection with the monitoring center upon startup, listens on a designated service port, and creates a command communication line connection for users requesting a connection. Users with different privileges have different control rights over the system, thus enabling the monitoring center to control the system. The monitoring center client software also supports image storage and playback. Users can store images from actual monitoring on their local hard drive and retrieve and play them back in different ways. 4 Conclusion The VstarMPEG-2 series remote digital monitoring system supports standard video signal and high-resolution image acquisition and compression, supports Internet-based data transmission, and the C/S architecture allows users to operate in a remote operating mode. The various sub-modules of the system are relatively independent and can achieve the following functions: (1) Real-time: The MPEG-2 encoding equipment can ensure the real-time transmission and reception of digital video signals. It ensures that there is no unacceptable time difference between the monitoring information received by the monitoring center and the actual situation on site; (2) Continuity: The MPEG-2 encoding and decoding equipment based on embedded technology can ensure that the frame rate of PAL video is 25 frames/second and NTSC video is 30 frames/second. It also ensures that the images seen by the monitoring center are clear and distinguishable and that communication is smooth, and that it can operate reliably around the clock. (3) Controllability: The monitoring center can remotely select and control the images of each sub-center. The system parameter settings are convenient and quick, and any parameter of the video source can be set, and the bandwidth can be dynamically adjusted. (4) Scalability: The system structure can be modified according to actual conditions. The expansion of the system scale only requires the addition of corresponding codecs. The control function of the center is scalable and can be connected to the office automation network to realize multi-site remote control. The function of the center is also scalable. It can also realize remote video conferencing function with appropriate addition of codecs, thereby meeting different needs. This series of remote digital monitoring systems has been widely used in bank monitoring, highway monitoring, map aerial photography, home monitoring and other fields. References 1 Yu Zhaoming, Li Xiaofei, Chen Laichun, eds. Digital Television Equipment and Measurement. Beijing: People's Posts and Telecommunications Press, 2000 2 Stevens. TCP/IP Illustrated - Protocol. Beijing: Machinery Industry Press, 2000 3 Wang Xuelong, ed. Embedded Linux System Design and Application. Beijing: Tsinghua University Press, 2001 Editor: He Shiping