Time-lapse Photography: Pi Studio

[Article in Beta v0.5]

At the weekend I returned to Bristol Digimakers after missing events in 2017 due to badly timed holidays. I've written about Digimakers numerous times before and am a huge supporter of this Bristol University student-run tech event. Every time I go I love discovering new, cool, interesting, practical, and not-so practical things one can do with computers. Normally I take along a Zumo robot along with various bits and pieces (typically a selection of Raspberry Pi HATs). It's time for something different, and hence I presented Raspberry Pi Lightbox Studio. This is an attempt to create a low-cost photo studio in the home / bedroom / kitchen for an all in price of under £100 (including Pi and camera).


I've been keen on trying time-lapse photography at the small or macro scale. An example: I have a tub of Science Putty which is fun for all of five minutes as one pulls it into shapes and then starts to watch it collapse back to its original tub-shaped state. I say "five minutes" because that is about the limit of my attention span as it is a rather slow process. Enter time-lapse photography to the rescue.

Time-lapse photography is a way of compressing time: a long duration is viewed as a video in a shorter period which has the result of accelerating the rate of change in a scene. Most of us have seen examples like this in films and on YouTube. One way to think of this is the exact opposite of Bullet Time featured in The Matrix, which is a pretty advanced technique that gives the appearance of slowing time (while introducing 3-dimensional camera movement). If Bullet Time (with the help of CGI) makes things appear to move s-l-o-w-l-y then time-lapse makes things move more quickly. Ahah! I do not have to watch my Science Putty collapse in real-time. I can create a video that accelerates the process.

To achieve the effect we take many individual photographs and then stitch them together into the video. Normal videos usually run at around 24 frames per second. For comparison to watch ice melt I take one photo every 15 seconds (your setting may vary). It will therefore take 15 x 24 = 360 seconds (or 6 minutes) to take the 24 frames required for one second of footage. We are therefore accelerating time 360 times! Ice will melt in front of our eyes.

To create a time-lapse effect you need a way to reliably take multiple photographs. Assuming you won't do this by hand (oh the boredom!) you need to be able to program your camera to do this process automatically either with an intervalometer or via the settings on some modern cameras. This is where the Raspberry Pi comes in. Coupled to a Pi Camera (I'm using v2.1 but this will work with v1 as well) we have a very fine degree of control over the creative process of creating a time-lapse movie as the raspistill software features a time-lapse mode.
Assuming you have followed the software set-up in the above guide the following steps will take you through the process:

  1. Select target and compose scene
  2. Take sample photo
  3. Re-adjust
  4. Re-take sample photo and check all is well
  5. Run raspistill to capture individual photos using the time-lapse option
  6. Stitch the images together into a movie
  7. Watch and enjoy.

You may want to use a stand-in for your target when setting up. For example, for a time-lapse of an ice cube melting use a d6 dice as a temporary target (or a whisky stone) and keep the ice in the freezer until needed. Else, you will miss some of the action.

To create a good time-lapse technique several challenges present themselves and each must be overcome. I* broadly split this into:

  • Subject
  • Lighting
  • Photographing
  • Stitching

* - other issues do exist, but get these four sorted and you'll be a long way towards creating excellent time-lapse


Essentially, you have two choices: go big or go small. If big (e.g.: clouds) then you will have less control over lighting (see below) but can create amazing views of our planet. If small then you need to be aware of potential close-up focus issues as the Pi camera struggles to focus below 20cm by default. This can be corrected but do read several sources of information on this first to avoid damaging the camera. YouTube has a good video showing the process. For those not liking the combination of pliers + delicate camera Adafruit have the answer. Or, for your first attempts just don't worry about it (I didn't). Does an ice cube melting need to be in perfect focus? I'll leave that to you to decide.

You should position the Pi Camera with a good view of your subject, and take sample photographs to ensure all is well before starting the time-lapse process. It is essential that you do not nudge either camera or subject in any way during the image capture process or the effect will be ruined. Motion time-lapse, where the camera rig is intentionally and automatically moved along a rail between frames is a whole subject in its own right, and with perfection can create some staggering results.


One of the banes of time-lapse photography is flicker. This is created when the lighting between each frame differs slightly and/or the camera changes its exposure. With the controls of an SLR camera (such as the excellent Nikon D7200 that I use when not Pi'ing) the latter can be resolved by using manual exposure mode and white balance settings. There are several ways to adapt to changes in lighting. You could, for instance, embrace lighting changes in your project. Time-laps of clouds during the day -> evening -> night often do this. Alternatively for controlled indoor scenes (Science Putty) you can use a lightbox that provides a controlled, consistent lighting array (ideally one that minimises shadows).

I am using a £12.99 bit of kit from Puluz. This lightbox has two LED strips top-front and top-back that provide even lighting, albeit do be aware of bright sunshine from the front as that can still change the light level. From Puluz's promotional images such as that below you can see that an added benefit of this lightbox is that a circle can be removed from the top to take photos from above the subject. As a piece of kit it is actually a lot better than its meagre price tag would suggest. Better light boxes are definitely available but at this price point it is worth giving it a go. The two LED arrays with supplied cables (that each require plugging in - use two USB ports on your Pi 3) are bright and provide even lighting throughout the box.
Puluz Lightbox


When your scene is set use the raspistill command to start taking photographs. Now, go make a cup of tea (or several) as the process will take a long time. Remember: we are accelerating time in video, not in reality (not even the Raspberry Pi can do that...yet.) ;)

The guide on time-lapse photography from the Raspberry Pi Foundation is very handy here. Assuming you have updated your Pi to the latest firmware and enabled the camera then the key commands to enter at the terminal prompt are a variant of:

mkdir tlcd tlraspistill -t 30000 -tl 2000 -o image%04d.jpg

First we need to make a directory (mkdir) in which to store our time-lapse photographs as the camera will create a lot, and hence create a bit of a mess in any folder you are currently in. We change directory (cd) to the tl folder (cd tl) and then run raspistill with parameters to output images:

-t switch is the amount of time to run the time-lapse for. In this example 30000 miliseconds, which is 30 seconds.
-tl is the frequency to take photographs, 2000 milliseconds being 2 seconds in this example.
-o is the image name to save the file to disk with %04d being a numerical increment. The 4 means pad with up to four preceding zeros. This will create images numbered 0000, 0001, 0002, etc, i.e.: image0001.jpg, image0002.jpg, image0003.jpg etc.

You should vary the -t and -tl settings as needed. Some experimentation is needed here. To melt a large ice cube of BB8 from Star Wars I used -t 14400000 which is a lot of milliseconds! This equates to 4 hours (1000ms x 60s x 60m x 4h). I decided to take a photograph every 15 seconds, setting -tl to 15000 to do this. This generated 960 images (14400000/15000) and required about 4GB of space on my SD card.

Allow the time-lapse to run to completion. Note that if a frame or two ends up corrupted / showing waving fingers in front of the lens then this can be corrected by deleting the offending image, copying its next nearest neighbour and renaming to fill the gap. This does result in two duplicate frames, but at a rate of 24ish per second no-one will likely notice.


When all the images have been created ... TBD

The end result

Here is a movie... TBD

Kit needed

  • Raspberry Pi 3. Other Pi's can be used however the encoding process to stitch the individual frames together is processor intensive. Even the Pi 3 only manages just over 1 frame per second in contrast to my 2014 MacBook Pro that regularly hits over 9 frames per second.
  • Official Raspberry Pi Power Supply. With the Pi 3 having to do some serious processing during the stitching process, coupled with the juice required for the two LED arrays on the Puluz plus the camera having a decent PSU makes sense. Note that kits are available that combine the Pi, PSU, SD card (with NOOBS pre-installed) for a good combined price are available. If you want to keep the lid on your Pi when the camera is attached do look for a kit with a suitable notch, such as the Pimoroni Pi 3 Essentials Kit.
  • Raspberry Pi Camera v2.1 (or v1 if you have one handy).
  • High capacity SD card. I use Integral cards. 16GB should be considered a minimum if you intend to use the card to save photographed frames and the stitched movie. Alternatively consider a 32GB SD card or an external device such as the Kingston 32GB (or higher) USB 3 external drive.
  • A mini tripod or similar to stabilise the camera.
  • ...for which you'll need an adaptor. I found I did not need a bolt to hold it onto the tripod nut despite what reviews state. Note that blu-tac should probably be avoided as a substitute as it tends to give way slowly which could be noticeable as the angle of your camera gradually changes over a number of frames.
  • Something to raise the Pi up a bit. I found that the limited camera connector length meant that I needed to get my Pi closer. I had one of these Clingo things lurking around and it does the job well. Alternatively use the boxes the Pi and Camera come in. Alternatively a longer ribbon cable does the trick. Pimoroni sell these.
  • A keyboard and mouse for the Pi. I suggest looking at Rii's offerings. I use the Rii i8 for when I need to enter the occasional command into the Pi which is available in RF (Radio Frequency) or Bluetooth variants. Note that the i8 is not suitable for prolonged typing.
  • A monitor to preview and view your movies. Or work headless by connecting your Windows / Mac laptop to the Pi and using it purely to acquire images.

If you use a headless setup this used to mean you could not view a live preview of the Pi Camera's output, even with VNC. Fortunately recent versions of RealVNC, bundled with the Pi, solve this problem. RealVNC provides a good write-up on their website. However if live previews are not important then a purely command line experience works well: you can always download the files to your computer (using SFTP in Filezilla, Transmit or similar) and view as needed.

I'm going to call out the Manfrotto PIXI EVO 2 that I bought as perfect for the job. With a claimed weight of 2.5kg (750g for the camera body) it doubles as a table-top tripod for holidays. At about £35 it is something of a bargain given the features, which includes easy head angle adjustment and ability to operate at a variety of heights. Being able to alter the height and angle of the head is a must given you will want to target your subject precisely.
Manfrotto PIXI EVO 2 mini tripod

Pro tip: the Pi Camera comes with a little sticky protector tab over the lens. Do remember to remove it before starting to capture images! Also, keep it to use as a mini lens protector if transporting / storing your kit.


Subject ideas for time-lapse photography


Issue 14 of The MagPi released

Issue 14 of The MagPi has been released. This issue contains a review of the Bristol Raspberry Pi Boot Camps that RaspTut has been attending along with The MagPi. Also in this issue is the first in a series of articles about the new camera board add-on available for the Pi.

As always, the magazine is available for free to read online or download as a PDF.

The MagPi issue 6 is out

The MagPi issue 6 has been released, featuring an interview written by yours truly with David Hunt of Camera Pi fame. Camera Pi is a superb amalgamation of Pi + DSLR camera that gives David lots of control over the photographic process.