OpenCV 2.4.9 C++ cannot open video

asked 2014-11-07 10:04:04 -0500

Greetings,

I'm new using OpenCV and I have some issues when I try to open a video.

I'm using OpenCV2.4.9 with QT 5.3.2 on windows 7 x64. I'm trying to open a *.MOV file, but it doesn't open. Maybe I need to set some configuration on VideoCapture class, but i don't know which ones :S

Video information from ffprobe

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MVI_7683.MOV':   Metadata:
    major_brand     : qt
    minor_version   : 537331968
    compatible_brands: qt  CAEP
    creation_time   : 2014-06-12 11:07:45   Duration: 00:00:11.00, start: 0.000000, bitrate: 45493 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yu vj420p(pc, smpte170m/bt709/bt709), 1280x720, 43884 kb/s, 50 fps, 50 tbr, 50k tbn , 100k tbc (default)
    Metadata:
      creation_time   : 2014-06-12 11:07:45
    Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s1 6, 1536 kb/s (default)
    Metadata:
      creation_time   : 2014-06-12 11:07:45

Code to open the video:

#include <iostream>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

int main()
{
    VideoCapture cap("C://workspace//ForegroundDetection//Data//MVI_7683.MOV"); // Read the video
    // I try with "C:/workspace/ForegroundDetection/Data/MVI_7683.MOV" also

    if(!cap.isOpened())  // check if we succeeded
    {
         cout << "Cannot open the video file" << endl;
         return -1;
    }


    namedWindow("Video");
    while(1)
    {
        Mat frame;
        cap >> frame;         // get a new frame from camera
        imshow("Video", frame);

        // Press 'c' to escape
        if(waitKey(30) == 'c') break;
    }
    return 0;
}

Thanks in advance, Ibon

edit retag flag offensive close merge delete