I have used following line of code to the video writer CvVideoWriter* writer = cvCreateVideoWriter("D:\Cam.avi",CV_FOURCC('M','J','P','G'),10,size,1); I dont know whether that codec supports .avi file nor I know my camera has capabibility of producing that quality