Handling decode errors from H264 IpCam stream with OpenCV


I’m using the cv::VideoCapture class to stream h264 content from an IP Camera and using ofxCv’s Utilities
to convert matrices to oF format. My main issue is every once in a while frames look glitch. I get warnings/errors in console (from VideoCapture/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  

How can I ‘listen to’/handle these error message so I can skip processing glitchy frames ?

1 Like

Did you ever figure out how to handle this?

@cnrmck Welcome to the forums !

Oh wow that’s on old one !
I still remember the headaches though and I’ve asked on stackoverflow as well.

See sturkmen’s answer here:

and his demo here
I haven’t tried it myself, but others reported it works.
It boiled down to using a newer version(3+) of the opencv_ffmpeg library, part of OpenCV.

Back in 2012 I’ve used Marek Bereza’s 64bit version of OpenFrameworks and OpenCV 2.4.1 (if I recall) compiled from source (which has a great mixture of grandients background subtractor).

I don’t know what this means for the current version of OF and ofxOpenCV (with the version of OpenCV it ships with). It might involve compiling OpenCV from source and integrating it with OF.