I am using OpenCV 2.4.3 to read and write a video file. My code is like this:
cv::VideoCapture video;
video.open ( "D:\\testVideo.avi" );
cv::VideoWriter output;
output.open ( "D:\\outputVideo.avi", CV_FOURCC('D','I','V','X'), 120, cv::Size ( 1200,1600), true );
cv::Mat img;
for ( int n = 0; ; n ++ )
{
video >> img;
output.write ( img );
}
Then the result video was an empty file, and I couldn't open it. What did I do wrong here?