Making a time-lapse in Debian

Make a script like this called “save”. Make it executable.

#!/bin/sh

ct=0
if [ -f "ct" ]; then
ct=`cat ct`
fi

ct=`expr $ct + 1`

mv snap.jpg snap-$ct.jpg
echo $ct > ct

Run “uvccapture -x648 -y480 -c./save -t20” to take a photo every 20 seconds.

Then you can use a script like this to continually re-encode it and send it to your webserver:
#!/bin/sh

while true
do
rm out.mpg
cat snap-*.jpg | ./ffmpeg -f image2pipe -r 1 -r 20 -vcodec mjpeg -i - out.mpg
scp out.mpg [email protected]:nella.org/jra/geek/3d
done

You can get ffmpeg from here, and not deal with all the problems of library compatibility, if “apt-get install ffmpeg” doesn’t just work.