Time Lapse Photography with an Axis 207MW

Posted on April 20th, 2007 by

There are many ways to create time lapse photography these days. The following is just one way we are using Axis 207MW cameras on campus to create interesting videos.

First we connect the camera to our ethernet or wireless network and mount it somewhere that it will not be likely to move. Once we have verified that the camera is up and running and reachable across the network, we setup a script that will start capturing the images.

To view the latest image from an axis camera, you can go to a URL similar to this one:×1024

Viewing that in a browser, you can see exactly what the camera could see at that moment.

Next we need to have a system grab an image from that URL on a set schedule. To do that we created a cron job which calls curl to grab an image from the camera and save it as a time stamped jpg file.

For example, you can tell curl to grab an image and save it to a file like so:
curl -s -o image.jpg

Here is an example script similar to the one we use:

d1=`date +"%y%m%d-%H%M%S"`
d2=`date +"%y%m%d"`
if [ -e "/var/www/html/cam/$d2" ]; then
/usr/bin/curl --connect-timeout 45 -s -o /var/www/html/cam/$d2/$d1.jpg
mkdir "/var/www/html/cam/$d2"
/usr/bin/curl --connect-timeout 45 -s -o /var/www/html/cam/$d2/$d1.jpg

cd /var/www/html/cam/$d2/
rm ../mostcurrent.jpg
ln -s /var/www/html/cam/$d2/`ls -t| head -1` ../mostcurrent.jpg

This script will create a new folder each day and store that days images in it. When a new day comes around, a new folder is created with the new days images. That way if we leave it running for a few months at a time, we don’t end up with a folder with thousands of files in it. This script also creates a link to mostcurrent.jpg so we can easily check out the latest image from the camera.

Next we tell our computer to run this script every minute by placing the following in /etc/crontab where cam-capture is the name of the script above:
* * * * * root /usr/local/bin/cam-capture

Let that run for a few hours and you should have a nice batch of images for the next step. To put all of the images together into a easy to watch movie, I have been using Quicktime. On my Apple Laptop I start Quicktime and from the File menu choose “Open Image Sequence…” A dialog box comes up and in there I choose the first image in the sequence. Usually Quicktime will get the ordering correct and when it is done you can play your time lapse video.

If you want to share the video with others just use Quicktime to export it to an iPod video or other MPEG4/H.264 video format and you are all set.

If you would like to take a look at some of the videos I have created lately, just click on one of these links:


One Comment

  1. aUser says:

    This is a good page. I did something similar in August 2006 and its been running since pulling images from quite a few Axis Network Cameras around the city. Here’s the code if anyone cares:

    -Crontab: grab@2min intervals, encode@11:59pm
    -Use wget to grab images from cameras
    -Use wget to grab weather forecast images
    -Use ImageMagick to overlay current weather/time on the cam image
    -Use convert/mpeg tools to encode videos nightly (daily time-lapse)
    -Encode the 12:00pm shots as a year-to-date time-lapse
    -Serve it up locally with Samba and HTTP over the net

    File “getimage.sh”
    YYYYMMDD=`date +%Y%m%d`
    YYYYMMDD_HHMM=`date +%Y%m%d_%H%M`
    cd /NetworkCamera/Camera1/
    rm image.cgi
    wget –tries=1 –timeout=30 –limit-rate=50k –wait=1 –random-wait –user-agent=your_email http://axis210a/axis-cgi/jpg/image.cgi
    mkdir $YYYYMMDD
    mv image.cgi $YYYYMMDD/$YYYYMMDD_HHMM.jpg

    File “encode.sh”
    YYYYMMDD=`date +%Y%m%d`
    cd /NetworkCamera/Camera1/$YYYYMMDD
    convert *.jpg $YYYYMMDD.mpg

    File “getimage_1200.sh”
    YYYYMMDD=`date +%Y%m%d`
    YYYYMMDD_1200=`date +%Y%m%d_1200`
    cd /NetworkCamera/Camera1/
    cp $YYYYMMDD/$YYYYMMDD_1200.jpg _1200/.

    File “encode_1200.sh”
    cd /NetworkCamera/Camera1/_1200
    rm Camera1_1200.mpg
    convert *.jpg Camera1_1200.mpg

    File “getdate.sh”
    rdate -s your_ntp_server
    hwclock –systohc

    Overlaying Current Weather Over Camera Image:
    cd /NetworkCamera/WUnderground/
    mkdir $YYYYMMDD
    cd /NetworkCamera/
    rm 71852.gif
    wget –tries=1 –timeout=10 http://banners.wunderground.com/weathersticker/miniWeather2_metric_cond/language/www/global/stations/71852.gif
    cp 71852.gif /NetworkCamera/WUnderground/$YYYYMMDD/$YYYYMMDD_HHMM.gif

    cd /NetworkCamera/Camera1/
    rm image.cgi
    wget –tries=1 –timeout=30 –limit-rate=50k –wait=1 –random-wait –user-agent=your_email http://axis2120/cgi-bin/jpg/image.cgi
    mkdir $YYYYMMDD
    mv image.cgi $YYYYMMDD/$YYYYMMDD_HHMM.jpg

    mkdir /NetworkCamera/Camera1+Weather/$YYYYMMDD
    composite -gravity southeast /NetworkCamera/71852.gif /NetworkCamera/Camera1/$YYYYMMDD/$YYYYMMDD_HHMM.jpg /NetworkCamera/Camera1+Weather/$YYYYMMDD/$YYYYMMDD_HHMM.jpg

    And some output at: http://www.youtube.com/timelapseproject