How to deal with cv::VideoCapture decode errors?
Asked Answered
T

3

14

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 ?

Twowheeler answered 24/7, 2012 at 18:8 Comment(1)
facing the same problem.... any solution???Ninanincompoop
S
3

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 )

Seizing answered 24/2, 2016 at 0:28 Comment(2)
I haven't tried this yet, but it looks much more elegant than trying to pipe in the error messages and skip frames.Twowheeler
recently my approach explained by Mare on his blogSeizing
T
0

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

Tribunate answered 24/6, 2014 at 8:45 Comment(2)
you're right, I had an endless loop, but haven't found a solution to the problem. I was thinking about piping in the console output from opencv/ffmpeg and using frames only when no decoding errors were encountered as hacky work around, but haven't got around to implement that or find a more elegant solutionTwowheeler
I thought about the same, but I have no idea on how to do this .. :/Tribunate
Z
0

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!!!

Zorazorah answered 21/6, 2018 at 9:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.