Page 125

for this task, since it’s a nicely readable language that comes pre-installed on every modern Mac. Here’s the script in its entirety, which I saved into a file called timelapse.rb. You can also find this code at

# Configuration settings — edit to your needs. path = “~/lapse” # Directory where images will be stored. Must exist and be writable. duration = 4 * 60 * 60 # Time to run, in seconds (4 hours here) interval = 5 * 60 # Time between each photo, in seconds (5 minutes here) # Start working... end_at = + duration i=0 while <= end_at do i += 1 system ‘say “cheese”’ # comment out if sound not wanted system “/Applications/isightcapture #{path}/%05d. jpg” % i sleep interval end Move this script into your home directory and create an empty path folder in the location specified at the top of the code. Then you can launch the script from Terminal by entering:

ruby timelapse.rb The script should start taking pictures at the given interval, and save them to the path folder under incremental filenames like 00001.jpg, 00002. jpg, and so on (Figure A, inset). It will run for the duration set in the duration variable, or you can Ctrl-C to stop it sooner. If you have more than one computer, you might want to make the path a shared folder, which lets you access its contents and check progress from another machine. The optional ‘say “cheese”’ line uses OS X’s built-in say utility to make a sound when a photo is taken.


Fig. A: (Opposite) Simple code tells the MacBook to snap and save a photo every few minutes. Fig. B: Turn a short photo sequence into an animated GIF using free GIFfun software. Longer sequences work better when converted to video formats.

more easily than files in standard video formats. Free GIFfun software ( lets you easily import all the photos from path and assemble them into an animated GIF (Figure B). With large numbers of frames, the GIF files become unwieldy, so it makes more sense to convert them to a video format, which uses compression. Another free tool, FFmpeg (, can help with that. If you have MacPorts installed, you can install FFmpeg with a simple command:

sudo port install ffmpeg Manually installing FFmpeg is beyond the scope of this article, but Stephen Jungels has a good guide at Once FFmpeg is installed, you can create a video with:

ffmpeg -f image2 %05d.jpg lapse.mpeg FFmpeg is a powerful utility with many other capabilities. It isn’t known for its ease of use, but with a little searching you can figure out many more fun ways to use it. If you create your own MacBook time-lapse videos, I’d love to see them! Please feel free to send me the links at

Creating a Clip With a sequence of up to a dozen photos or so, you can string them together into an animated GIF, which will play anywhere, as a loop, and will embed

Nir Yariv works with code and people to make stuff. He occasionally blogs at



Scan & PDF: worldmags & avaxhome

M_122-123_DIYI_F1.indd 123

6/18/10 2:34:11 PM

Make magazine 23  

Make: magazine 23

Make magazine 23  

Make: magazine 23