Re: Video surveillance options
On Thu, Jan 20, 2005 at 09:40:26PM -0800, Curtis Vaughan wrote:
> As I see it, the server should know to start archiving any information
> either when the camera is turned on by motion, or when the motion
> sensor detects any activity.
The motion package will take an jpg from a camera whenever it detects
motion. You can control the # of pictures per second. It's easy.
You can also have it take a picture every n seconds regardless of
motion.
I use this with mencoder to convert the jpgs into a soundless mpeg.
I control the frames-per-second so that I can watch six hours of time
lapse in about 90 seconds.
When I leave my apartment, I come back and watch the timelapse of the
entire time and make sure nobody came in. If I need more detail I
single-step the video or go to the jpegs.
I do it all with motion and some dumb bash scripts. Here they are.
I'm the king of utterly hacktacular scripts.
[cam-structure: set up some directories]
mkdir -p /x/cam/incoming
mkdir -p /x/cam/work
mkdir -p /x/cam/output
ln -s /x/x/cam-start /x/cam/start
ln -s /x/x/cam-run /x/cam/run
ln -s /x/x/cam-test /x/cam/test
ln -s /x/b/motion/motion-3.0.6 /x/cam/motion
[cam-run: use X10 to turn on a lamp and start recording]
light on &
cd /x/cam/incoming
../motion/motion -Q -s 640x480 -a 30 -f 4
[cam-start: archive the images and create a movie]
dt=`date +"%y%m%d_%H%M%S"`
cd /x/cam
if [[ `ls work/* | wc -l` -ne 0 ]]; then rm -r work/*; fi
mv incoming/* work
if [[ -e work/lastsnap.jpg ]]; then rm work/lastsnap.jpg; fi
cd work
find -name "*.jpg" > temp
perl -e 'open(F, "temp"); while(chomp($x=<F>)){ $x=~/.\/(....)\/(..)\/(..)\/(..)\/(..)\/(.+)/; print "mv $x $1$2$3_$4$5$6\n"; }' >> temp2
bash temp2
mencoder "mf://*.jpg" -mf fps=25 -o ../output/$dt.avi -ovc lavc
if [[ -e ../output/$dt.avi ]]; then mplayer -fs -speed 0.5 ../output/$dt.avi; fi
if [[ `ls *-snapshot.jpg 2> /dev/null | wc -l` -ne 0 ]]; then
mkdir snap && mv *-snapshot.jpg snap
tar -cvjf ../output/$dt-snap.tar.bz2 snap > /dev/null
fi
if [[ `ls *.jpg 2> /dev/null | wc -l` -ne 0 ]]; then
mkdir motion && mv *.jpg motion
tar -cvjf ../output/$dt-motion.tar.bz2 motion > /dev/null
fi
cd ..
rm -r work/*
[cam-test: see what's on the camera right now]
vidcat -s 640x480 -p y -d /dev/video0 > ~/vidcap.jpg
display ~/vidcap.jpg
rm ~/vidcap.jpg
Reply to: