Question

Running Windows 7, x64 with OpenCV 2.4.8 (pre-built binaries).

Trying the following basic code:

VideoWriter wrt;
wrt.open("video.mp4",  -1, 29, Size(480, 640));

This does nothing. The expected popup for codec selection does not open, nor is the writer getting open (i.e. a call to wrt.isOpen() returns false). Also, the internal pointer inside the writer class wrt.writer remains null.

Tried:

  1. Both Debug and Release OpenCV binaries.
  2. Copying opencv_ffmpeg248.dll to the executable's directory according to this.
  3. Passing exclusive codec codes such as CV_FOURCC('M','P','4','2') and others.
  4. Hitting the computer.

Nothing worked. Any help/direction would be appreciated..

Was it helpful?

Solution

Try VideoWriter wrt; wrt.open("video.avi", -1, 29, Size(480, 640));

OTHER TIPS

VideoCapture cap;
VideoWriter videoWriter;

cap.open(0);
if (!cap.isOpened())
{
    printf("can not open camera or video file\n");
    return ;
}
string namemove("foo.AVI");
int fourCC = CV_FOURCC('M', 'J', 'P', 'G');
Size S = Size((int)cap.get(CAP_PROP_FRAME_WIDTH), (int)cap.get(CAP_PROP_FRAME_HEIGHT));
int fps = cap.get(CAP_PROP_FPS);
videoWriter.open(namemove, -1, cap.get(CAP_PROP_FPS), S, true);


if (!videoWriter.isOpened())
{
    cerr << "Cannot open output file " << endl;

    return ;
}

Mat img0;
namedWindow("image", WINDOW_NORMAL);

for (;;)
{
    cap >> img0;
    if (img0.empty())
        break;

    videoWriter << img0;

    imshow("image", img0);
    char k = (char)waitKey(30);
    if (k == 27) break;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top