Ask Your Question
2

VideoWriter produces empty videos

asked 2012-10-21 17:05:35 -0600

John gravatar image

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-10-23 17:38:16 -0600

John gravatar image

I'll answer my own question. I upgraded to ffmpeg 0.11 from 0.8 and it solved the problem.

edit flag offensive delete link more

Comments

Can someone direct me to info on how to compile/link/install ffmpeg into a project so that VideoWriter can use it in a windows / C++ context?

storm gravatar imagestorm ( 2012-12-06 13:34:14 -0600 )edit

I think ffmpeg is Linux only.

John gravatar imageJohn ( 2012-12-31 02:44:17 -0600 )edit

Question Tools

Stats

Asked: 2012-10-21 17:05:35 -0600

Seen: 1,800 times

Last updated: Oct 23 '12