Gary Edwards

Time lapses and photo montage

written on 3 January 2010

These scripts are from my old blog and are used for creating a time lapses and photo montages from a sequence of photos.

Time Lapse

This uses the command line tool ffmpeg to convert a sequence of jpg images into a DNxHD encoded mov. This example assumes files are named in the following format (0001.jpg, 0002.jpg etc.):

$ ffmpeg -i %04d.jpg -r 25 -croptop 99 -cropbottom 100 -s hd1080 \
  -vcodec dnxhd -mbd rd -b 120Mb -an output.mov

I have also used the following in the past to go from jpgs to a H.264 encoded file ready to upload to sites like Vimeo:

$ ffmpeg -y -i %04d.jpg -mbd 2 -an -pass 1 -vcodec libx264 -r 25 \
  -croptop 23 -cropbottom 176 -s hd720 -sws_flags lanczos -vpre \
  fastfirstpass -b 5000k -bt 4000k -threads 0 OUTPUT.mp4 && ffmpeg \
  -y -i %04d.jpg -mbd 2 -acodec aac -ab 128k -ar 44100 -pass 2 \
  -vcodec libx264 -r 25 -croptop 23 -cropbottom 176 -s hd720 \
  -sws_flags lanczos -vpre hq -b 5000k -bt 4000k -threads 0 out.mp4

Photo Montage

The following copies every nth file to a folder and then uses GraphicsMagick to process them into a photo montage.

This example copies every 15th file to a sub folder named output:

$ ls | awk 'NR%15==0{ cmd = "cp \047"$0"\047 ./output";system(cmd)}'

Then use GraphicsMagick to create a 10x11 grid of 354x236 rectangles:

$ gm montage -tile 10x11 -geometry 354x236+0+0 ./output*.jpg joined.jpg

This entry was tagged bash, ffmpeg, graphicsmagick, howto, linux, montage, scripts and timelapse