Video monitoring code stream analysis method and system based on PS packaging

Through the video surveillance code stream analysis method based on PS encapsulation, video fault analysis at video surveillance points is realized, which solves the problem that existing tools cannot handle video disorder and packet loss, and provides effective analysis and analysis of non-standardized code streams. Abnormal prompt analysis support significantly improves video surveillance analysis capabilities.

CN118764685APending Publication Date: 2024-10-11WUHAN FIBERHOME DIGITAL TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410942084.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2024-10-11

AI Technical Summary

Technical Problem

In the existing technology, video fault analysis tools at video monitoring points lack video stream format analysis functions and cannot effectively handle video out-of-order and packet loss problems. Professional analysis software has insufficient support for abnormal prompt analysis of non-standardized code streams.

Method used

Using the video surveillance code stream analysis method based on PS encapsulation, through packet capture file preprocessing, RTP information extraction and processing, removing RTP header, decapsulation and decoding, PS encapsulated video files are read frame by frame to realize video frame sequence image display and Output exception information and quickly locate code stream problems.

Benefits of technology

It solves the problem that the video monitoring tool itself does not have the video stream format analysis function. It can display video frame sequence images and quickly locate problems based on abnormal information, making up for the shortcomings of professional analysis software in the analysis of non-standardized code streams and abnormal prompts. .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118764685A_ABST
    Figure CN118764685A_ABST
Patent Text Reader

Abstract

A video monitoring code stream analysis method based on PS packaging comprises the following steps: S100, preprocessing a packet capture file to obtain a target stream file in the packet capture file; s200, carrying out RTP information extraction and processing on the target stream file to obtain RTP packet related information; s300, removing an RTP header from the processed RTP information stream, and splicing RTP PAYLOAD load data in RTP packet related information into a PS (Packet Switched) encapsulated video file taking a frame as a unit; s400, reading the PS encapsulated video file frame by frame, and de-encapsulating the PS encapsulated video file; and S500, decoding and displaying the video frame data after the de-encapsulation is carried out on the video frame data. According to the method and the device, the problem that in the prior art, a current package capturing tool does not have a function related to video code stream format analysis is solved, and the problem that current professional analysis software focuses on analyzing a standardized code stream and is slightly insufficient in the aspects of code stream abnormity prompt analysis and support is also solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of video analysis, and in particular to a video monitoring code stream analysis method and system based on PS encapsulation. Background Art

[0002] In the field of video surveillance and security technology, the national industry standard GB28181 stipulates the encapsulation and encoding standards of surveillance camera video code streams. In the national standard protocol, the encapsulation stipulates that it is encapsulated in MPEG-PS format and encoded as one of the video encoding technology standards such as H264 / H265 / SVAC. In actual industry applications, it is often necessary to perform video fault analysis on video surveillance points. A mainstream industry practice is to use packet capture tools to capture video streams of relevant points at the project site, and then perform the next technical analysis on the captured packets. However, the current packet capture tools do not have the relevant functions for video code stream format analysis. They can only perform some auxiliary analysis on network layer indicators such as packet loss rate, and the packet loss rate is basically invalid when the video is out of order. It is powerless to analyze professional technical fields such as video encapsulation / video decoding / video display. Although there are industry professional analysis software in related fields, and professional analysis software focuses on parsing standardized code streams, it is slightly insufficient in the prompt analysis and support of code stream anomalies. For non-professional industry users, it is a pain point in tool application. Summary of the invention

[0003] In view of the above problems, the present invention is proposed to provide a method and system for analyzing video surveillance code streams based on PS encapsulation, which overcomes the above problems or at least partially solves the above problems.

[0004] In order to solve the above technical problems, the embodiments of the present application disclose the following technical solutions:

[0005] In a first aspect, an embodiment of the present invention discloses a video surveillance code stream analysis method based on PS encapsulation, comprising:

[0006] S100. Obtain a target monitoring point video capture file, pre-process the capture file, and obtain a target stream file in the capture file;

[0007] S200 extracts and processes the RTP information of the target stream file to obtain RTP packet related information;

[0008] S300 removes the RTP header from the processed RTP information stream, and splices the RTP PAYLOAD payload data in the RTP packet related information into a PS encapsulated video file in frames;

[0009] S400. Read the PS encapsulated video file frame by frame, and decapsulate the PS encapsulated video file;

[0010] S500. Decode and display the decapsulated video frame data.

[0011] Further, in S100, the captured packet file is preprocessed to obtain a target stream file in the captured packet file, and the specific method includes:

[0012] S101. Use the packet capture tool to capture the video packet capture file of the target monitoring point;

[0013] S102. Parse and extract the captured packet file according to the network packet format to obtain a list of all network packet sequences;

[0014] S103. Use the port number or SSRC information to filter the packets in the network packet sequence list to obtain a network packet subset sequence of the target video stream.

[0015] Further, in S200, the RTP information of the target stream file is extracted and processed to obtain RTP packet related information, and the specific method includes:

[0016] S201. According to the standard RTP protocol, the obtained filter packet sequence information is parsed to obtain detailed information of each RTP packet, wherein the detailed information of the RTP packet includes at least: packet number, timestamp, packet interval time, PAYLOAD;

[0017] S202. Based on the sequence number of the RTP packet, the parsed RTP packet sequence is rearranged in ascending order;

[0018] S203. Check the continuity of the sorted RTP packet sequence, mark the discontinuous position number of the packet, and output it to the abnormal information file;

[0019] S204. Calculate the RTP packet loss rate and maximum time interval information according to the reordered RTP sequence.

[0020] Further, in S300, the RTP header is removed from the processed RTP information stream, and the RTPPAYLOAD payload data in the RTP packet related information is spliced ​​into a PS encapsulated video file in frames. The specific method includes:

[0021] S301. Detect whether each RTP PAYLOAD contains the start code 0x000x000x010xBA. If so, record the packet location;

[0022] S302. Sequentially splice the PAYLOAD contents between the RTP sequences where the two start codes are located, wherein the contents between the RTP packet where the first start code is located and the RTP packet where the second start code is located do not include the RTP packet where the second start code is located; after sequential splicing, output a PS packet file, wherein the PS packet file is written in a file format according to the frame sequence number, frame length and frame content format, and a frame information list file is recorded;

[0023] S303. For the abnormal situation that the same frame appears but the RTP packet timestamp is different and the PS start code offset is not 0, check and record are performed and output to the abnormal information file.

[0024] Further, in S400, the PS encapsulated video file is read frame by frame, and the PS encapsulated video file is decapsulated. The specific method includes:

[0025] S401 reads the PS packet file output by the frame extraction module frame by frame, first reads the frame length, and then reads the corresponding byte PS frame content according to the frame length;

[0026] S402. Parse the content of a single PS frame, and parse each field and content in the PS frame substructure one by one according to the MPEG-PS (ISO / IEC13818-1:2000) encapsulation standard; wherein a standard PS frame structure consists of a PS packet header, a system header, a program map table, and multiple PES packet parts;

[0027] S403. Check the actual length of PES. If the actual length of PES is less than the value specified in the format file, determine that the current data is missing and abnormal, and write the abnormal phenomenon, abnormal level, frame number, offset, and PES information position into the abnormal information file; at the same time, check whether the data contains a special system header, and the special system header includes 0x000x000x010xBD or 0x000x000x010xBH; then skip the special system header content, and give a warning output prompt in the abnormal information file to remind the user to process the item.

[0028] Furthermore, in S500, the decapsulated video frame data is decoded and displayed, and the specific method includes:

[0029] S501 establishes frame index information; with the PS frame number as the index, the corresponding information is the PS frame length, the offset of the PS frame in the PS packet file output by the frame extraction module, the length of the raw video data parsed in the PS frame, the raw video data parsed in the PS frame, the video encoding type, the frame type, and the frame index is established;

[0030] S502. For the target frame with the specified serial number, find the nearest key frame position on the left in the index, start from the nearest key frame, and gradually decode sequentially until the target frame. The data to be decoded is the raw stream video data in the index, and the YUV data is obtained after decoding;

[0031] S503. Use the graphics rendering SDK / API to render the YUV data.

[0032] In a second aspect, an embodiment of the present invention discloses a video surveillance code stream analysis system based on PS encapsulation, including: a packet capture preprocessing module, an RTP packet extraction module, a frame extraction module, a decapsulation module, a decoding and display module; wherein:

[0033] A packet capture preprocessing module is used to obtain a packet capture file of a target monitoring point video, preprocess the packet capture file, and obtain a target stream file in the packet capture file;

[0034] An RTP packet extraction module is used to extract and process the RTP information of the target stream file to obtain RTP packet related information;

[0035] The frame extraction module is used to remove the RTP header from the processed RTP information stream and splice the RTPPAYLOAD payload data in the RTP packet related information into a PS encapsulated video file in frames;

[0036] A decapsulation module, used for reading the PS-encapsulated video file frame by frame and decapsulating the PS-encapsulated video file;

[0037] The decoding and display module is used to decode and display the decapsulated video frame data.

[0038] Furthermore, the RTP packet extraction module is used to extract and process the RTP information of the target stream file to obtain RTP packet related information, and the specific method includes:

[0039] Parse the obtained filtered packet sequence information according to the standard RTP protocol to obtain detailed information of each RTP packet, wherein the detailed information of the RTP packet at least includes: packet sequence number, timestamp, packet interval time, and PAYLOAD;

[0040] Using the sequence number of the RTP packet as a comparison basis, the parsed RTP packet sequence is rearranged in ascending order;

[0041] Check the continuity of the sorted RTP packet sequence, mark the discontinuous position numbers of the packets, and output them to the abnormal information file;

[0042] According to the reordered RTP sequence, the RTP packet loss rate and maximum time interval information are calculated.

[0043] Furthermore, the decapsulation module is used to read the PS encapsulated video file frame by frame and decapsulate the PS encapsulated video file. The specific method includes:

[0044] Read the PS package file output by the frame extraction module frame by frame, first read the frame length, and then read the corresponding byte PS frame content according to the frame length;

[0045] Parse the content of a single PS frame, and parse each field and content in the PS frame substructure one by one according to the MPEG-PS (ISO / IEC13818-1:2000) encapsulation standard; wherein a standard PS frame structure consists of a PS packet header, a system header, a program map table, and multiple PES packet parts;

[0046] Check the actual length of PES. If the actual length of PES is less than the value specified in the format file, determine that the current data is missing and abnormal, and write the abnormal phenomenon, abnormal level, frame number, offset, and PES information position into the abnormal information file; at the same time, check whether the data contains a special system header, and the special system header includes 0x000x000x010xBD or 0x000x000x010xBH; skip the special system header content, and give a warning output prompt in the abnormal information file to remind the user to process this item.

[0047] In a third aspect, an embodiment of the present invention discloses an electronic device, including:

[0048] one or more processors;

[0049] A memory for storing one or more programs;

[0050] When the one or more programs are executed by the one or more processors, the one or more processors implement the video surveillance code stream analysis method.

[0051] The beneficial effects of the above technical solution provided by the embodiment of the present invention include at least:

[0052] The present invention discloses a video surveillance code stream analysis method based on PS encapsulation, comprising: S100. acquiring a video packet capture file of a target monitoring point, preprocessing the packet capture file, and obtaining a target stream file in the packet capture file; S200. extracting and processing RTP information of the target stream file, and acquiring RTP packet related information; S300. removing the RTP header of the processed RTP information stream, and splicing the RTP PAYLOAD payload data in the RTP packet related information into a PS encapsulated video file in frames; S400. reading the PS encapsulated video file frame by frame, and decapsulating the PS encapsulated video file; S500. decoding and displaying the decapsulated video frame data.

[0053] The present invention captures the original PS video packet. After the combined application of the present invention, the video frame sequence image can be displayed, and the problem existing in the original PS packet can be quickly located according to the image abnormality and the information abnormality file output, thereby solving the problem in the prior art that the current packet capture tool itself does not have the function related to the video code stream format analysis, and also solves the problem that the professional analysis software focuses on parsing the standardized code stream and is slightly insufficient in the prompt analysis and support for the code stream abnormality.

[0054] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0056] Figure 1 This is a flowchart of a video surveillance code stream analysis method based on PS encapsulation in Example 1 of the present invention;

[0057] Figure 2 This is a schematic diagram of the structure of an electronic device in Example 3 of the present invention. DETAILED DESCRIPTION

[0058] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0059] In order to solve the problems existing in the prior art, an embodiment of the present invention provides a video surveillance code stream analysis method and system based on PS encapsulation.

[0060] Example 1

[0061] The present invention discloses a video surveillance code stream analysis method based on PS encapsulation, comprising:

[0062] S100. Obtain a target monitoring point video capture file, pre-process the capture file, and obtain a target stream file in the capture file;

[0063] In S100 of this embodiment, the captured packet file is preprocessed to obtain a target stream file in the captured packet file. The specific method includes:

[0064] S101. Use the packet capture tool to capture the video packet capture file of the target monitoring point; specifically, install the corresponding packet capture tool on the monitoring device or server and enable the relevant functions. Configure the packet capture parameters, such as the packet capture interface, filter expression, etc., according to the requirements of the monitoring system and the network environment.

[0065] Use the remote start packet capture tool and start capturing network traffic according to the configuration. Using the command line tool, you can use the corresponding command and parameters to start the packet capture process. To capture packets, you need to configure the rpcapd service and install the corresponding service routine on the remote host.

[0066] S102. Parse and extract the captured packet file according to the network packet format to obtain a list of all network packet sequences;

[0067] S103. Use the port number or SSRC information to filter the packets in the network packet sequence list to obtain a network packet subset sequence of the target video stream.

[0068] S200 extracts and processes the RTP information of the target stream file to obtain RTP packet related information;

[0069] In this embodiment, in S200, the RTP information of the target stream file is extracted and processed to obtain RTP packet related information. The specific method includes:

[0070] S201. According to the standard RTP protocol, the obtained filter packet sequence information is parsed to obtain detailed information of each RTP packet, wherein the detailed information of the RTP packet includes at least: packet number, timestamp, packet interval time, PAYLOAD;

[0071] Specifically, the RTP packet (Real-time Transport Protocol Packet) is a protocol data packet used for audio and video communication. It provides end-to-end real-time transmission services for multimedia data (such as voice, images, etc.) that need to be transmitted in real time on the Internet; RTP Payload (RTP Payload), the payload contains the actual audio and video data. The specific format and content of the data depends on the audio and video encoding format specified by the payload type field.

[0072] S202. Based on the sequence number of the RTP packet, the parsed RTP packet sequence is rearranged in ascending order;

[0073] S203. Check the continuity of the sorted RTP packet sequence, mark the discontinuous position number of the packet, and output it to the abnormal information file;

[0074] S204. Calculate the RTP packet loss rate and maximum time interval information according to the reordered RTP sequence.

[0075] S300 removes the RTP header from the processed RTP information stream, and splices the RTP PAYLOAD payload data in the RTP packet related information into a PS encapsulated video file in frames;

[0076] In S300 of this embodiment, the RTP header is removed from the processed RTP information stream, and the RTPPAYLOAD payload data in the RTP packet related information is spliced ​​into a PS encapsulated video file in frames. The specific method includes:

[0077] S301. Detect whether each RTP PAYLOAD contains the start code 0x000x000x010xBA. If so, record the packet location;

[0078] S302. Sequentially splice the PAYLOAD contents between the RTP sequences where the two start codes are located, wherein the contents between the RTP packet where the first start code is located and the RTP packet where the second start code is located do not include the RTP packet where the second start code is located; after sequential splicing, output a PS packet file, wherein the PS packet file is written in a file format according to the frame sequence number, frame length and frame content format, and a frame information list file is recorded;

[0079] S303. For the abnormal situation that the same frame appears but the RTP packet timestamp is different and the PS start code offset is not 0, check and record are performed and output to the abnormal information file.

[0080] S400. Read the PS encapsulated video file frame by frame, and decapsulate the PS encapsulated video file; In S400 of this embodiment, the PS encapsulated video file is read frame by frame, and the PS encapsulated video file is decapsulated. The specific method includes:

[0081] S401 reads the PS packet file output by the frame extraction module frame by frame, first reads the frame length, and then reads the corresponding byte PS frame content according to the frame length;

[0082] S402. Parse the content of a single PS frame, and parse each field and content in the PS frame substructure one by one according to the MPEG-PS (ISO / IEC13818-1:2000) encapsulation standard; wherein a standard PS frame structure consists of a PS packet header, a system header, a program map table, and multiple PES packet parts;

[0083] S403. Check the actual length of PES. If the actual length of PES is less than the value specified in the format file, determine that the current data is missing and abnormal, and write the abnormal phenomenon, abnormal level, frame number, offset, and PES information position into the abnormal information file; at the same time, check whether the data contains a special system header, and the special system header includes 0x000x000x010xBD or 0x000x000x010xBH; then skip the special system header content, and give a warning output prompt in the abnormal information file to remind the user to process the item.

[0084] S500. Decode and display the decapsulated video frame data. In S500 of this embodiment, the decapsulated video frame data is decoded and displayed, and the specific method includes:

[0085] S501 establishes frame index information; with the PS frame number as the index, the corresponding information is the PS frame length, the offset of the PS frame in the PS packet file output by the frame extraction module, the length of the raw video data parsed in the PS frame, the raw video data parsed in the PS frame, the video encoding type, the frame type, and the frame index is established;

[0086] S502. For the target frame with the specified serial number, find the nearest key frame position on the left in the index, start from the nearest key frame, and gradually decode sequentially until the target frame. The data to be decoded is the raw stream video data in the index, and the YUV data is obtained after decoding;

[0087] S503. Use the graphics rendering SDK / API to render the YUV data.

[0088] The present embodiment discloses a method for analyzing a video surveillance code stream based on PS encapsulation, including: S100. Obtaining a packet capture file of a target surveillance point video, preprocessing the packet capture file, and obtaining a target stream file in the packet capture file; S200. Extracting and processing RTP information of the target stream file, and obtaining RTP packet related information; S300. Removing the RTP header from the processed RTP information stream, and splicing the RTP PAYLOAD payload data in the RTP packet related information into a PS encapsulated video file in frames; S400. Reading the PS encapsulated video file frame by frame, and decapsulating the PS encapsulated video file; S500. Decoding and displaying the decapsulated video frame data.

[0089] For original PS video packet capture, this embodiment can display video frame sequence images through the combined application of the present invention, and quickly locate the problems in the original PS packet based on image anomalies and information anomaly file outputs, thereby solving the problem in the prior art that the current packet capture tools themselves do not have the functions related to video bitstream format analysis, and also solves the problem that professional analysis software focuses on parsing standardized bitstreams, but is slightly insufficient in prompt analysis and support for bitstream anomalies.

[0090] Example 2

[0091] In order to better understand this embodiment, this embodiment takes a specific example as Embodiment 2. Specifically, there is UDP / RTP packet capture, the packet capture file is data.capture, PS encapsulation, (H264 video encoding, disorder, packet loss, RTP timestamp has two adjacent different timestamps but is actually the same frame phenomenon). The brackets are objectively present in the packet capture, but are hidden conditions unknown to the user layer. The user layer playback is abnormal, freezes, screen distortion, etc., and the reasons are to be analyzed.

[0092] The specific analysis steps are as follows:

[0093] Step 1: Packet capture preprocessing, the process is as follows:

[0094] a) Parse and extract the captured packet file. According to the network packet format, all network packet sequences can be obtained:

[0095] Result=ParsePacket("data.capture")

[0096] The returned results are similar to:

[0097] <data.capture:TCP:xx1 UDP:xx2...>

[0098] It means there are xx2 UDP packets in data.capture;

[0099] b) Use the target port number (observed from the packet capture) to filter the UDP packets in the network packet sequence list in Result to obtain the network packet subset sequence of the target video stream, recorded as subResult. The subResult result is similar:

[0100] <Source IP / Source IP Port-Destination IP / Destination IP Port-UDP raw data> Several tuple parts. RTP information is in UDP raw data;

[0101] Step 2: Extract RTP packets. The process is as follows:

[0102] a) Perform RTP format parsing on the subResult sequence information of the filtering packet obtained by the pre-processing module to obtain detailed information of each RTP packet: RTPInfo{RTP packet sequence number / PAYLOAD TYPE / timestamp / PAYLOAD, etc.};

[0103] b) Using the sequence number of the RTP packet as the comparison basis, the parsed RTPInfo List is rearranged in ascending order. Since the RTP sequence number only occupies two bytes and ranges from 0 to 65535, it will flip periodically, so the sequence number comparison function CompareRTPSeq needs to be overloaded. The function definition is as follows:

[0104]

[0105]

[0106] The definition of the flip flag flow_sign is as follows:

[0107]

[0108] With this specially designed comparison function, the sequence numbers of two RTPs can be compared even if the adjacent RTP sequence numbers are flipped, thereby arranging the entire RTP sequence in ascending order.

[0109] c) Check the continuity of the sorted RTP packet sequence, mark the discontinuous position number of the packet (if the RTP sequence number is reversed, it is considered continuous), and output it to the abnormal information file;

[0110] d) Calculate the RTP packet loss rate and other information based on the reordered RTP sequence number sequence (a(j), j=1-N, N is the total number of RTP packets);

[0111] Number of RTP packet losses

[0112] Packet loss rate = M / N, write the packet loss rate value to the exception information file.

[0113] Step 3: Frame extraction processing: sequentially extract PS frame information from the ascending RTP sequence in step 2. The steps are as follows:

[0114] The RTP sequence information is recorded as a(j)j=0~N-1, where N is the total number of RTP packets.

[0115] Design a structure information PSTag, including two attribute values: seq (rtp sequence number value), lastseq (previous rtp sequence number value), offset (ps header offset value).

[0116] a) For each PAYLOAD part of a(j) (remove the remaining data part of the RTP header), search for the 0x000x000x010xBA flag. If it appears, record the offset in PAYLOAD as offset, and put PSTag(curseq, lastseq, offset) into the result queue ResultTag. If offset is not 0, it means that there is abnormal data that should not be in front of the PS header or it is glued together with the previous packet. Write the PSTag information and abnormal prompts into the abnormal information file; if there is no such flag, continue j=j+1 and continue to search the PAYLOAD of the next a(j);

[0117] b) Sequentially traverse the queue ResultTag (j = 0 ~ K-2, K is the number of elements in the queue), for two adjacent elements ResultTag[j], ResultTag[j+1], beginSeq = ResultTag[j].seq, endSeq = ResultTag[j+1].lastseq, perform PAYLOAD splicing on the RTP subsequences between beginSeq <= j <= endSeq in a(j): design a frame memory of sufficient size and an initial value of empty, denoted as psBuffer, and a variable for recording the length of the frame memory, denoted as psLength, with an initial value of 0, and sequentially copy the PAYLOAD of each RTP in the RTP subsequence between beginSeq <= j <= endSeq to the end of psBuffer, and at the same time, add the length value of the PAYLOAD to psLength. After the splicing is completed, write the frame number, psLength, and psData into the PS packet file in sequence. At the same time, the frame sequence number, beginSeq, endSeq, and ResultTag[j].offset information are written to the frame information list file for use as auxiliary data. After analyzing abnormal data from the PS packet file, the corresponding specific RTP packet position in the original captured packet file can be quickly located.

[0118] In particular, when traversing the RTP packets between beginSeq and endSeq, the RTP timestamp of the first RTP packet is used as a benchmark to check whether different RTP timestamps appear in the RTP sequence. If so, it indicates that the RTP protocol encapsulation is abnormal and multiple RTP timestamps appear in the same frame. The corresponding frame sequence number, RTP sequence number, and abnormal timestamp information are written into the abnormal information file.

[0119] Step 4: decapsulate the PS frame. The steps are as follows:

[0120] a) Read the PS packet file output by the frame extraction module frame by frame, first read the frame sequence number (curSeq) and frame length (psLength), and then read the PS frame content of psLength bytes in sequence, recorded as psBuffer;

[0121] b) Parse the content of a single PS frame, record offset as the distance and offset of the psBuffer address, the initial value is 0, when offset>=psLength, it means the parsing of psBuffer is complete. Record curHeaderPointer=psBuffer+offset, curHeaderData represents the four-byte content starting from curHeaderPointer. The specific traversal steps are as follows:

[0122] B1: Check whether curHeaderData is the same as PS Pack Header (0x000x000x010xBA). If so, data = curHeaderPointer+4+9. Figure 1 The calculation method in is used to move L bytes backward (offset=4+10+data[9]&0x07), offset=offset+L, and proceed to step B2. If not, write the frame lacking PS Header exception information into the exception information file, and then proceed to step B2.

[0123] B2: Check whether curHeaderData starts with PS System Header (0x000x000x010xBB). If so, Figure 1 Move L bytes backward according to the calculation method (length is the content of the last two bytes of curHeaderData+4, L=4+2+length), offset=offset+L, and proceed to step B3. If not, jump directly to step B3;

[0124] B3: Check whether curHeaderData starts with PS Program Stream Map (0x000x000x010xBC). If so, Figure 1 Move backward L bytes offset (L = 4 + 4 + 2 + length1 + 2 + length2 + 4, length1 is the content of the last two bytes of curHeaderData + 4, length2 is the content of the last two bytes of curHeaderData + 4 + 2 + length1), offset = offset + L, proceed to step B4, if not, jump directly to B4;

[0125] B4: Check if curHeaderData starts with a PES packet (0x000x000x010xE0 (video packet) or 0x000x000x010xC0 (audio packet)). If so, calculate the length of the current PES packet (the length is the value of the 2 bytes after E0), and then verify this PES packet length to check if the actual length is less than <length>. The definition of the actual length value is the length from the 3rd byte after E0 / C0 to the next PS sub-structure (starting with 0x000x00 0x01, mainly the PES (0x000x000x010xE0 / 0xC0) structure, and very rarely a system header carrying private data, such as 0x000x000x010xBD / 0xBH) (if this PES packet is the last PES, it is the length from the 3rd byte to the end of the PS frame data). If it is found that the actual length is less than <length>, it belongs to serious data loss and anomalies, which will cause phenomena such as gray screens and pixelated screens. Write information such as the anomaly phenomenon, anomaly level, frame number, offset, and which PES into the anomaly information file, and at the same time exit the frame parsing program, jump to B1, and start parsing the next frame; if it is equal to the length, it is a normal encapsulation. After moving L bytes of offset backward (L = 4 + 2 + length), offset = offset + L, repeat step B4 until the last PES, end the parsing of this frame, jump to B1, and start parsing the next frame; if it is not a PES packet, jump to B5;

[0126] B5: Check if curHeaderData is a special system header (0x000x000x010xBD or 0x000x000x010xBH). If it is this system header, move L bytes of offset backward (L = 4 + 2 + length), offset = offset + L. If it has reached the end of the frame after the offset and there is no other data, directly jump to B1 and start parsing the next frame. If there is still remaining data, jump to B4; if it is a packet type that cannot be recognized, end the parsing of this frame, write the unrecognized warning information into the anomaly information file, and at the same time jump to B1 and start parsing the next frame;

[0127] In particular, for step B4, for multiple PES structures that have been parsed in one frame, a raw video frame buffer is set to save the pure video data after removing the PS encapsulation, recorded as buffer, with an initial value of null. Each time a PES is parsed, the pure data part of the PES is added to the end of the buffer (the content from the third byte after 0xE0 to the end, that is, the length part of the data parsed in B4). After parsing, the PTS / DTS and other values ​​are parsed according to the MPEG-PS standard. The value unit of PTS is usually ms, and the PTS difference between two adjacent frames (the smallest value) is recorded as diff. The theoretical frame rate of the code stream fps=1000 / diff can be calculated, and the RTP timestamp interval should be 90000 / fps. According to these theoretical values, the actual RTP timestamp of the frame is verified. If there is a very large deviation, the non-standard RTP timestamp information is written into the abnormal analysis file.

[0128] Step 5: The specific process of decoding and display is as follows:

[0129] a) Establish frame index information: Use the PS frame number as the index, and the corresponding information is the PS frame length, the offset of the PS frame in the PS package file output by the frame extraction module, the length of the raw stream video data parsed in the PS frame, the raw stream video data parsed in the PS frame, the video encoding type, and the frame type (I frame / P frame) to establish the frame index. The video encoding type is determined by selecting the raw stream video data of the first frame. If 0x00 0x00 0x01 xx appears, and xx is one of 0x67 / 0x68 / 0x27 / 0x28 / 0x65 / 0x45 / 0x25 / 0x61 / 0x21 / 0x41 / 0x06, it is regarded as H264 encoding. If 0x000x000x01 xx appears, and xx is one of 0x02 / 0x40 / 0x42 / 0x44 / 0x26, it is regarded as h265 encoding. The method of judging the frame type is that for h264 encoding, if 0x000x000x010x65 / 0x45 / 0x25 appears, it is regarded as an I frame, and if it does not appear, it is regarded as a P frame. For h265 encoding, if 0x000x000x010x26 appears, it is regarded as an I frame, and if it does not appear, it is regarded as a P frame.

[0130] b) For the target frame with the specified sequence number i, find the nearest key frame position on the left in the index, record it as j, and gradually decode from frame j to frame i. The data to be decoded is the raw stream video data in the index, and the YUV data is obtained after decoding;

[0131] c) After converting the YUV data into RGB data, use the graphics rendering API to render it in the specified window (hwnd).

[0132] d) You can play each frame in sequence, or drag it to any position and specify any frame to decode and display.

[0133] For the packet capture file data.capture, after the above steps, the information anomaly file, frame information list file, and PS package file are obtained. After the PS package file is imported into the decoding and display module, any frame can be viewed. According to the overall analysis information such as the packet loss rate in the abnormal information file, a general macroscopic understanding of the packet data situation can be obtained. For frames with abnormal images, the abnormal analysis result prompts in the information anomaly file (whether packet loss, disorder, packet loss position, disorder position, RTP protocol encapsulation standardization in the frame, PS encapsulation standardization, etc.) and the corresponding actual RTP sequence number segment in the frame information list file can be located according to the frame sequence number, and the actual position in the captured packet can be quickly located for comparison and viewing, and the analysis results and phenomena are intuitively given: H264 video encoding, disorder, packet loss, specific location:..., RTP timestamps have two adjacent segments with different timestamps, which are actually the same frame phenomenon, specific location:..., combined with the picture display, it is very easy to locate, display and trace the source.

[0134] For UDP / RTP packet capture, H265 video encoding, PS encapsulation, no disorder, no packet loss, user layer playback has flowery or gray screen.

[0135] The internal analysis process of the tool is the same as that of the specific embodiment 1. There is a gray screen in the decoding and display module display sequence, and some frames have only half of the picture, and the other half is gray. After selecting a specific gray screen frame, check the frame number, search the frame number in the exception information file, and get the prompt information: the length of the i-th PES of the frame is abnormal and defective, and the actual data length is less than the theoretical value. According to the frame information list, the RTP sequence number segment of the frame is queried. After finding the frame on the packet capture tool, the i-th PES is sequentially located. After manual calculation, the phenomenon is confirmed and the feedback evidence is directly submitted to the relevant operation and maintenance personnel.

[0136] Example 3

[0137] This embodiment discloses a video surveillance code stream analysis system based on PS encapsulation, including: a packet capture preprocessing module, an RTP packet extraction module, a frame extraction module, a decapsulation module, and a decoding and display module; wherein:

[0138] A packet capture preprocessing module is used to obtain a packet capture file of a target monitoring point video, preprocess the packet capture file, and obtain a target stream file in the packet capture file;

[0139] An RTP packet extraction module is used to extract and process the RTP information of the target stream file to obtain RTP packet related information;

[0140] The frame extraction module is used to remove the RTP header from the processed RTP information stream and splice the RTPPAYLOAD payload data in the RTP packet related information into a PS encapsulated video file in frames;

[0141] A decapsulation module, used for reading the PS-encapsulated video file frame by frame and decapsulating the PS-encapsulated video file;

[0142] The decoding and display module is used to decode and display the decapsulated video frame data.

[0143] Among them, the specific working methods of the packet capture preprocessing module, the RTP packet extraction module, the frame extraction module, the decapsulation module, and the decoding and display module have been described in detail in Example 1, and will not be repeated in this embodiment.

[0144] Based on the same inventive concept, an embodiment of the present disclosure also provides an electronic device. Figure 1 FIG. 1 is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. Figure 1 As shown, an embodiment of the present disclosure provides an electronic device including: one or more processors 101, a memory 102, and one or more I / O interfaces 103. The memory 102 stores one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement any optimization method in the above embodiments; the one or more I / O interfaces 103 are connected between the processor and the memory, and are configured to implement information interaction between the processor and the memory.

[0145] Among them, the processor 101 is a device with data processing capabilities, including but not limited to a central processing unit (CPU), etc.; the memory 102 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface (read-write interface) 103 is connected between the processor 101 and the memory 102, and can realize information interaction between the processor 101 and the memory 102, including but not limited to a data bus (Bus), etc.

[0146] In some embodiments, the processor 101 , the memory 102 , and the I / O interface 103 are connected to each other via a bus 104 , and further connected to other components of the computing device.

[0147] In some embodiments, the one or more processors 101 include a field programmable gate array.

[0148] According to an embodiment of the present disclosure, a computer-readable medium is further provided, wherein a computer program is stored on the computer-readable medium, wherein when the program is executed by a processor, the steps in any optimization method in the above-mentioned embodiment are implemented.

[0149] It should be understood that the specific order or hierarchy of steps in the disclosed process is an example of an exemplary method. Based on design preferences, it should be understood that the specific order or hierarchy of steps in the process can be rearranged without departing from the scope of protection of the present disclosure. The attached method claims present the elements of the various steps in an exemplary order and are not intended to be limited to the specific order or hierarchy described.

[0150] In the above detailed description, various features are grouped together in a single embodiment to simplify the disclosure. This method of disclosure should not be interpreted as reflecting an intention that the embodiments of the claimed subject matter require more features than are clearly stated in each claim. On the contrary, as reflected in the appended claims, the invention is in a state of having less than all the features of the disclosed individual embodiments. Therefore, the appended claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.

[0151] Those skilled in the art will also appreciate that the various illustrative logic blocks, modules, circuits, and algorithmic steps described in conjunction with the embodiments herein can all be implemented as electronic hardware, computer software, or a combination thereof. In order to clearly illustrate the interchangeability between hardware and software, various illustrative components, blocks, modules, circuits, and steps are generally described above around their functions. Whether such functions are implemented as hardware or software depends on specific applications and the design constraints imposed on the entire system. A skilled person can implement the described functions in an alternative manner for each specific application, but such implementation decisions should not be interpreted as departing from the scope of protection of the present disclosure.

[0152] The steps of the method or algorithm described in conjunction with the embodiments herein may be directly embodied as hardware, a software module executed by a processor, or a combination thereof. The software module may be located in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a mobile disk, a CD-ROM, or any other form of storage medium well known in the art. An exemplary storage medium is connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Of course, the storage medium may also be an integral part of the processor. The processor and the storage medium may be located in an ASIC. The ASIC may be located in a user terminal. Of course, the processor and the storage medium may also be present in a user terminal as discrete components.

[0153] For software implementation, the techniques described in this application can be implemented with modules (e.g., procedures, functions, etc.) that perform the functions described in this application. These software codes can be stored in a memory unit and executed by a processor. The memory unit can be implemented within the processor or outside the processor. In the latter case, it is coupled to the processor in a communication manner via various means, which are well known in the art.

[0154] The above description includes examples of one or more embodiments. Of course, it is impossible to describe all possible combinations of components or methods for the purpose of describing the above embodiments, but it should be recognized by those skilled in the art that the various embodiments may be further combined and arranged. Therefore, the embodiments described herein are intended to cover all such changes, modifications and variations that fall within the scope of protection of the appended claims. In addition, with respect to the term "comprising" used in the specification or claims, the word is covered in a manner similar to the term "including", just as "including," is explained as a transitional word in the claims. In addition, any term "or" used in the specification of the claims is intended to mean "non-exclusive or".

Claims

1. A video surveillance code stream analysis method based on PS encapsulation, characterized in that: include: S100. Obtain a target monitoring point video capture file, pre-process the capture file, and obtain a target stream file in the capture file; S200 extracts and processes the RTP information of the target stream file to obtain RTP packet related information; S300 removes the RTP header from the processed RTP information stream, and splices the RTP PAYLOAD payload data in the RTP packet related information into a PS encapsulated video file in frames; S400. Read the PS encapsulated video file frame by frame, and decapsulate the PS encapsulated video file; S500. Decode and display the decapsulated video frame data.

2. A video monitoring code stream analysis method based on PS encapsulation as claimed in claim 1, characterized in that: In S100, the captured packet file is preprocessed to obtain a target stream file in the captured packet file. The specific method includes: S101. Use the packet capture tool to capture the video packet capture file of the target monitoring point; S102. Parse and extract the captured packet file according to the network packet format to obtain a list of all network packet sequences; S103. Use the port number or SSRC information to filter the packets in the network packet sequence list to obtain a network packet subset sequence of the target video stream.

3. A video monitoring code stream analysis method based on PS encapsulation as claimed in claim 2, characterized in that: In S200, the RTP information of the target stream file is extracted and processed to obtain RTP packet related information. The specific method includes: S201. According to the standard RTP protocol, the obtained filter packet sequence information is parsed to obtain detailed information of each RTP packet, wherein the detailed information of the RTP packet includes at least: packet number, timestamp, packet interval time, PAYLOAD; S202. Based on the sequence number of the RTP packet, the parsed RTP packet sequence is rearranged in ascending order; S203. Check the continuity of the sorted RTP packet sequence, mark the discontinuous position number of the packet, and output it to the abnormal information file; S204. Calculate the RTP packet loss rate and maximum time interval information according to the reordered RTP sequence.

4. A video monitoring code stream analysis method based on PS encapsulation as claimed in claim 1, characterized in that: In S300, the RTP header is removed from the processed RTP information stream, and the RTP PAYLOAD payload data in the RTP packet related information is spliced ​​into a PS encapsulated video file in frames. The specific method includes: S301. Detect whether each RTP PAYLOAD contains the start code 0x000x000x010xBA. If so, record the packet location; S302. Sequentially splice the PAYLOAD contents between the RTP sequences where the two start codes are located, wherein the contents between the RTP packet where the first start code is located and the RTP packet where the second start code is located do not include the RTP packet where the second start code is located; after sequential splicing, output a PS packet file, wherein the PS packet file is written in a file format according to the frame sequence number, frame length and frame content format, and a frame information list file is recorded; S303. For the abnormal situation that the same frame appears but the RTP packet timestamp is different and the PS start code offset is not 0, check and record are performed and output to the abnormal information file.

5. The video monitoring code stream analysis method based on PS encapsulation as claimed in claim 1, characterized in that: In S400, the PS encapsulated video file is read frame by frame, and the PS encapsulated video file is decapsulated. The specific method includes: S401 reads the PS packet file output by the frame extraction module frame by frame, first reads the frame length, and then reads the corresponding byte PS frame content according to the frame length; S402. Parse the content of a single PS frame, and parse each field and content in the PS frame substructure one by one according to the MPEG-PS (ISO / IEC13818-1:2000) encapsulation standard; wherein a standard PS frame structure consists of a PS packet header, a system header, a program map table, and multiple PES packet parts; S403. Check the actual length of PES. If the actual length of PES is less than the value specified in the format file, determine that the current data is missing and abnormal, and write the abnormal phenomenon, abnormal level, frame number, offset, and PES information position into the abnormal information file; at the same time, check whether the data contains a special system header, and the special system header includes 0x000x000x010xBD or 0x000x000x010xBH; then skip the special system header content, and give a warning output prompt in the abnormal information file to remind the user to process the item.

6. A video monitoring code stream analysis method based on PS encapsulation as claimed in claim 1, characterized in that: In S500, the decapsulated video frame data is decoded and displayed, and the specific method includes: S501 establishes frame index information; with the PS frame number as the index, the corresponding information is the PS frame length, the offset of the PS frame in the PS packet file output by the frame extraction module, the length of the raw video data parsed in the PS frame, the raw video data parsed in the PS frame, the video encoding type, the frame type, and the frame index is established; S502. For the target frame with the specified serial number, find the nearest key frame position on the left in the index, start from the nearest key frame, and gradually decode sequentially until the target frame. The data to be decoded is the raw stream video data in the index, and the YUV data is obtained after decoding; S503. Use the graphics rendering SDK / API to render the YUV data.

7. A video monitoring code stream analysis system based on PS encapsulation, characterized in that: include: Packet capture preprocessing module, RTP packet extraction module, frame extraction module, decapsulation module, decoding and display module; among them: A packet capture preprocessing module is used to obtain a packet capture file of a target monitoring point video, preprocess the packet capture file, and obtain a target stream file in the packet capture file; An RTP packet extraction module is used to extract and process the RTP information of the target stream file to obtain RTP packet related information; The frame extraction module is used to remove the RTP header from the processed RTP information stream and splice the RTPPAYLOAD payload data in the RTP packet related information into a PS encapsulated video file in frames; A decapsulation module, used for reading the PS-encapsulated video file frame by frame and decapsulating the PS-encapsulated video file; The decoding and display module is used to decode and display the decapsulated video frame data.

8. The video monitoring code stream analysis system based on PS encapsulation as claimed in claim 7, characterized in that: The RTP packet extraction module is used to extract and process the RTP information of the target stream file to obtain RTP packet related information. The specific method includes: Parse the obtained filtered packet sequence information according to the standard RTP protocol to obtain detailed information of each RTP packet, wherein the detailed information of the RTP packet at least includes: packet sequence number, timestamp, packet interval time, and PAYLOAD; Using the sequence number of the RTP packet as a comparison basis, the parsed RTP packet sequence is rearranged in ascending order; Check the continuity of the sorted RTP packet sequence, mark the discontinuous position numbers of the packets, and output them to the abnormal information file; According to the reordered RTP sequence, the RTP packet loss rate and maximum time interval information are calculated.

9. The video monitoring code stream analysis system based on PS encapsulation as claimed in claim 7, characterized in that: The decapsulation module is used to read the PS encapsulated video file frame by frame and decapsulate the PS encapsulated video file. The specific method includes: Read the PS package file output by the frame extraction module frame by frame, first read the frame length, and then read the corresponding byte PS frame content according to the frame length; Parse the content of a single PS frame, and parse each field and content in the PS frame substructure one by one according to the MPEG-PS (ISO / IEC13818-1:2000) encapsulation standard; wherein a standard PS frame structure consists of a PS packet header, a system header, a program map table, and multiple PES packet parts; Check the actual length of PES. If the actual length of PES is less than the value specified in the format file, determine that the current data is missing and abnormal, and write the abnormal phenomenon, abnormal level, frame number, offset, and PES information position into the abnormal information file; at the same time, check whether the data contains a special system header, and the special system header includes 0x000x000x010xBD or 0x000x000x010xBH; skip the special system header content, and give a warning output prompt in the abnormal information file to remind the user to process this item.

10. An electronic device comprising: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method for video surveillance code stream analysis in claims 1-6.

Citation Information

Cited By

  • Mobile video coordinate coding method and system based on GB35114

    CN119628891A