Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with cv::VideoCapture decode errors?

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 ?

like image 248
George Profenza Avatar asked Jul 24 '12 18:07

George Profenza


People also ask

What is CV VideoCapture?

cv::VideoCapture Class Reference. Class for video capturing from video files, image sequences or cameras.

How does cv2 VideoCapture work?

cv2. VideoCapture is a function of openCV library(used for computer vision, machine learning, and image processing) which allows working with video either by capturing via live webcam or by a video file.

What does cv2 VideoCapture return?

The VideoCapture class returns a video capture object which we can use to display the video. The class has several methods, for example, there is the get() method which takes a property identifier from cv2.


1 Answers

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 )

like image 166
sturkmen Avatar answered Sep 17 '22 13:09

sturkmen