My recent time lapse video of the
Portage Lake lift bridge at sunset turned out to be rather popular -- because of my brief tutorial on using
gphoto2 for time-lapse video. So, I've written up a short (but more detailed) tutorial on setting up and using gphoto for time-lapse videos.
Step 1: Install gphotoThe first step is getting gphoto installed on your computer. I have heard rumors of a version of gphoto for Windows, but getting that set up is far beyond the scope of this tutorial. If you are using Linux, you almost certainly know enough to install gphoto on your own -- your favorite package manager will work. The trickiest system on which to install gphoto is Mac OS X. If you are willing to go with an older version of gphoto, you can install
darwinports and use the command
sudo port install gphoto2
in Terminal.
Update (September 2009): Here are more detailed instructions for installing the newest version of gphoto2 on Mac OS X. I recommend starting with the DarwinPorts version above -- even though it's old, installing it will also install and update many other programs which gphoto2 needs to operate. After doing that, you should get the newest version. To get the newest version, download
both the gphoto and libgphoto packages from the
gphoto homepage. The first step is to install libgphoto. Double-click the libgphoto package to uncompress it. In Terminal, type the following commands:
cd (path to the libgphoto directory)
sudo ./configure --prefix=/opt/local
A large amount of text should pass through the terminal, after which type
sudo make
sudo make install
This installs libgphoto. The next step is to install gphoto2 itself, which uses libgphoto to control your camera. Double-click the gphoto package to uncompress it. Again in Terminal, type the following commands:
cd (path to the gphoto directory)
sudo ./configure --prefix=/opt/local --without-cdk --without-aalib POPT_CFLAGS="-I${prefix}/include" POPT_LIBS="-L${prefix}/lib -lpopt"
sudo make
sudo make install
These should configure, compile, and install gphoto2 correctly. To double-check that it worked, type in Terminal:
gphoto2 -v
The result should be a bit of information, including version numbers about gphoto2. If there are any errors, you'll need to reinstall gphoto2.
Step 2: Set up and test your cameraAlmost all digital cameras made in the last 5 years -- whether point-and-shoot or DSLR -- will almost certainly work with gphoto. To be sure, you can check out this
complete list of supported cameras.
There are a few basic steps to getting your camera ready to work with gphoto:
- Set your camera to the correct mode. This doesn't mean exposure mode, but rather the correct "connection mode," which controls how your camera talks to your computer. To figure out which mode you need, look on the list of supported cameras. Find your camera in the list, and look for the text in parentheses at the end -- for example "(PTP mode)". You now need to change your camera into this mode. This is usually in a "setup" or "options" menu, and it's a rarely changed option. Every camera is different, and your best resource is the user's guide. Many cameras work in either their normal mode (requiring no special setup), or PTP mode, which is a standard allowing computers to control cameras.
Here's an example for the Nikon D40 (my favorite camera) which works on most Nikon DSLRs. The mode you need is PTP mode. To set this, press the Menu button, then choose Setup -> USB -> MTP/PTP and hit OK. - Connect your camera to a computer using a USB cable. This should be the normal USB cable which you use to connect your camera to your computer when downloading photos. If you normally use a card reader or some other method, you will need to locate a USB cable which lets you connect your camera directly to the computer -- typically cameras come pre-supplied with these. I recommend using a laptop, so that you can move the camera to your favorite shooting location.
- For Mac OS X users only: kill the PTP daemon. This isn't as evil as it sounds! Mac OS X automatically "grabs" the camera when you plug it in -- this is how iPhoto and other programs can automatically download your photos. But this also means that gphoto doesn't "own" the camera, and can't use it. To fix this, open Terminal and type:
ps -e | grep PTP
and hit return. The output should be a single line which looks something like this: dcclark 29983 (several more numbers) PTPCamera
The first item will be your userid, and the number immediately following it is the id of the PTP daemon. Execute the following command: kill -9 29983
where of course "29983" is replaced with the number in your output. You will have to repeat this entire process every time you plug the camera in to your laptop.
- Test that your camera is connected and working. To do so, execute this command in a terminal:
gphoto2 --capture-image
Your camera should (after a few seconds) take a photo, just as if you had pressed the shutter button. If it doesn't, the error message may be enlightening.
Step 3: Take photos!You are now all ready to take photos! The most useful "advanced" feature of gphoto2 is the ability to take time-lapse photos. The basic command you need will look like this:
gphoto2 --capture-image --interval 30 --frames 10
Here's a breakdown:
- --capture-image: tells gphoto to take an image.
- --interval 30 : tells gphoto to keep taking images, once every 30 seconds.
- --frames 10 : tells gphoto to stop taking photos after 10 have been captured.
You can replace --capture-image with --capture-image-and-download if you want the images to be downloaded to your laptop instead of staying on your camera. Remember, you don't want to touch the camera while it's taking shots!
Here are a handful of useful things to remember:
- Your camera will take photos in the current exposure mode (Program, Aperture Priority, etc.). Be sure your camera is in the mode you want before you begin. This usually means going into full-manual mode, so that the exposure is consistent between frames.
- If using a camera which has it, turn off ISO-Auto and ADR (this is Nikon, mostly). These features can change your intended exposure and make your frames look inconsistent, even if you're in fully manual exposure mode.
- Focus your camera on the intended subject before you begin, and then turn your lens to manual focus. This will avoid the camera trying to refocus for each frame, especially if there are moving objects involved, or if lighting gets dim.
- Don't touch your camera while taking time-lapse photos, unless you want different frames to have a different viewpoint. For time-lapse videos such as the one I mentioned at the top of this post, you want the camera to be untouched for the entire time.
WrapupThose are the basics! You can do a
lot more than this with gphoto2 -- but that's for the future. If you're interested in seeing what you can do, there are many other tutorials available out on the web. You can also get a summary of gphoto's options by typing
gphoto2 --help
in your terminal. For now, enjoy!