Making a video with opencv, getting only 1 frame
Question: I've been trying to add a video making module to my program using opencv, but
try as I might I can't get the video to show more than 1 frame. I got this
example code while searching for answers ([Creating a video using OpenCV 2.4.0
in python](http://stackoverflow.com/questions/14440400/creating-a-video-using-
opencv-2-4-0-in-python))

    
    
    import cv2
    from cv import *
    
    img1 = cv2.imread('i001.png')
    img2 = cv2.imread('i002.png')
    img3 = cv2.imread('i003.png')
    
    height , width , layers =  img1.shape
    
    video=cv2.VideoWriter('test.avi', CV_FOURCC('D', 'I', 'V', 'X'),1,(width,height))
    
    video.write(img1)
    video.write(img2)
    video.write(img3)
    
    cv2.destroyAllWindows()
    video.release()
    

This creates a video that runs for 3 seconds, but shows only the first image
for all 3 seconds. Is there a codec error or am I missing something?


Answer: u can use :

    
    
     cv.WriteFrame(writer, image)
    

like this :

    
    
     import cv
    
     img1 = cv.LoadImage('i001.png')
     img2 = cv.LoadImage('i002.png')
     img3 = cv.LoadImage('i003.png')
    
     writer=cv.CreateVideoWriter(filename, fourcc, fps, frame_size, is_color)
    
     cv.WriteFrame(writer, img1)
     cv.WriteFrame(writer, img2)
     cv.WriteFrame(writer, img3)
    

look also :

<http://opencv.willowgarage.com/documentation/python/highgui_reading_and_writing_images_and_video.html?highlight=createvideowriter#CreateVideoWriter>

