Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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?

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.