Skip to content

Instantly share code, notes, and snippets.

@yun-long
Last active March 29, 2021 13:25
Show Gist options
  • Save yun-long/6bc05e3218bda1ca74642dfbae9f0264 to your computer and use it in GitHub Desktop.
Save yun-long/6bc05e3218bda1ca74642dfbae9f0264 to your computer and use it in GitHub Desktop.
import cv2
import os
import glob
#
image_folder = './Saved'
video_name = 'video.avi'
fourcc = cv2.VideoWriter_fourcc(*'MP4V')
images = []
for img in sorted(glob.glob(os.path.join(image_folder, "*"))):
images.append(img)
frame = cv2.imread(images[0])
height, width, layers = frame.shape
video = cv2.VideoWriter(video_name, fourcc, 40, (width,height))
for image in images:
video.write(cv2.imread(image))
cv2.destroyAllWindows()
video.release()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment