save img to avi:
import os
import cv2
img_path = '/home/sever/'
video_path = '/home/sever/'
video_name = 'output.avi'
img_list = os.listdir(img_path)
img = cv2.imread(os.path.join(img_path, img_list[0]))
img_size = (img.shape[1], img.shape[0])
fourcc = cv2.VideoWriter_fourcc(*'XVID')
video_writer = cv2.VideoWriter(os.path.join(video_path, video_name), fourcc, 25, img_size)
for i in range(300):
filename = '/home/sever/img' + str(i) + '.png'
img = cv2.imread(filename)
video_writer.write(img)
video_writer.release()
cv2.destroyAllWindows()