简体   繁体   中英

OpenCV RTSP H264 capture

I am using OpenCV 2.4.5 on windows 7 to capture RTSP stream.But I am getting some corrupt images in between.I found that the error is in decoding in ffmpeg layer.I want to drop these corrupt frames.But I am not able to do that because opencv Mat::empty never returns true. What could be the root cause of this and please let me know the solution for the same.

Here is an image for the reference:

One fix to be this problem could be to force the RTSP protocol to use TCP as a transport. you can append ?tcp into your URL eg rtsp://ip-address:port/xyz?tcp then pass it to open method.

This solution worked for me and I have tried with Axis, D-Link, Acti and Panasonic.

I'm using 2.4.6 and no such frames. Nevertheless, ffmpeg is known to have issues with parsing h264 frames. Look for ffmpeg h264 parser patch or similar. Building ffmpeg with the patch and using it in your project should solve it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM