RTSP ffmpeg set flags

There is a lot of latency when capture RTSP stream. When using ffplay with -fflags nobuffer -flags low_delay almost no latency. How can i pass this flags to ffmpeg via opencv. If it is not possible can i change source code of opencv to set flags?

If you are not on Windows I would think setting this with av_dict_set should work, see

It is however possible the delay is due to the fact you are not requesting the frames quickly enough in which case this might not make any difference.

1 Like

Thank you. I use Windows. A seperate thread captures the stream. After your answer, I set environment variable OPENCV_FFMPEG_CAPTURE_OPTIONS =fflags;nobuffer|flags;low_delay but i did not work. Then i changed source code cap_ffmpeg_impl.hpp. I compiled in Visual Studio but nothing changed. I think it compiled from binary opencv_videoio_ffmpeg_64.dll. i changed cmakelist.txt of videoio add src cap_ffmpeg.cpp caused a lot of lib error.

That’s correct which is why my comment above specified not on windows.

In windows you can try building against FFMpeg, see

I decided tobuild opencv with gstreamer. Then i used latency=0 parameter in rtsp uri this solved my problem. thank you for your help.