# Delay problem when capturing RTSP video

**URL:** <https://forum.opencv.org/t/delay-problem-when-capturing-rtsp-video/6925>\
**Category:** C++\
**Tags:** gstreamer, videoio\
**Created:** [January 1, 2022, 1:13pm UTC](https://forum.opencv.org/t/delay-problem-when-capturing-rtsp-video/6925 "2022-01-01T13:13:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yusuf\_satilmis](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/yusuf_satilmis/32/1821_2.png) [@yusuf\_satilmis](https://forum.opencv.org/u/yusuf_satilmis)\
**Post date:** [January 1, 2022, 1:13pm UTC](https://forum.opencv.org/t/delay-problem-when-capturing-rtsp-video/6925/1 "2022-01-01T13:13:37Z")

</div>

In my project, I need to process by capturing the RTSP broadcast with OpenCV. For this, I compiled openCV 4.5.4 to use gstreamer in the background (Windows). But when I capture the RTSP video with OpenCV, the delay is around 3-4 seconds. When I open it with the gst-launch-1.0 command, there is a delay of around 250-300ms.

> gst-launch-1.0 -v rtspsrc latency = 30 location=rtspt://192.168.1.119:554 ! application/x-rtp, payload=96 ! rtph264depay ! avdec\_h264 ! videoconvert ! autovideosink sync=false
> 
> or
> 
> gst-launch-1.0 -v rtspsrc latency = 0 location=rtspt://192.168.1.119:554 ! application/x-rtp, payload=96 ! rtph264depay ! h264parse ! nvh264dec ! videoconvert ! autovideosink sync=false

When I run it with commands, the delay is 250-300ms.

> path =“rtspsrc latency = 30 location=rtsp://192.168.1.119:554 ! rtph264depay ! decodebin ! videoconvert ! appsink”;
> 
> or
> 
> path =“rtspsrc latency = 30 location=rtspt://192.168.1.119:554 ! application/x-rtp, payload=96 ! rtph264depay ! nvh264dec ! videoconvert ! appsink”;
> 
> VideoCapture cap(path, **CAP\_GSTREAMER** );

But when I capture it with OpenCV and play it with imshow, there is an unacceptable amount of delay.

How can I solve this?
