OpenCV VideoWriter with python gives 5.54kb file
Question: I am trying to create a TimeLapse creator in python using OpenCV, and have the
following code:

    
    
    import cv2
    import os
    import string
    
    directory = (r"C:\Users\Josh\Desktop\20130216")
    video = cv2.VideoWriter(r"C:\Users\Josh\Desktop\video.avi", cv2.cv.CV_FOURCC('F','M','P', '4'), 15, (1536, 1536), 1)
    
    for filename in os.listdir(directory):
        if filename.endswith(".jpg"):
            video.write(cv2.imread(filename))
    
    cv2.destroyAllWindows()
    video.release()
    

The folder has 1,440 pictures in it, yet video.avi is only 5.54kb in size, and
has an empty output when played. Can anyone see any flaws in my code, and give
me any help?


Answer: It seems to be that, you have windows without ffmpeg support. I had the same
problem and [OpenCV 2.4 VideoCapture not working on
Windows](http://stackoverflow.com/questions/11699298/opencv-2-4-videocapture-
not-working-on-windows) helped me on that.

The opencv246\opencv\3rdparty\ffmpeg\opencv_ffmpeg.dll should be copied to
c:\Python27\opencv_ffmpeg246.dll

Your frame size defined in your code as 1536x1536, so all of your .jpg files
should match that size.

    
    
    video = cv2.VideoWriter(r"C:\Users\Josh\Desktop\video.avi", 
    cv2.cv.CV_FOURCC('F','M','P', '4'), 15, (1536, 1536), 1)
    

