Create per-folder timelapse of photos in multiple folders

May 18, 2022 unzip python [code]

Given many directories where each directory contains multiple photos, go into each directory and create a timelapse.

import os

#Get a list of directories
dirnames = os.listdir('.')

#Go into each directory
for dirname in dirnames:

    #Skip if it is not a directory
    if not os.path.isdir(dirname):
    #cd into directory
    print("Dir: " + os.path.abspath(os.path.curdir))
    #FFMPEG command to generate a timelapse of 4s/image using two threads.
    cmd = 'ffmpeg -y -threads 2 -framerate 0.25 -i %04d.jpg -c:v libx264 -movflags +faststart -crf 0 ' + dirname + '.mp4'
    #Return to top dir
    print("Dir: " + os.path.abspath(os.path.curdir))