Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV VideoWriter does not open file

Tags:

c++

opencv

The following code fails to open a VideoWriter object:

#include <iostream>

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

int main() {
    VideoWriter oVideo;
    oVideo.open ("381.avi", -1, 30, Size(640,480), true);
    if (!oVideo.isOpened()) {
        cout  << "Could not open the output video for write" << endl;
        return -1;
    }

    return 0;
}

I'm running OpenCV 2.4.9 pre-built with Code::Blocks on Ubuntu 12.04. I've written a number of images using imwrite() on the same location without issue, so I doubt it has to do with permissions. Also I tried CV_FOURCC('X','V','I','D') which did not work.

What am I missing here?

Any help is greatly appreciated.

like image 302
BdB Avatar asked Jun 05 '26 08:06

BdB


1 Answers

I reinstalled OpenCV using this amazing script: https://help.ubuntu.com/community/OpenCV

Solved.

like image 200
BdB Avatar answered Jun 06 '26 23:06

BdB