A method and system for detecting a video frame transmission break based on a polling timeout

By introducing a polling timeout mechanism and a multi-semantic state machine into the video frame transmission of the UAV cloud platform, the problems of permanent blocking at the receiving end and lack of handshake signals are solved, enabling rapid disconnection detection and resource management, and improving system responsiveness and resource utilization efficiency.

CN123185342APending Publication Date: 2026-11-27HANGZHOU CAIQI TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611179839.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-05
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing video frame transmission solutions for drone cloud platforms suffer from issues such as the risk of permanent blocking at the receiving end, lack of semantic distinction of handshake signals during the connection establishment phase, and confusion between frame transmission end signals and normal frame data.

Method used

A video frame transmission interruption detection method based on polling timeout is adopted. By setting timeout parameters at the receiving end and combining a multi-semantic state machine to judge the return result and length value of the polling method, the semantic distinction of events such as normal frame data, zero frame end signal, video source opening failure and connection timeout is realized, and the corresponding processing flow is executed on a single communication channel.

Benefits of technology

It effectively eliminates the risk of permanent blocking of the receiving thread, shortens the interruption detection latency to within 500 milliseconds, improves system responsiveness and resource management efficiency, and reduces the overhead of repeated loading and releasing of GPU resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123185342A_ABST
    Figure CN123185342A_ABST
Patent Text Reader

Abstract

The application discloses a video frame transmission cut-off detection method and system based on polling timeout, and belongs to the technical field of unmanned aerial vehicle cloud platform video stream processing. The method comprises the following steps: a receiving end calls a polling method through a connection object and sets a timeout parameter; when the polling returns true, a 4-byte little-endian byte sequence length prefix is received and parsed into a length value; multi-semantics judgment is performed on the length value to distinguish zero frame signals, valid frame data and handshake phase timeout events; in the case of valid frames, image compression format encoded frame data bodies are read and returned to an inference pipeline. The application takes the polling timeout as a protocol semantic component through a multi-semantics state machine, eliminates the risk of permanent blocking of the receiving end, realizes accurate distinction of five types of communication events on a single communication channel, and reduces the cut-off detection delay after interruption of an RTMP source stream from the minute level to within 500 milliseconds.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of video stream processing technology for UAV cloud platforms, specifically relating to a method and system for detecting video frame transmission interruption based on polling timeout. Background Technology

[0002] In the video inspection service of the drone cloud platform, video frames are transmitted between processes via a Python multi-process pipeline (Pipe). The sending end is responsible for reading frames from the RTMP video stream and encoding them into image compression formats, while the receiving end is responsible for decoding the image compression format frames and performing AI inference. Existing Pipe communication solutions only provide basic send / receive primitives and lack semantic detection capabilities for transmission anomalies.

[0003] Firstly, in the existing solution, if the sender has not sent data when the receiver calls the receive method, the receive method will block the receive thread indefinitely. This makes it impossible for the receiver to distinguish between permanent blocking caused by sender failure and normal frame interval waiting. After the RTMP source stream is interrupted, the receiver thread will remain blocked and unresponsive until it is forcibly terminated externally. The average recovery time exceeds 15 minutes, which seriously affects the availability of the 24 / 7 drone inspection service.

[0004] Secondly, the existing solution lacks a mechanism for differentiating handshake signals during the connection establishment phase, meaning the receiving end cannot determine the root cause of connection failure during the initial connection attempt. When the sending end is unable to provide service due to reasons such as unavailable video source files, network unavailability, or abnormal process exit, the receiving end can only obtain general timeout or connection error information and cannot take targeted recovery strategies based on the specific cause of failure. For example, if the video source file does not exist, maintenance personnel should be notified to check the file path; if the network is unreachable, network reconnection should be triggered instead of file checking.

[0005] Third, existing solutions use the same transmission channel for the end-of-frame data transmission signal (zero frame) and normal frame data, but lack semantic markers. The receiver must rely on additional out-of-band signals or timeout mechanisms to determine whether the stream has ended. When the sender actively sends a zero frame to indicate the end of the stream, if the zero frame arrives late during transmission due to pipeline buffering, the receiver may misjudge the stream interruption before receiving the zero frame, triggering unnecessary process restarts, causing repeated loading and releasing of GPU resources, and increasing system overhead. Summary of the Invention

[0006] The technical problem this invention aims to solve is that, in the multi-process video frame transmission scenario of a drone cloud platform, existing Pipe communication solutions suffer from the risk of permanent blocking at the receiving end, lack of semantic distinction of handshake signals during the connection establishment phase, and confusion between frame transmission end signals and normal frame data.

[0007] To address the aforementioned technical problems, this invention provides a video frame transmission interruption detection method based on polling timeout, comprising at least the following steps: The receiving end calls a polling method through a connection object, sets a timeout parameter, and waits for readable data within the time specified by the timeout parameter; when the polling method returns true, the receiving end receives a 4-byte length prefix through the connection object's receive method, and parses it into an unsigned integer length value in little-endian byte order format; multiple semantic judgments are performed on the length value: when the length value is equal to 0, it is determined to be a zero-frame signal, triggering a resource reclamation process; when the length value is greater than 0, it is determined to be valid frame data, and the frame data reception step begins; when the polling method returns false and it is the first connection scenario, it is determined to be a timeout event in the handshake phase, distinguishing between three handshake states: video source opening failure signal, start reading success signal, and connection timeout; when the length value is greater than 0, the receiving end reads the image compression format encoded frame data body in bytes of the length value through the connection object's receive method; the received image compression format encoded frame data body is returned to the inference processing pipeline to complete one video frame transmission.

[0008] The beneficial effects of this invention are as follows: By introducing a polling method mechanism with a timeout parameter at the Pipe receiver, the traditional blocking receiving method is replaced with a polling method that can return a timeout, eliminating the risk of permanent blocking of the receiver thread. When the RTMP source stream is interrupted, the receiver can detect the no-data state after a 500-millisecond timeout. Compared to the minute-level recovery time required by the traditional blocking receiving method which requires external forced termination, this invention reduces the interruption detection latency to less than 500 milliseconds. Through the joint judgment of the polling method return result and the length value by a multi-semantic state machine, semantic distinctions are achieved for five types of communication events on a single communication channel: normal frame data, zero-frame end signal, video source opening failure, successful start-up reading, and connection timeout. The receiver can execute the corresponding processing flow according to different event types. By treating timeout as a component of protocol semantics rather than a fault fallback, the receiver can maintain responsiveness even during the normal frame interval waiting period and can immediately process other control signals after a timeout, improving the overall responsiveness of the system. Attached Figure Description

[0009] Figure 1 This is a flowchart of the method in an embodiment of the present invention.

[0010] Figure 2 This is the state transition diagram of the multi-semantic state machine in this embodiment of the invention.

[0011] Figure 3 This is a comparison chart of blockage recovery time and detection accuracy in an embodiment of the present invention.

[0012] The meanings of the markings in the diagram are as follows: Figure 1101 - The receiving end calls the polling method to set the timeout parameter; 102 - Polling returns true and readable data has been detected; 103 - Multi-semantic judgment of the byte array length value; 104 - Receive frame data body image compression format encoding; 105 - Distinguish handshake signal type; 106 - Determine if it is a zero frame signal and trigger the resource reclamation process; 107 - Perform processing or terminate according to the handshake status; 108 - Return the frame data body to the inference pipeline.

[0013] Figure 2 201 - Idle state, 202 - Handshake detection state, 203 - Frame reception state, 204 - Disconnection detection state, 205 - Resource reclamation, 206 - Service termination.

[0014] Figure 3 301 - Normal Pipe with no timeout solution; 302 - Fixed timeout polling solution; 303 - Multi-semantic state machine solution of this invention; 304 - Normal frame detection; 305 - Zero frame identification; 306 - Handshake signal differentiation; 307 - Abnormal disconnection detection. Detailed Implementation

[0015] The technical solution of the present invention will now be described in detail with reference to the accompanying drawings.

[0016] This invention provides a video frame transmission interruption detection method based on polling timeout, applied to a multi-process communication scenario in a UAV cloud platform video detection service. In this scenario, the video frame reading process (process_readFrame) is responsible for decoding frame data from the RTMP video stream and performing image compression format encoding, while the inference process (process_infer) is responsible for receiving image compression format frames and performing AI object detection. A bidirectional communication connection is established between the two processes via Python multi-processing .Pipe.

[0017] Reference Figure 1 The flowchart shown indicates that after the method begins execution, it first proceeds to step S101 (as shown). Figure 1 (As shown in mark 101): When waiting for frame data, the receiving end calls the polling method of the connection object, passing in a timeout parameter of 500 milliseconds. The polling method returns a boolean value: true indicates that there is readable data in the connection object, and false indicates that no data has arrived within the timeout parameter. This design allows the receiving end to block for a maximum of 500 milliseconds each time it waits, after which it can continue to execute subsequent logic regardless of whether there is data.

[0018] like Figure 1As indicated by reference numerals 102 and 103, steps S102 and S103 are executed in sequence: when the polling method returns true, the receiving end first receives a 4-byte length prefix via the receive method of the connection object. This length prefix is encoded by the transmitting end into a 4-byte little-endian unsigned integer with format code `<I` via the `struct.pack` method before transmitting frame data. After the receiving end parses this prefix to obtain the length value, it proceeds to Figure 1 the multi-semantic judgment branch shown in judgment node 103. The specific semantic distinction logic of this judgment node can be further referred to Figure 2 the multi-semantic state machine state transition diagram shown in

[0019] The first semantic branch (corresponding to Figure 1 the zero-frame branch of node 103, and the trigger condition "length value equals 0" in the frame reception → stream interruption detection transition shown in Figure 2 ): When the length value equals 0, it is determined that the transmitting end has sent a zero-frame signal, indicating that the RTMP video stream has ended or the transmitting end has actively stopped. Based on this, the receiving end triggers a complete six-step resource recovery process (as shown in the stream interruption detection → resource recovery state transition in Figure 2 ): The first step is to stop the inference process `process_infer` and the frame reading process `process_readFrame`; the second step is to disconnect the MQTT client connection and release network resources; the third step is to set the `trainer` model object to `None` to release references; the fourth step is to execute `gc.collect()` to force Python garbage collection; the fifth step is to call `paddle.device.cuda.empty_cache()` to clear the GPU memory cache; the sixth step is to close the streaming pipeline to release encoder resources. Taking the test in an actual deployment environment as an example, after a server equipped with an NVIDIA Tesla T4 GPU runs the inference service 7x24 hours, executing this six-step recovery process can reduce the GPU memory usage from 3.2GB before recovery to 0.1GB after recovery, with a memory leakage amount of 0MB.

[0020] The second semantic branch (corresponding to Figure 1 the valid frame data branch of node 103): When the length value is greater than 0, the receiving end continues to read the image compression format encoded frame data body of the length value bytes via the receive method, as indicated by reference numeral 104 in Figure 1 . Taking the encoding with a resolution of 1920x1080 and an image compression format quality parameter of 85 as an example, the size of a single frame of image compression format data body is usually 80000 to 250000 bytes. The receiving end creates a numpy array from the read image compression format bytes via `numpy.frombuffer` zero-copy, then decodes it into a BGR format image via `cv2.imdecode`, and subsequently executes step S108 (as shown in Figure 1As shown in label 108, the received image compressed format encoded frame data body is returned to the inference processing pipeline to complete a complete frame transmission. The entire process does not go through the file system and has no disk I / O overhead.

[0021] The third semantic branch (corresponding to) Figure 1 The timeout branch of node 103, and Figure 2 (Idle → Handshake Detection State Transition and Handshake Detection → Frame Reception Transition): When the polling method returns false and this polling method occurs in the initial connection scenario, the receiving end enters the handshake detection logic. For example... Figure 2 As shown, the system enters the handshake detection state (handshake detection) from the idle state. After a timeout, the receiving end attempts to read a string message from the connection object for semantic analysis. If the string "video source opening failed" is read, it indicates that the sending end cannot open the specified video source file (e.g., ...). Figure 2 Interruption detection → Service termination transfer (as shown in the diagram), the receiving end records an error log and terminates the connection with the sending end, notifying the upper-layer service that the video source is unavailable. If the string "Initial reading successful" is read, it indicates that the sending end has successfully opened the video source and started reading frames normally (e.g., ...). Figure 2 (As shown in the handshake detection → frame reception state transition), the receiving end switches to the normal frame reception state. Subsequent polling methods returning false only indicate waiting for the frame interval. If no string data is received after an additional 500 milliseconds, it is determined that the network layer connection has timed out (e.g., ...). Figure 2 (As shown in the Idle → Resource Recycling state transition), the receiving end re-initiates a Pipe connection request with the sending end.

[0022] In one specific implementation scenario of this invention, the RTMP streaming device mounted on a drone experiences a streaming interruption due to flying out of signal coverage. Under traditional blocking reception methods, the receiving thread of the inference process remains blocked until maintenance personnel manually restart the service after detecting the anomaly through the monitoring system, with an average recovery time exceeding 15 minutes (900,000 milliseconds). With the solution of this invention, the receiving end detects no data arrival within 500 milliseconds, and then completes zero-frame semantic judgment and six-step resource reclamation after approximately 100 milliseconds, completing the entire process from stream interruption detection to resource reclamation in approximately 600 milliseconds, shortening the recovery time by approximately 1500 times compared to traditional solutions. Furthermore, because the fifth step in the reclamation process actively calls `cuda.empty_cache()` to clear the GPU cache, subsequent new inference tasks do not need to wait for the GPU memory to be naturally released; new inference tasks can be started immediately with full available GPU memory after service recovery.

[0023] like Figure 3The comparison chart shows that, during a continuous 72-hour stability test simulating 50 RTMP streaming interruption events, the average interruption detection latency of the proposed solution was 487 milliseconds, and the worst-case detection latency was 523 milliseconds. All 50 interruption events were correctly detected and triggered complete resource reclamation, with no missed detections. Figure 3 The detection accuracy data shows that the accuracy rate of normal frame detection is 99.8%, the accuracy rate of zero frame recognition is 100%, the accuracy rate of handshake signal differentiation is 95.0%, and the accuracy rate of abnormal disconnection detection is 98.5%, which fully verifies the technical effect of the present invention.

Claims

1. A video frame transmission interruption detection method based on polling timeout, characterized in that, Includes at least the following steps: The receiving end calls the polling method through the connection object and sets a timeout parameter, so that the receiving end waits for readable data for the time specified by the timeout parameter; when the polling method returns true, the receiving end receives the 4-byte length prefix through the receiving method of the connection object, and parses it into an unsigned integer length value in little-endian byte order format; the length value is subjected to multiple semantic judgments: when the length value is equal to 0, it is determined to be a zero frame signal, triggering the resource reclamation process; When the length value is greater than 0, it is determined to be valid frame data, and the frame data reception step is initiated. When the polling method returns false and it is the first connection scenario, it is determined to be a timeout event in the handshake phase. It distinguishes between three handshake states: video source opening failure signal, start reading success signal, and connection timeout. If the length value is greater than 0, the receiving end reads the image compression format encoded frame data body in bytes of length value through the receiving method of the connection object. The received image compression format encoded frame data body is returned to the inference processing pipeline to complete one video frame transmission.

2. The method according to claim 1, wherein, The timeout parameter is set to 500 milliseconds. When the polling method does not detect readable data within the timeout period, it returns false. The receiving end uses this to distinguish between the no-data state and the zero-frame state.

3. The method according to claim 1, wherein, The timeout events during the handshake phase are distinguished as follows: when the receiver receives a video source opening failure string after the first polling timeout, it is determined that the video source opening has failed and the connection is terminated; when the receiver receives a start-up read success string after the first polling timeout, it is determined that the start-up read has been successful and the receiver enters the normal frame reception state. If the receiver does not receive any data after the initial polling timeout, it is determined that the connection has timed out and a new connection request is initiated.

4. The method according to claim 1, wherein, The 4-byte length prefix uses little-endian byte order encoding. Before sending the image compression format encoded frame data body, the sending end first encodes the number of bytes of the frame data body into 4-byte binary data blocks for transmission.

5. The method according to claim 1, wherein, The resource recycling process includes, in sequence: stopping the inference process, disconnecting the message queue telemetry transmission connection, releasing the inference model object, performing garbage collection, clearing the parallel computing unit cache, and closing the push pipeline.

6. A video frame transmission interruption detection system based on polling timeout, characterized in that, include: The timeout polling module is used by the receiving end to call the polling method through the connection object and set the timeout parameter, so that the receiving end waits for readable data for the time specified by the timeout parameter. The length prefix parsing module is used to receive a 4-byte length prefix through the connection object's receive method when the polling method returns true, and parse it into a length value of an unsigned integer in little-endian byte order. The multi-semantic judgment module is used to perform multi-semantic judgments on the length value. When the length value is equal to 0, it is determined to be a zero-frame signal triggering resource reclamation; when the length value is greater than 0, it is determined to be valid frame data entering frame data reception; when the polling method returns false and it is the first connection scenario, it distinguishes between three handshake states. The frame data reception module is used to read the image compression format encoded frame data body in the case of valid frame data. The frame data transmission module is used to return the received image compressed format encoded frame data body to the inference processing pipeline.

7. The system according to claim 6, wherein, The timeout parameter is set to 500 milliseconds. When the polling method does not detect readable data within the timeout period, it returns false. The receiving end uses this to distinguish between the no-data state and the zero-frame state.

8. A streaming media server for a drone cloud platform, characterized in that, The system comprising any one of claims 6 to 7.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 5.