Open xxtkidxx opened 1 day ago
Hi @xxtkidxx ,
In the project, the FFmpeg decoding method is set to TCP by default:
ffmpeg_cmd = [ 'ffmpeg', '-rtsp_transport', 'tcp', '-loglevel', 'error', '-i', camera_url, '-vf', 'fps=1', '-f', 'rawvideo', '-pix_fmt', 'bgr24', # Using 'bgr24' format 'pipe:' ]
TCP is reliable but may introduce latency due to its acknowledgment and retransmission mechanisms. If real-time performance is a higher priority for your use case, switching to UDP as the transport protocol can help reduce the delay.
P.S You might be able to further reduce the delay by implementing the following mechanisms: lowering the FPS, adjusting the FPS buffer size, or using FFmpeg's low-latency mode, among others.
Hi @dan246 Thanh you for response, My camera (HIKVision) not support UDP protocol. When I uncomment the lines '-rtsp_transport', 'tcp', error has occurred When I use the config as shown in the photo, the delay is reduced to about 0.7s. Frame recognition delay is about 1s It seems like it's the best result right now
Hi @xxtkidxx,
Thank you for your response and for sharing your findings. I understand your situation and the limitations with your camera. I will continue researching decoding techniques to further reduce latency. If I discover any new optimizations, I’ll make sure to update the project.
Likewise, if you make any progress or find a solution, please feel free to share it as well. Thank you!
Hi @dan246 I am very interested in your project and willing to contribute my finding. There is a problem of 300ms delay between stream and recognized stream when I use model Yolo11n.pt I checked that the frame processing time on yolo is only 50ms What is your opinion on this? Is it because of your mainloop function in the Docker recognize object? According to me due:
Hi @dan246 I have got delay about 1 second when using the RTSP link from a HIK camera I tried both your OpenCV Code and FFMPEG Code on Worker Docker How to reduce delay?