A method for accessing rtsp camera video stream based on Flume
By customizing FlumeSource to process RTSP camera video streams in the Flume system, the problem of low video stream processing efficiency in existing technologies is solved, and efficient and reliable video frame extraction and analysis are achieved.
Patent Information
- Application Number
- CN202211216447.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2042-09-30
AI Technical Summary
The existing technology lacks specialized middleware for efficiently processing video streams from surveillance cameras, resulting in inefficient and costly manual analysis.
Based on the Flume system, we customize FlumeSource to achieve fast, effective and reliable access and frame extraction of RTSP camera video streams. Through customized source, channel and sink components, combined with ffmpeg objects and video frame converters, we can achieve real-time capture of video streams and key frame extraction.
It achieves high-concurrency video frame extraction, reduces manual analysis costs, and improves video stream processing efficiency.
Smart Images

Figure CN115695920B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of camera video stream access, and in particular to a Flume-based RTSP camera video stream access method. Background Art
[0002] Artificial intelligence and big data technologies have developed rapidly in recent years. However, in the current industry context, big data processing primarily focuses on data from various data tables, and video stream analysis and processing is relatively rare in the big data field. Surveillance cameras are now ubiquitous in cities and rural areas. Manually obtaining useful information from these cameras is costly and inefficient.
[0003] Currently, there is no specialized middleware on the market that can achieve the purpose of extracting frames from video streams. Based on the existing situation, the performance and stability of Flume middleware in extracting data were investigated. Apache Flume is a distributed, reliable, and available system for efficiently collecting, aggregating, and moving large amounts of log data from many different sources to a centralized data store. The use of Apache Flume is not limited to log data aggregation. Since the data source is customizable, Flume can be used to transmit large amounts of event data, including but not limited to network traffic data, data generated by social media, email messages, and almost all possible data sources. The Flume architecture is to start a separate Flume agent on the node where the data generator runs to collect data. Each agent is an independent Java process that receives data from the client (other agents) and then forwards it to the next destination.
[0004] The Agent consists of three components:
[0005] (1) Source, which receives data from the event generator and transmits it to one or more channels in the form of events;
[0006] (2) Channel: receives FlumeEvent from the source and stores it in a buffer as a temporary storage until it is consumed by the sink. It is a bridge between the source and the sink. Channel is transactional and can work with multiple sources or sinks.
[0007] (3) Sink: stores data in HDFS, consumes events from the channel, and distributes them to the destination.
[0008] Flume is also extensible and can be developed secondary. Summary of the Invention
[0009] In view of this, the present invention provides a Flume-based rtsp camera video stream access method. On the basis of the Flume system, a custom FlumeSource is used to extract video frames quickly, effectively and reliably, including the following steps:
[0010] S1. Create a public class named RtspSourceConstants. The function of this class is to define some static variables. The values of the static variables are the values of the configuration file variables to be read when the Flume system starts;
[0011] S2. Define an abstract class inheritance of the RTSP camera data source Source, named: AbstractSource, and configure the static variables read in S1 to customize the source based on Flume;
[0012] S3. After the code is completed, package and compile it, and put the JAR package into the specified directory of Flume;
[0013] S4. Connect the RTSP camera to the custom source of the Flume system to implement access for big data analysis and processing and extract frames.
[0014] Furthermore, S1: create a public class named: RtspSourceConstants. The function of this class is to define some static variables. The values of the static variables are the values of the configuration file variables to be read when the Flume system is started. The configuration file contains two parts: video source information and Flume event header. The video source information includes camera access path, camera number, and camera access protocol; the Flume event header includes Kafka topic, event stamp, partition number, and offset.
[0015] Furthermore, S2 defines an abstract class inheritance of the RTSP camera data source Source, named: AbstractSource, and configures the static variables read in S1, based on the Flume custom source, specifically:
[0016] S21. Rewrite the configure() method, pass the configuration parameters of the static variables read in S1 into this class, assign initial values to the member variables in the class, and the subsequent execution process is executed according to the configuration;
[0017] S22. Rewrite the start() method to connect the video stream of the RTSP camera, set the connection properties and video source path of the RTSP camera, and create an ffmpeg object and a video frame converter object according to the set properties; after the ffmpeg object and the video frame converter object are successfully created, start the video stream capture thread and continuously extract frames;
[0018] S23, rewrite the stop() method to stop the RTSP video stream frame extraction thread and release the resource objects in the video stream frame extraction process;
[0019] S24. Rewrite the process() method to determine whether the frame extraction fails based on the parameters in S1. If it is determined to be a video, extract the frame from its thread; if it is successful, extract the key frames in the video, and convert the successfully extracted key frames into BufferImage objects through the converter object; set the Flume event header and obtain the Flume time object in the video data encapsulation in the BufferImage object, and send it to the channel of the Flume system.
[0020] The technical solution provided by the present invention has the beneficial effects of using Flume to access the RTSP video stream and realizing fast, effective and reliable extraction of video frames through customizing FlumeSource, thereby meeting the high concurrency requirements for large-scale data processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a design architecture diagram of a Flume-based rtsp camera video stream access method of the present invention;
[0022] Figure 2 This is the Flume design architecture diagram. DETAILED DESCRIPTION
[0023] To make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described below with reference to the accompanying drawings.
[0024] Please refer to Figure 1 and Figure 2 , Figure 1 This is a design architecture diagram of a Flume-based rtsp camera video stream access method of the present invention; Figure 2 This is the Flume design architecture diagram.
[0025] The present invention provides a method for accessing rtsp camera video stream based on Flume, which specifically includes the following steps:
[0026] S1. Create a public class named RtspSourceConstants. This class defines static variables whose values are the values of the configuration file variables read when the Flume system starts. The configuration file contains two parts: video source information and Flume event headers. Video source information includes the camera access path, camera number, and camera access protocol. The Flume event header includes the Kafka topic, event stamp, partition number, and offset.
[0027] S2. Define an abstract class inheriting the Source data source of the RTSP camera and name it AbstractSource. In this class, the data acquisition mechanism adopts the PollableSource interface. Rewrite the source code using JavaCV and configure the static variables read in S1 to customize the source based on Flume.
[0028] The specific steps are as follows:
[0029] S21. Rewrite the configure() method, pass the configuration parameters of the static variables read in S1 into this class, assign initial values to the member variables in the class, and the subsequent execution process is executed according to the configuration;
[0030] S22. Rewrite the start() method to set the RTSP camera connection properties and video source path. Create the ffmpeg object and video frame converter object based on the set properties. After the two core objects are successfully created, start the video stream capture thread and continuously extract frames.
[0031] S23, rewrite the stop() method to stop the RTSP video stream frame extraction thread and release the resource objects in the video stream frame extraction process;
[0032] S24. Rewrite the process() method to determine whether frame extraction failed based on the parameters in S1. If the frame extraction is successful, extract the keyframes from the video and convert them into BufferImage objects using a converter object. Set the Flume event header and obtain the Flume time object encapsulated in the video data in the BufferImage object, then send it to the Flume system channel.
[0033] S3. After the code is completed, package and compile it, and put the jar package into the specified directory of Flume.
[0034] S4. Connect the RTSP camera to the custom source of the Flume system to implement access for big data analysis and processing and extract frames.
Claims
1. A method for accessing rtsp camera video stream based on Flume, characterized in that: The following steps are involved: S1. Create a public class named RtspSourceConstants. The function of this class is to define some static variables. The values of the static variables are the values of the configuration file variables to be read when the Flume system starts; S2. Define an abstract class inheritance of the RTSP camera data source Source, named: AbstractSource, and configure the static variables read in S1 to customize the source based on Flume; S3. After the code is completed, package and compile it, and put the JAR package into the specified directory of Flume; S4. Connect the RTSP camera to the custom source of the Flume system to implement access for big data analysis and processing and perform frame extraction. Among them, S2 is specifically: S21. Rewrite the configure() method, pass the configuration parameters of the static variables read in S1 into this class, assign initial values to the member variables in the class, and the subsequent execution process is executed according to the configuration; S22. Rewrite the start() method to connect the video stream of the RTSP camera, set the connection properties and video source path of the RTSP camera, and create an ffmpeg object and a video frame converter object according to the set properties; after the ffmpeg object and the video frame converter object are successfully created, start the video stream capture thread and continuously extract frames; S23, rewrite the stop() method to stop the RTSP video stream frame extraction thread and release the resource objects in the video stream frame extraction process; S24. Rewrite the process() method to determine whether the frame extraction fails based on the parameters in S1. If it is determined to be a video, extract the frame from its thread; if it is successful, extract the key frames in the video, and convert the successfully extracted key frames into BufferImage objects through the converter object; set the Flume event header and obtain the Flume time object in the video data encapsulation in the BufferImage object, and send it to the channel of the Flume system.
2. A method for accessing rtsp camera video stream based on Flume according to claim 1, characterized in that, Step S1: Create a public class named RtspSourceConstants. The function of this class is to define some static variables. The values of the static variables are the values of the configuration file variables to be read when the Flume system starts. The configuration file contains: The video source information includes the camera access path, camera number, and camera access protocol, and the Flume event header includes the Kafka topic, event stamp, partition number, and offset.
Citation Information
Patent Citations
Video scene understanding method, device and system
CN114299416A