Time lapse photography

It was recently announced that a new building is being constructed next to my office. It’s not any old building – it’s going to be a 26-storey tower, the tallest in Bristol! Working on the second-top floor of an adjacent office block, this is a great opportunity to get a birds’ eye view of the construction site.

Castle Park View
Castle Park View

This artist’s impression of the new tower, Castle Park View shows it looming over its surroundings. My office, One Castlepark, is circled in red – massively overshadowed! Clearly I am going to need a very wide angle lens to get it all in.

I’m on a very limited budget so I started off looking at wide angle webcams. This one was the cheapest one with a decent angle of view, but it quickly became obvious that at the close proximity, it couldn’t even fit the footprint of the construction site in – let alone the height of the tower.

Castle Park View construction site - wide angle view
Castle Park View construction site – wide angle view

So I decided to buy a USB camera with a fisheye lens. This one offered such a wide angle of view that it can see its own window frame – almost 180°! It easily encompasses the footprint of the construction site and hopefully will fit in most, if not all, of the height of the tower as it goes up.

Castle Park View construction site - fisheye view
Castle Park View construction site – fisheye view

I’m not fully happy with the image quality from the fisheye camera but it’s hard to judge when the weather is grey. It might benefit from a graduated ND filter to give extra exposure to the foreground.

The camera was supplied with a simple metal bracket so I knocked together a wooden stand for it, painted matt black to reduce reflections in the window. It has a heavy base and rubber feet to reduce vibrations, and a rubber washer at the “neck” joint so it can be set and will keep its position.

Wooden camera stand

I did a lot of thinking about the number of pictures to take, etc and eventually decided over the duration of the construction (about 2 years), taking a picture every 10 minutes during daylight hours and playing back at 30fps would yield a video that plays for about 16 minutes. Here are the calculations from my spreadsheet…

Frames taken every10minutes
from8AM
to18PM
That’s6frames per hour
Filming runs for10hours per day
Construction lasts24months
There are21work days per month
Filming lasts for504days
Total frames taken30240
Playback rate30frames per second
Video plays for1008seconds
that’s16.8minutes
Frame size330KB
Total data size9.5GB

I decided to run the capture from an old Linux laptop I had lying around, although a Raspberry Pi would be ideal.

There are various time lapse capture tools around but I decided to keep it simple and use a tiny utility called fswebcam. This can be invoked with the following command line:

#!/bin/bash
fswebcam -r 1920x1080 -D 3 -S 75 --no-banner --jpeg 85 /motion/$(date "+%FT%H.%M").jpg

Let me break this down a bit.

  • fswebcam the name of the program
  • -r 1920×1080 capture at full HD resolution
  • -D 3 delay for 3 seconds to allow the camera to “warm up”
  • -S 75 capture 75 frames before taking the real frame, to allow the autoexposure to stabilise
  • –no-banner don’t overlay a timestamp etc on the captured image
  • –jpeg 85 export the frame as JPG with 85% quality
  • /motion/$(date “+%FT%H.%M”).jpg save the frame with a filename like 2019-03-13T18.00.jpg

Tweak this to suit your needs, save it as a script, and then invoke it as a cron job by adding this line to /etc/crontab

*/10 8-17 * * 1-5 root /motion/take-snapshot.sh

Cron formatting is a bit weird, so here’s what it means:

  • */10 capture every 10 minutes
  • 8-17 capture between the hours of 8am and 5pm
  • 1-5 capture Monday-Friday

Note that due to the way cron interprets times, the first capture will be at 08:00 and the last will be at 17:50, not 17:00.

The frames will be stitched together into a video using the video editing Swiss army knife that is ffmpeg. There are many customisable options but here’s the gist of it:

ffmpeg -r 30 -pattern_type glob -i '/motion/*.jpg' -s hd1080 -vcodec libx264 timelapse.mp4

This hoovers up all of the JPGs that have been saved, mashes them together at a rate of 30fps and saves it as a full HD, 1080p, H.264-encoded video.

All I have to do now is wait for them to build the tower and hope the camera is pointing in the right direction! It’s a shame I’m so impatient…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s