Gray frames/lost pixes

Hello guys.

I’m using the opencv_contrib_python_rolling-4.12.0.86-cp37-abi3-win_amd64.whl, to read a video streaming (RTSP link).

What happens, is that, usually video is getting gray frames, in part of image or in total image.


Example above.

When I open the RTSP link on VLC, it works perfecly, the same when I open the ipcam management system. We have a clean video, in the same computer. This is the reason which I can not think the problem is bad/slow network.

Please, any sugestion?
Thanks and best regards.

gray (or green) frames happen when there hasn’t been a keyframe yet.

if you make it decode the stream right away, it’s “starting” somewhere other than the beginning of the stream, so it’s getting predictive frames first, not a keyframe.

the picture will snap to what it should be as soon as there’s a keyframe.

So, how to solve this question?

As I said, when I open the same camera at the same time in VLC the image is perfect.

Other question: It is very common when we got moviment (cars crossing camera) the image getting frozen, it is not a “fluid” image and again, in VLC image is perfect.

How to solve both questions? Should I put any extra config in opencv setup?
Thanks.

I don’t know what exactly you did, I haven’t seen the code you run, I don’t know anything about your video source, how you set it up, … I can’t even replicate the issue.

in any case, I can’t help with RTSP issues. RTSP is not an area I specialize in.

@crackwitz It sounds like the classic, not injesting fast enough so they’re loosing frames, but it will become clearer with a MRE.

Ok, here is how I conect to my rtsp source:

cap = cv2.VideoCapture("rtsp://admin:admin@10.90.50.206:554/cam/realmonitor?channel=1&subtype=0")

Below a snapshot of same rtsp link in opencv and in VLC:

This is my video source:

In same computer where I’m playing opencv, I have the NVR software of intelbras where I did a lot of records (more than 10 hours) and did not get any grayscreen:

Any sugestion?

OpenCV is using either gstreamer or ffmpeg (libraries).

get those standalone and as CLI programs. run those on their own. see what they do with your stream.

Thanks for your support @crackwitz.
Sorry, but maybe I did not understand correctly you suggestion.

Your answer means that opencv is using the video libraries: gstreamer or ffmpeg and I should test my stream in a program which use these libraries, right?

Is not that exactly what I did in my print screen above, when I compare VLC to opencv, same time, same camera? I showed the stream running perfectly in VLC and grayscreen in opencv.

Sorry about misunderstanding. I wait for your support.
Thanks and best regards.

no. VLC uses neither gstreamer nor ffmpeg libraries.

Guys, problem solved.

I started opencv without yolo. Worked fine.So, the problem was the interaction of Opencv with yolo. I put booth in diferent threads.
Working nice.

Hope this topic can help others with same problem.
Thanks and best regards.

AKA, not injesting frames fast enough!

that’s why we ask for a MRE, so that you can’t omit such details.

you must be jesting :stuck_out_tongue:

1 Like