Tuesday, 25 March 2014

Timelapse Raspberry Pi Camera

Last weekend I tried my hand at some time-lapse movie creation

To do this, I've used the Raspberry Pi camera module + Raspberry pi

This high-tech setup attaches a Pi & camera module to my sons bedroom window with electrical insulation tape.  raspistill is run using the following command:


raspistill -o image_%05d.jpg  -n -tl 5000 -t 72000000 &


The above command only creates a set of jpg files, each approx 2.5Mb, and not the final video clip.  (The ampersand keeps it running in the background)

The final clip is created with mencoder.  See here for detail on how to set this up


ls *.jpg > list.txt
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o timelapse.avi -mf type=jpeg:fps=20 mf://@list.txt     

Attempt 1
My first attempt was okay, but suffered from reflection of the Pi's camera light.  this can be turned off by following these instructions.  This is also captured every 30 seconds, which I felt was a bit too speedy once combined at 25fps

Attempt 2
This clip was created on the following day, with the wind in a more 'atmospheric' direction relative to the window.  I soon discovered that I was limited in the length of video clip I could create by the space on the Pi's SD card.  My solution was to create a share on the Ubuntu machine, mount it on the Pi set the output destination for raspistill to save there, rather than the Pi's SD card.

With this approach I was able to leave it running for approx 8hrs, over which time it generated 14Gb image files.  Using mencoder, this converted into a 250Mb avi file, and encoded at 25 fps created a video of 3:30 minutes long, and I'm quite pleased with it.  It could be improved with some background music... maybe The Orb's Little Fluffy Clouds?  Best viewed full screen in HD.

I opted in this one for a 5 second time interval.  There's a handy guide here which gives some suggestions as to appropriate intervals based on what you want to timelapse.  The astute among you will notice that there is a skip in the middle of this, which is where my laptop decided for 15 mins or so to drop off the network.  the problem with defining the output of raspistill to a network share is if it stops sharing for some reason the capture will fail.

A more elegant solution would be to capture directly to the SD card as a buffer and periodically move to external HD/network share.  I also noticed that the output jpg didn't make it across sometimes where raspistll would complain of dropped frames.

I particularly like the end where there's a brief flash of red as the sun sets off camera.  Quite pleased with the end result.


  1. Nice sequence.

    Have you tried running this setup at night from this position?

  2. That's a good idea, apart from the part where my son will probably try swinging from the cables, monkey-style. He likes flashy, shiny devices. Cant think where he gets that from...