Ask Your Question

bluebug's profile - activity

2016-05-21 03:26:56 -0500 asked a question OpenCV2.4 VideoWriter Create single frame video out of image file

http://stackoverflow.com/questions/37...

int main() {
    //simple example I came up with to test out my understanding of the library 
    IplImage* img = cvLoadImage("img1.jpg", CV_LOAD_IMAGE_UNCHANGED);
    CvSize imgSize = cvGetSize(img);
    cv::Mat frame = cv::cvarrToMat(img); //will be used to write on the videowriter
    cv::VideoWriter writerNew("out.avi", CV_FOURCC('M', 'J', 'P', 'G'), 20, imgSize, true);
    if (!writerNew.isOpened())
    {
        std::cout << "FAIL";
        return -1
    }
    writerNew.write(frame);         
    return 0;

}

Program runs. But the video file I get is corrupted(I cannot open-play it).

I wish I got an error message to guide me. However since I get no error message, I am completely lost.