Server:Server Status

Building a Security Cam/Time-Lapse Video/Auto Webcam System on Linux

I left for the weekend, and left my dog at home (he has a doggy door and an auto food/water thing, he's ok). I leave a webcam on so I can check on him; the way I have it set up is that I want a picture copied to my public dropbox folder then embedded in an html page, so I can check on him from anywhere. Also, my family/friends like to look in on him.

To make this work, the dependencies are dropbox, fswebcam, and cheese. fswebcam does the actual picture capturing, cheese is used to auto-calibrate the camera (you can set settings with fswebcam, but it's a pain...I find if you open cheese for 10 seconds then kill it every 30 minutes, its auto-adjust sticks and works great). Here's my script, called autocam.sh:

#!/bin/bash<br /> case "$1" in<br /><br /> recal)<br /> &nbsp;&nbsp;cheese &<br /> &nbsp;&nbsp;sleep 10s<br /> &nbsp;&nbsp;killall cheese<br /> &nbsp;&nbsp;exit 1<br /> ;;<br /><br /> <em>)<br /> &nbsp;&nbsp;now=$(/bin/date '+%Y%m%d%H%M')<br /> &nbsp;&nbsp;mv /Path/To/Dropbox/Public/RygelWatch.jpg /Path/To/Pictures/RygelWatch/RygelWatch.${now}.jpg<br /> &nbsp;&nbsp;/usr/bin/fswebcam -d v4l2:/dev/video0 -i 0 -r "640x480" --deinterlace --no-banner "/Path/To/Dropbox/Public/RygelWatch.jpg"<br /> &nbsp;&nbsp;exit 1<br /> esac

This is then called using the following cronjobs:

</em>/2 <em> </em> <em> </em> sh /Path/To/Scripts/autocam.sh<br /> 1,31 <em> </em> <em> </em> sh /Path/To/Scripts/autocam.sh recal

Boom, works great!

So, then to turn it into a timelapse, I cd into the ~/Pictures/RygelWatch folder and run:

ls -1tr | grep -v files.txt > files.txt

I then build the video using mencoder with the following command:

mencoder -nosound -noskip -oac copy -ovc copy -o 2013.08.25.RygelWatch.avi -mf fps=15 'mf://@files.txt'

This works great! Finally, I opened that up in openshot, polished it a bit, and submitted it to youtube:

The autocam function is something I've been meaning to expand on. I actually have raspberry pi's in several of the rooms in my house; I'd like to set up about 8 of them and use it as a security cam from a web interface I'd access on an internal web server (over vpn); it'd be very expandable very quickly. By symlinking from shares and cutting out the whole "upload to public dropbox" step, it won't use a ton of bandwidth and if I drop to grayscale I think it could be an adequate security cam system or something. The only obvious limit is that the auto-opening of cheese selects /dev/video0 for the auto-configuration, but I'm sure I can figure that out once it's actually an issue. For now, it's just webcams while we leave the dog home.

Hope you enjoy!

Leave a Reply