fourcc = cv.VideoWriter_fourcc(*'XVID') writer = cv.VideoWriter("out.avi", fourcc, 20.0, (640, 480), True) writer.write(im)