Motion is a webcam motion capture software. It takes pictures when ever it detects motion on the camera.
sudo apt-get install motion
Configuring and starting motion
If you have more than one webcam (like in the case of a laptop with a built in webcam and an external cam you want to use) you need to change the following line to match the device you want to use. You can use cheese or something equivalent at this point to work out which cam is which.
There are lots of other options in this file, but the default worked for us.
edit /etc/default/motion if you want to run motion as a deamon.
# set to 'yes' to enable the motion deamon start_motion_deamon='yes'
And start the motion deamon
service motion start
Compiling the video
Motion can output video but its default settings are not very hi quality. So I composed the images into a swf using ffmpeg.
First you need to rename the files from motion into a sequence that ffmpeg can use. Run this script in /tmp/motion, or where ever you set the output folder for motion.
x=1; for i in *jpg; do counter=$(printf %03d $x); ln "$1" /tmp/movie/img"$counter".jpg; x=$(($x+1)); done
Then do the conversion propper.
ffmpeg -b 400k -f image2 -i /tmp/movie/img%03d.jpg out.swf