Ask Your Question

lb's profile - activity

2019-01-12 02:51:21 -0600 received badge  Popular Question (source)
2016-10-12 06:20:17 -0600 received badge  Student (source)
2015-04-23 04:01:01 -0600 commented answer Saving gray images to .avi with VideoWriter and Lagarith codec

Thanks for your answer! From executing OpenCV in Debug mode it seems Video For Windows is used internally. Encoding color images is OK. Saving the images as png could be a good workaround but I leave the question open to see if there are other options.

2015-04-23 03:56:16 -0600 received badge  Editor (source)
2015-04-21 11:07:41 -0600 asked a question Saving gray images to .avi with VideoWriter and Lagarith codec

I wish to save grayscale images to a (small) avi file with the Lagarith codec under Windows in a 32 bit application compiled with Visual C++ 2010 and OpenCV 2.4.10. I'm using the VideoWriter object from highgui. However, the function VideoWriter::open returns false --see the following code snippet:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;

int main(int argc, char* argv[]){
    VideoWriter outputVideo;
    if (!outputVideo.open("test.avi", CV_FOURCC('L', 'A', 'G', 'S'), 25.0, Size(800, 600), false))
        std::cout << "Couldn't open VideoWriter" << std::endl;
}

Is this the expected behaviour? I could convert my gray image to a color image but as far as I know the Lagarith codec compresses each channel separately so I think it would increase the size of the resulting video. How can I get the smallest possible video file?

Edit:

  • Encoding color images works.
  • I compiled OpenCV in debug mode and it seems Video For Windows is being used for compression.