Home | About | Apps | Github | Rss

FFMPEG: Create video from sequence of Images

I was recently working on creating a timelapse video from about 90 images, each of which is a 3-6 second exposure, which I shot during one of my bike trips.

rename files

The images in JPG format, shot on 5D-Mark2, needed renaming to ‘img_%d.jpg’ format, which I quickly did with a simple python script

>>> import os
>>> from glob import glob
>>> for i, f in enumerate( glob('*.jpg') ):
...     os.rename( f, 'img_%d.jpg' % i )

downscale

The images were all of 5616x3714 resolution. Using this one liner I bought it down to 1280x853 and moved them to a folder r1280_seq0

for each in *.jpg; do
> convert $each -resize 1280x -quality 85% "r1280_seq0/$each"
> done

ffmpeg

I needed ffmpeg which I setup using brew

$ brew install ffmpeg

convert to video

And for actual conversion, here is how I did it

$ffmpeg -r 10\
	-i img_%d.jpg\
	-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"\
	-pix_fmt yuv420p\
	video_10fps.mp4

Notes & Pitfalls::

Result


More posts