How to record a timelapse with a Raspberry Pi… Finally

Posted In: Blogroll

Outside my office here in Berlin there is a Christmas market. There they have a Ferris Wheel they build for December and then dismantle afterwards. So I thought it would be awesome to record a time-lapse of the wheel being constructed…

That was 2 years ago!

I hold my hand to my heart and say that out of all the time-lapses I have made this subject is a really bitter one for me. First time round it was my fault. Perfect conditions and I had forgotten to mount the external drive. I did not know what happened until after the wheel was finished. The SD card was full with only the images for half the construction.

Wheel attempt 2014

2015 would have be fine, alas I was foiled by the rain.

Wheel attempt 2015

Now this years….. 😉

Here is how you do it!

What you need:

  • Raspberry Pi + power, sd-card, case etc… Installed with raspbain
  • Pi Camera board
  • Some sort of tripod (but this can even be hot glue and something that stands up)
  • Mass storage device – USB stick or Hard drive (powered)
  • Some black card or cloth to block out the light

Step One: Find a location to shoot

I was indoors so I have to find a window where I could set the camera up. I had to consider the reflection so it was a good idea to make everything black. I have the Camera mount from pimoroni which is black and with black screws. Otherwise I just covered everything else in a black cloth.

This image is an example of reflection in action (sucks!)


If the time lapse is at night then try and reduce the light behind the camera so you don’t end up with a massive network cable in the sky!

Step Two: Setup the camera and make a test shot

I used my laptop to SSH into the Raspberry Pi where it was so I could walk away and leave it running without any screens or keyboards waiting to trip anyone up.

To test the camera was working I made my 1st shot using the following command:

raspistill -o /home/pi/test.jpg

which gave me this image (without the reflection)


(the blur is water on the window nothing I can do but can look interesting with light intersecting it)

I had to rotate the camera and flip the image so that everything looked as it should  on the output screen. You could just turn the camera but where is the fun in that.

raspistill -hf -vf -o /home/pi/test.jpg

hf = horizontal flip, vf = vertical flip


Now we are cooking!

Step Three: Attach mass storage device and MOUNT IT!

First make a new folder

mkdir /media/timelapse

Then you can plug in your hard drive and type the following command (assuming sda1 is the drives Identifier)

mount /dev/sda1 /media/timelapse

This now means the anything on the hard drive can be seen in the folder /media/timelapse and in turn you can save to /media/timelapse and it would be on the hard drive.

Yeah well this is important and where I slipped up the first time.

Why did I use a hard drive instead of cloud or online storage??? My office wont allow this device to be connected to our network. But if you have the option there is nothing wrong with using networked storage but just keep in mind upload times.

Step Four: Start the timelapse

There are a few ways to do this..

I went with the -tl option. Actually I have been using it quite a lot to be honest so much so I know the command off by heart.

My command looked like this –

raspistill -hf -vf -o /media/timelapse/wheel_%07d.jpg -tl 30000 -t 604800000

so -tl is 30000 milliseconds (30 seconds) meaning it will take a picture every 30s for -t 604800000 (7 days), the file name has %07d which means the file name will have 7 digits for example: wheel_0000001.jpg this will increase until wheel_9999999.jpg

So at this point check its all working and your happy!

Step Five: Ignore and get on with life

Its worth noting you would want to place the camera somewhere where the camera does not move. Last thing you want is something to knock the camera and ruin your time-lapse.

Step Six: Compile your photos

Ok so this is where I cheat and don’t use the raspberry pi. The data you would be pushing to make the finished video is massive, especially when your compiling 7 days worth of photos at 30s interval’s. I think I stopped the script manually after 5-6 days and it was 210620 frames. Crazy right!

I found a neat tool for MacOS called Time-lapse assembler. Its a simple application where you point it to a directory tell it the frame rate and quality, have a couple cups of tea and its done.

I used this app because while the pi is capable of compiling the time-lapse, when you start running into the 1000s of files it is just quicker to use a desktop system like a Macbook.

Step Seven: Upload and share

Well that’s a given right!

In the end this is a quick overview of what I did. I would totally recommend you to read the tutorials on the page I mentioned before as they do a really great job to show you by example how this can work.

Final thought: Experiment!

My tutorial here is an example of days long time-lapses but there is nothing stopping you from taking shorter ones with different intervals.

Please feel free to leave a comment with how you get on or any questions. Share your results also!