How to deal with cv::VideoCapture decode errors?

旧街凉风 提交于 2019-12-08 15:35:15

问题


I'm streaming H264 content from an IP camera using the VideoCapture from OpenCV (compiled with ffmpeg support).

So far things work ok, but every once in a while I get decoding errors (from ffmpeg I presume):

[h264 @ 0x103006400] mb_type 137 in I slice too large at 26 10
[h264 @ 0x103006400] error while decoding MB 26 10
[h264 @ 0x103006400] negative number of zero coeffs at 25 5
[h264 @ 0x103006400] error while decoding MB 25 5
[h264 @ 0x103006400] cbp too large (421) at 35 13
[h264 @ 0x103006400] error while decoding MB 35 13
[h264 @ 0x103006400] mb_type 121 in P slice too large at 20 3
[h264 @ 0x103006400] error decoding MB 20 3

These messages show up in the console. Is there any clean way to listen to these ? I'd like to skip processing the glitchy frames.

Any hints/tips ?


回答1:


recently i have solved the same problem and try to explain the steps i followed.

i updated most recent opencv_ffmpeg.dll ( i renamed opencv_ffmpeg.dll to opencv_ffmpeg310.dll to use with OpenCV 3.1, also renamed same dll opencv_ffmpeg2412.dll to use with OpenCV 2.4.12

by doing that, a basic capturing frames and display became successful without problem.but still the same problem if i do some image-processing or detection causes delay between capturing frames.

to solve the second problem i used a thread to grab frames continiously and update a global Mat for processing.

here you can find my test code ( it need some improvements like using mutex and lock memory when update the Mat)

i hope the information will be useful ( sorry for my poor english )




回答2:


I have the same problem. It seems to me that the problem comes from the fact that the source originating the stream is slower than the one decoding. Probably for the decoding you have an endless loop reading frames and decoding them, which might be faster than what your source can send you.

I don't know how to stop and wait until the buffer is full .. I'm using a file, such that my camera source writes a file and I read frames from it in my decoding program. So far I haven't been able to synch them




回答3:


what sturkmen said is absolutely right, the opencv version is 2413, and for some reason, I can not update the opencv to 310, I know there is gonna be no any decoding error like this for opencv310. So firstly, I copy lib opencv_ffmpeg310_64.dll to my executable file path E:\GITHUB\JpegRtspCamera\vs2013\JpegRtspCamera\x64\Release

then I just delete opencv_ffmpeg2413.dll and change the name opencv_ffmpeg310_64.dll to opencv_ffmpeg2413.dll. it works!!!



来源:https://stackoverflow.com/questions/11636766/how-to-deal-with-cvvideocapture-decode-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!