Use Automator to shoot a time-lapse movie

Movies created through time-lapse photography can be stunning. And for some people in the sciences they can also be a useful tool. While there are a variety of applications that allow you to create time-lapse movies of your own, none of them are built into the Mac OS save this one: Automator. The following workflow allows you to automate not only the shooting of your images, but their conversion into a movie.

Before you launch Automator, create a folder on the Desktop called Time Lapse. Now launch Automator and from the template sheet that appears, select Application and click Choose. In the resulting workflow window add these actions: Take Picture (found under Photos), Pause (Utilities), Loop (Utilities), Get Specified Finder Items (Files & Folders), Get Folder Contents (Files & Folders), Import Files into iPhoto (Photos), and finally, Run AppleScript (Utilities).

For the Take Picture action to work (and thus the workflow) you must have a camera compatible with that action. My point-and-shoot Canon S95 isn’t, but my Nikon D300 DSLR is (and I suspect many other DSLRs are as well). When you plug your camera into your Mac’s USB port and switch on the camera, this action will display your camera’s name, if it’s compatible. From the Download To pop-up menu choose Other and then navigate to your Time Lapse folder. If you’re concerned about your camera’s media card filling up during the shoot, enable the Delete Picture From Camera After Downloading option. Also, you’ll probably want to attach your camera to a power supply rather than depending on a battery that might drain before you finish the shoot.

In the Pause action choose an appropriate interval between pictures—30 seconds or 1 minute, for example. Configure the following Loop action so that the first pop-up menu reads Loop Automatically, the second reads Stop After X Times (where X is the number of shots you’d like to take), and Use the Original Input is selected in the last pop-up menu.

The time-lapse workflow

Drag your Time Lapse folder on the Desktop into the Get Specified Finder Items action. Follow up with Get Folder Contents. In the Import Files into iPhoto action that appears, choose New Album from the pop-up menu and call that album Time Lapse. To tidy up your Time Lapse folder, enable the Delete the Source Images After Importing Them option.

Finally, in the Run AppleScript action add this text:

tell application "iPhoto" to activate

tell application "System Events"

	tell process "iPhoto"

		keystroke "E" using {command down, shift down}

		delay 0.5

		tell window "Export"

			tell tab group 1

				click radio button "QuickTime™"

				delay 0.5

				tell text field 1 of group 1 of group 1

					set focused to true

					delay 0.5

					set value to "1024"—movie width

				end tell

				tell text field 2 of group 1 of group 1

					set focused to true

					delay 0.5

					set value to "768"—movie height

				end tell

				tell text field 3 of group 1 of group 1

					set focused to true

					delay 0.5

					set value to "0.5"—seconds per frame

				end tell

				tell checkbox 1 of group 3 of group 1

					set focused to true

					if value is 1 then click

				end tell

			end tell

			click button "Export" of list 1

		end tell

		keystroke "G" using {command down, shift down}

		delay 0.5

		keystroke "~/Desktop/timelapse.mov"

		delay 0.5

		keystroke return

		delay

		keystroke return

	end tell

end tell 

Note the “seconds per frame” comment in the AppleScript. If you find that value (0.5, or half-a-second) too short, you’re welcome to change it. Likewise you can change your movie’s width and height values. Note too that for the AppleScript to work its magic you must have the Enable Access For Assistive Devices options enabled in the Universal Access system preference.

So, what goes on here? The Take Picture action does just that—Automator orders your tethered camera to take a picture and save it to the Time Lapse folder. The workflow then waits for the period of time entered in the Pause action. The Loop action tells the workflow to repeat those first two steps a certain number of times—300, for instance. When the workflow has finally taken the specified number of pictures, the next few actions import the camera’s images (saved to the Time Lapse folder) into iPhoto. And the AppleScript invokes iPhoto’s Export command, selects the QuickTime tab, exports the images as a movie, and saves the results to the Desktop as timelapse.mov (you can change the movie’s title within the AppleScript if you like).

When you’re ready to give it a go, place your camera on a steady surface or tripod, attach it to your Mac, and run the Automator application you’ve created.

Subscribe to the Help Desk Newsletter

Comments