Skip to content

Instantly share code, notes, and snippets.

@oak-tree
Created March 4, 2020 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oak-tree/6eb8cf98ab6fc09bb229ec7e4b981885 to your computer and use it in GitHub Desktop.
Save oak-tree/6eb8cf98ab6fc09bb229ec7e4b981885 to your computer and use it in GitHub Desktop.
create video from all jpeg in current folder
image_height,image_width,_ =cv2.imread(os.listdir()[0]).shape
output_path = os.path.join(os.getcwd(), "result.avi")
video_size = image_width, image_height
video_fps = 5
video_size = image_width, image_height
video_FourCC = cv2.VideoWriter_fourcc(*'MJPG')
out = cv2.VideoWriter(output_path, video_FourCC, video_fps, video_size)
for i in sorted(os.listdir()):
if i[-4:] != "jpeg":
continue
print(i)
img = cv2.imread(i)
print(img.shape)
out.write(img)
cv2.waitKey(1)
print('done, releasing')
out.release()
print('released')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment