Ask Your Question

Revision history [back]

Hi Pascal,

I have tried your code and it works for me (with OpenCV 2.3.1).

Are you sure that the codec used to generate your video is supported in your system? (I have tried with an avi video encoded with MJPG codec and it works)

Also, this should not be an issue, but when you initialize your video capture:

VideoCapture cap(0);

The parameter 0 that you are passing to the constructor means that the capture device should be "the first webcam found in the system". It might be better to initialize it just as

VideoCapture cap;

But, again, I don't think this is the issue in your case. You should make sure that you have the proper codecs installed.