Skip to content

Instantly share code, notes, and snippets.

@scientificRat
Created July 15, 2022 12:23
Show Gist options
  • Save scientificRat/155044b1eace31a0bfcddd1f49e401bc to your computer and use it in GitHub Desktop.
Save scientificRat/155044b1eace31a0bfcddd1f49e401bc to your computer and use it in GitHub Desktop.
make time lapse from images
import os
import glob
import moviepy.editor as mpe
IMAGE_ROOT = '/Users/huangzhengyue/work_data/jiaolou3'
OUT_FILE_NAME = 'test3.mp4'
FPS = 12
def main():
image_list = glob.glob(os.path.join(IMAGE_ROOT, '*.jpg'))
image_list += glob.glob(os.path.join(IMAGE_ROOT, '*.JPG'))
image_list += glob.glob(os.path.join(IMAGE_ROOT, '*.jpeg'))
image_list += glob.glob(os.path.join(IMAGE_ROOT, '*.JPEG'))
image_list = sorted(image_list)
print("total image cnt:", len(image_list))
video = mpe.ImageSequenceClip(image_list, fps=FPS)
video.write_videofile(OUT_FILE_NAME)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment