You can use an external tool, such as ffmpeg, to merge images into a movie (see answer here ), or you can try using OpenCv to merge images into a movie, similar to the example here .
I am attaching below code. I used to combine all png files from a folder named "images" in the video.
import cv2
import os
image_folder = 'images'
video_name = 'video.avi'
images = [img for img in os.listdir(image_folder) if img.endswith(".png")]
frame = cv2.imread(os.path.join(image_folder, images[0]))
height, width, layers = frame.shape
video = cv2.VideoWriter(video_name, -1, 1, (width,height))
for image in images:
video.write(cv2.imread(os.path.join(image_folder, image)))
cv2.destroyAllWindows()
video.release()
source
share