fourcc = cv2.cv.CV_FOURCC(*'XVID')
out = cv2.VideoWriter('out_video.avi', fourcc, 24, (704, 240))
c = cv2.VideoCapture('in_video.avi')
while 1:
    _, f = c.read()
if f is None:
    break
f2 = f.copy()
out.write(f2)
out.release()
cv2.destroyAllWindows()
c.release()
Python JPEG to movie