http://stackoverflow.com/questions/37359374/opencv2-4-videowriter-create-single-frame-video-out-of-image-file
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.