HD time-lapse movies with Motion and Linux part 1

NSLU2 with webcam

The system

Background

I have previously experimented with time lapse videos, but wanted a more dedicated platform which could be set up, and run pretty much anywhere.

This is the first iteration, where the the purpose is to get the system up and running with headless operation.

Next iteration will be to construct a chassis with built-in power source (battery), hence the “part 1″.

Components

The original idea was to use a PC Engines alix1d system board in a box1c enclosure, but unfortunately the board I had was running very unstable – so I brought in an old friend of mine:

The Linksys NSLU2 aka. “slug”. The one I had ran Debian 5.0 Lenny, but had to be upgraded in order to get the webcam to work.

I recklessly tried doing a dist-upgrade, but ended up with bricked slug. Guess a fresh installation was the right answer indeed.

Debian Squeeze on a NSLU2

Due to a required proprietary firmware, the official Debian 6.0 installer does not ship with support for the on board Ethernet controller – which is bad because this is the only way of communicating the the device. Well, technically you can use the serial pin header or an USB Ethernet device, but I think I have burned the circuit for the serial port in a previous modding attempt :-\

There is a few guides that  give you directions on how to add the proprietary firmware to the installer image, and after about 5 reflashes I finally had one that worked.

Before starting the installation, I checked around for known installation errors. The installation takes about 5 hours, so you really want to get i right the first time.

I learned that others had experienced out of memory errors during the installation. Though luck.

To the rescue came Martin Michlmayr. He has the answer to all my quarrels; a compiled guide, with a complete Debian 6 userspace and kernel. This saved me a lot of time.

 Install and configure Motion

You can install motion by

apt-get install motion

as root or via sudo.

On Debian (Squeeze in my case), Motion is disabled by default – as many other services. Enable it, as mentioned in the notice:

Not starting motion daemon, disabled via /etc/default/motion ... (warning).

Setting the value start_motion_daemon to yes in /etc/default/motion as such:

start_motion_daemon=yes

 

The trick to disable motion detection in Motion, is to set the threshold to 0 in the config file:

threshold 0

Enabling time-lapse by setting the following in /etc/motion/motion.conf:

# Use ffmpeg to encode a timelapse movie
# Default value 0 = off - else save frame every Nth second
ffmpeg_timelapse 10

In this case, I take a pictures every ten seconds.

You should also adjust the width and height parameters, and the target_dir.

You can also get a copy of my preconfigured motion.conf by running the following set of commands

/etc/init.d/motion stop
mv /etc/motion/motion.conf /etc/motion/motion.conf.orig
wget http://www.retrospekt.dk/files/motion.conf -O /etc/motion/motion.conf
mkdir /home/motion
chown motion:motion /home/motion
chown root:motion /etc/motion/motion.conf
chmod g+r /etc/motion/motion.conf
/etc/init.d/motion start

An example can be seen here: http://www.retrospekt.dk/files/timelapse.mpg

4 Responses to HD time-lapse movies with Motion and Linux part 1

  1. bloke says:

    Thanks for the above. It all works really good, exactly what I wanted.

    I have one little problem and that is trying to capture to a new file each day. So at midnight I would like it to close today’s mpeg and open a new one.

    Any suggestions would be gratefully received.

    In the meantime enjoy your Christmas.

  2. Girardins says:

    Thanks so much for this awesome little tutorial. I wanted to do some timelapse while I was at the beach, and I read in a few other tutorials that Motion was the way to go, but try as I might, I couldn’t get the motion.conf file to use the timelapse settings. Every time I moved (or something moved) in front of the camera, that’s when the program would begin taking pictures. Thanks again, for letting me download your motion.conf file. With it, I was able to begin taking timelapse video. Lots of people thought I looked a little strange taking my laptop to the beach–but when I noticed the wind was jostling my laptop lid (and therefore my webcam), I gently placed my arm around the back of the laptop to steady the camera. It kindof looked like I took my laptop to the beach for a romantic date. LOL. Anyway, my first timelapse video is here: http://www.youtube.com/watch?v=8BuQJ-Xgw4A.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>