Time Lapse Photography With MacBook’s iSight

After the weekend blizzard barely touched New York, I was particularly glad to wake up to a snowy morning. My trusty old Canon A85 recently passed away, so left with only the Macbook’s built in iSight camera to document this I figured it might be fun to try and take some time lapse shots. Here’s one of the results:

timmargh‘s blog post showed me how to get going. First I had to install iSightCapture to control iSight via the command line, then write a script that will take photos in fixed intervals. Initially I used Tim’s AppleScript, but then converted to a quick Ruby script instead:

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)

end_at = Time.now + duration

i = 0
while Time.now <= end_at do
 i += 1
 system "/Applications/isightcapture #{path}/%05d.jpg" % i
 sleep interval

This will take a photo every 5 minutes for four hours. A few notes:

1. The directory in path (“~/lapse” here) should exist before you run the script. If you have more than one machine it may be a good idea to make it a shared folder, so you can check on the progress from your other machine.

2. Photo Booth, or any other app that uses the camera, should be off or iSightCapture won’t work.

3. WordPress code view adds some ‘ ‘s in “copy to clipboard” which will break the script – use the “source view” icon to get the clean version.

4. If you’re taking photos over a long time period, remember to turn the screen off (ie, minimal brightness) – this will help the battery last the whole time, especially if you’re on an older MacBook.

5. If you want to get some sound indication that photos are being taken you might add the following line at the start of the while loop:

`say "cheese"`

Once you have some photos, GIFfun will let you combine them into an animated GIF. If there are more than a few dozen file size can quickly get out of hand, so you might convert them to video instead –  ffmpeg can take care of that. Installing it is pretty simple if you have MacPorts:

sudo port install ffmpeg

You can then cd to the image directory and create the video:

ffmpeg -i %05d.jpg lapse.mp4

Finally, here’s a photo of the whole setup, taken with the other MacBook’s iSight :)