I’m trying to play a video using opencv (the video is an avi file stored on the disk). However, the program stops execution on the following line in cap_ffmppeg.cpp:
if(!ffmpegCapture ||
!icvRetrieveFrame_FFMPEG_p(ffmpegCapture,&data,&step,&width,&height,&cn))
return 0;
The error is: Access violation reading location… so a seg fault is occurring the first time capture >> frame is run.
Here is the program:
#include<iostream>
#include<fstream>
#include<cv.h>
#include<highgui.h>
#include<opencv2/nonfree/features2d.hpp>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
if (argc <= 1)
{
printf("Usage: %s video\n", argv[0]);
return -1;
}
VideoCapture capture(argv[1]);
if(!capture.isOpened())
{
printf("Failed to open the video\n");
return -1;
}
for(;;)
{
Mat frame;
capture >> frame; // get a new frame from camera
}
return 0;
}
Any idea what I’m doing wrong?
Turned out that OpenCV couldn’t play the uncompressed video. Compressed it and all is well… don’t know why the original problem exists tho.