Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

VideoCapture doesn't work with video files

My environment: Windows 7 x64 Qt 5.1.1 OpenCV 2.4.7

I have no problems opening video streams using VideoCapture class, but when it comes to opening files(like .avi or .mp4) the VideoCapture object says, that the file wasn't opened. (Tried with both absolute and relative paths) - on error messages, only isOpened returns false.

From what I've read, it has something to do with ffmpeg, but I have no idea, how I should fix it.

What should I do to be able to open video files?

string filepath[6];
filepath[0] = "C:\\absolute\\path\\test.mp4";
filepath[1] = "C:/absolute/path/test.mp4";
filepath[2] = "test.mp4";

filepath[3] = "C:\\absolute\\path\\test.avi";
filepath[4] = "C:/absolute/path/test.avi";
filepath[5] = "test.avi";

cv::VideoCapture cap;
for(int i = 0; i < 6; ++i){
    cout << filepath[i] << " ";
    cout << cap.open(filepath[i]) << endl; //always returns 0
}