Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

VideoWriter produces empty videos

I'm using OpenCV 2.4.9 (from the source) but I can no longer write videos using VideoWriter. I have FFmpeg 0.7.11 installed.

My code is really nothing special:

  VideoCapture capture;
  capture.open(FLAGS_input_video);
  CHECK(capture.isOpened());

  double fps = capture.get(CV_CAP_PROP_FPS);
  int width = capture.get(CV_CAP_PROP_FRAME_WIDTH);
  int height = capture.get(CV_CAP_PROP_FRAME_HEIGHT);

  VideoWriter writer(FLAGS_output_video, CV_FOURCC('M', 'P', '4', '2'), fps, Size(width, height));

  for (int i = 0; capture.grab(); ++i) {
    Mat frame;
    capture.retrieve(frame);

    writer << frame;
  }

Previously, I was able to write video just fine using OpenCV 2.3.1.