Skip to content

Instantly share code, notes, and snippets.

@mmautner
Last active April 12, 2018 07:16
Show Gist options
  • Save mmautner/9552919eea4a4e16195e31a20bcdeba4 to your computer and use it in GitHub Desktop.
Save mmautner/9552919eea4a4e16195e31a20bcdeba4 to your computer and use it in GitHub Desktop.
make a simplistic multi-frame animation with Python + ffmpeg
#!/bin/bash
convert -loop 0 -delay 30 -resize 683x512\! *.png out.gif
#!/usr/bin/env python
import sys, glob, shutil
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
arg = sys.argv[1]
logger.info('locating files matching "{}*"'.format(arg))
files = glob.glob('{}*.png'.format(arg))
logger.info('\t{}'.format(files))
PATTERN = "img%03d.png"
for i in xrange(100):
src = files[i % len(files)]
dest = PATTERN % i
logger.info("copying {} to {}".format(src, dest))
shutil.copyfile(src, dest)
logger.info("ffmpeg -framerate 10 -i image%03d.png -s:v 1280x720 -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p out.mp4")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment