Time Lapse Webcam

Project Requirements
At work we needed a time lapse camera of our new student center construction project. It needs to run continuously for entire length of construction project – approx 18 months. It should run mostly unattended.

It captures 1 picture every 5 minutes. Storage capacity is cheap, so after using excel to make some projections, this worked out to be a reasonable rate for our resources. After some more research, I came to the conclusion that flash video has compatibility with most visitors while being relatively bandwidth efficient, but other codecs could be used. I originally got the idea from http://mydebian.blogdns.org/?p=261 but it wasn’t quite awesome enough, so I rewrote using Perl and expanded upon it.

Requirements – This document assumes you have:
Knowledge using Linux… You’re on your own for installing and configuring

Hardware: The General Idea

Hardware: What we’re using

  • HP D350MT – P4 2.6GHz – 512MB Ram – 80 GB SATA hard drive – retired from classroom
  • Cheap generic capture card using bttv chipset
  • Fixed Security Camera

Software used by the scripts:
I chose Ubuntu 8.04 LTS, but distro isn’t very important.
Note: The rest of the document is assuming use of ubuntu 8.04 LTS

Added packages: installed through apt-get or synaptic
There is more software used, but it is included in Ubuntu 8.04

Perl Modules:
Date::Manip (I used cpan to install, easiest method)

Script Overview:
This entire project is pretty much glued together by cron.


  • Runs every 5 minutes
  • Captures video frame using a strict naming scheme – YYYYMMDDHHmm.jpg


  • Runs once a day at 3 minutes past midnight
  • Builds video from pictures for the day that just ended
  • Builds based on picture filename, not file creation time so it will still function after restoring from backup
  • Creates thumbnails by resizing picture from 10:00AM of first day in video
  • Creates playlist based on thumbnail and video files
  • Copies playlist, thumbnails, and videos to webserver
  • Creates backup and copies to network location


Pulling it all together
I’m going to explain this backwards, from presentation, to how to get it there.

Web Page
One of the most important parts of this project is how it will be displayed to visitors to our site. I let our webmaster handle most of this.

JW FLV Media Player
We decided upon JW FLV Media Player. It is very easy to use.

Alternatives – not quite as awesome as JW FLV Player
A quick search turned up a few alternatives

Web server
Content shared with the internet has to be served from somewhere. We’re already using Microsoft IIS. Since we already have a webserver exposed to the internet, might as well use it to host the time-lapse video too. Also, we know more aobut securing IIS than apache. So hosting videos from the computer that generates them is unappealing. This was an easy decision.

Flash Security
This caused quite a headache when we were trying to play content published to our live webserver from the test webserver… it just didn’t work. I fired up the Firefox extension Tamper Data and loaded the page. It was showing a 404 for crossdomain.xml. A quick search later brought me to http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html.

For example, if playlist.xml points to http://www.example.com/video.flv, http://example.com/video.flv is on a different domain and requires crossdomain.xml

Copy files to webserver
The webserver has a windows file share and a local user account for this project. This local user account has access to nothing else. Luckily, it’s pretty easy to copy files from a linux computer to a windows file share. The command “mount.cifs” (part of smbfs) will mount a windows file share. Then all that’s left is to copy files to the mountpoint and umount to close the connection.

tar/gzip all the pictures and copy to fileshare for safe keeping. Hard drives die more often than I’d like.

Update: 03/02/2010
Updated links.

This has been in place and working since December of 2008. We have had relatively few problems. The biggest of which were due to extended power failure and issues with the video feed.

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: