I just wrote a simple video reading example with openCV2.3.1, but it seems that I cannot open avi video anyway :(
VideoCapture capture("guitarplaying.avi");
if(!capture.isOpened()){
std::cout<<"cannot read video!\n";
return -1;
}
Mat frame;
namedWindow("frame");
double rate = capture.get(CV_CAP_PROP_FPS);
int delay = 1000/rate;
while(true)
{
if(!capture.read(frame)){
break;
}
imshow("frame",frame);
if(waitKey(delay)>=0)
break;
}
capture.release();
I made a breakpoint in std::cout<<"cannot read video!\n"
and find that it stopped here every time. So why avi video cannot be opened? Thanks!
A missing OpenCV's ffmpeg.dll does not generate any warnings/errors in OpenCV 2.3.1, and code fails silently. Make sure that you have proper opencv_ffmpeg*.dll in your path.