2

I would like to write all my image files entitled "pictures_1/2/3/etc..." into a video file.

The code below is creating the video.avi file successfully. However, there is no data written inside the latter.

I'm aware that the videocapture opencv function is mainly used to capture data from a video, but i heard it was possible to use it for images too (As described here (1rst answer))

void video (void)
  {
  VideoCapture in_capture("/path/.../pictures_%d.jpg");
  Mat img;


  VideoWriter out_capture("path/.../video.avi", CV_FOURCC('M','J','P','G'), 30, Size(1989,1680));

  while (true)
  {
    in_capture >> img;
    if(img.empty())
        break;

    out_capture.write(img);
  }
}
Community
  • 1
  • 1
  • Could it be the codec problem? Mind showing your main() file too? So we can narrow down the possibilities(: Tag me in the comments when you are done(: – rockinfresh Mar 31 '14 at 15:52

1 Answers1

3

Possible reason for no video created.

  1. Make sure that your image is successfully loaded, just use imshow() in while loop.

  2. Your image size can be any size other than 1989X1680, so either resize your image to given size or set out video resoluton to input image size.

Haris
  • 13,645
  • 12
  • 90
  • 121