{"id":1421,"date":"2013-08-27T13:43:20","date_gmt":"2013-08-27T20:43:20","guid":{"rendered":"https:\/\/surfrock66.com\/?p=1421"},"modified":"2013-08-27T13:45:23","modified_gmt":"2013-08-27T20:45:23","slug":"building-a-security-camtime-lapse-videoauto-webcam-system-on-linux","status":"publish","type":"post","link":"https:\/\/surfrock66.com\/?p=1421","title":{"rendered":"Building a Security Cam\/Time-Lapse Video\/Auto Webcam System on Linux"},"content":{"rendered":"<p><p>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.<\/p>\r\n<p>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:<\/p>\r\n<code>#!\/bin\/bash<br \/>\ncase \"$1\" in<\/p>\n<p>recal)<br \/>\n&nbsp;&nbsp;cheese &amp;<br \/>\n&nbsp;&nbsp;sleep 10s<br \/>\n&nbsp;&nbsp;killall cheese<br \/>\n&nbsp;&nbsp;exit 1<br \/>\n;;<\/p>\n<p>*)<br \/>\n&nbsp;&nbsp;now=$(\/bin\/date '+%Y%m%d%H%M')<br \/>\n&nbsp;&nbsp;mv \/Path\/To\/Dropbox\/Public\/RygelWatch.jpg \/Path\/To\/Pictures\/RygelWatch\/RygelWatch.${now}.jpg<br \/>\n&nbsp;&nbsp;\/usr\/bin\/fswebcam -d v4l2:\/dev\/video0 -i 0 -r \"640x480\" --deinterlace --no-banner \"\/Path\/To\/Dropbox\/Public\/RygelWatch.jpg\"<br \/>\n&nbsp;&nbsp;exit 1<br \/>\nesac <\/code>   \r\n<p>This is then called using the following cronjobs:<\/p>\r\n<code>*\/2 * * * * sh \/Path\/To\/Scripts\/autocam.sh<br \/>\n1,31 * * * * sh \/Path\/To\/Scripts\/autocam.sh recal<\/code>\r\n<p>Boom, works great!<\/p>\r\n<p>So, then to turn it into a timelapse, I cd into the ~\/Pictures\/RygelWatch folder and run:<\/p>\r\n<code>ls -1tr | grep -v files.txt > files.txt<\/code>\r\n<p>I then build the video using mencoder with the following command:<\/p>\r\n<code>mencoder -nosound -noskip -oac copy -ovc copy -o 2013.08.25.RygelWatch.avi -mf fps=15 'mf:\/\/@files.txt'<\/code>\r\n<p>This works great! Finally, I opened that up in openshot, polished it a bit, and submitted it to youtube:<\/p><span style=\"text-align:center;\">\r\n<iframe width=\"420\" height=\"315\" src=\"\/\/www.youtube.com\/embed\/OrzmttIBCpY\" frameborder=\"0\" allowfullscreen><\/iframe><\/span>\r\n<p>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.\r\n<p>Hope you enjoy!<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/bash case &#8220;$1&#8221; in recal) &nbsp;&nbsp;cheese &amp; &nbsp;&nbsp;sleep 10s &nbsp;&nbsp;killall cheese &nbsp;&nbsp;exit 1 ;; *) &nbsp;&nbsp;now=$(\/bin\/date &#8216;+%Y%m%d%H%M&#8217;) &nbsp;&nbsp;mv \/Path\/To\/Dropbox\/Public\/RygelWatch.jpg \/Path\/To\/Pictures\/RygelWatch\/RygelWatch.${now}.jpg &nbsp;&nbsp;\/usr\/bin\/fswebcam -d v4l2:\/dev\/video0 -i 0 -r &#8220;640&#215;480&#8221; &#8211;deinterlace &#8211;no-banner &#8220;\/Path\/To\/Dropbox\/Public\/RygelWatch.jpg&#8221; &nbsp;&nbsp;exit 1 esac *\/2 * * * * sh \/Path\/To\/Scripts\/autocam.sh 1,31 * * * * sh \/Path\/To\/Scripts\/autocam.sh recalls -1tr | grep -v files.txt > files.txtmencoder [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1421","post","type-post","status-publish","format-standard","hentry","category-projects"],"_links":{"self":[{"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/posts\/1421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/surfrock66.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1421"}],"version-history":[{"count":13,"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/posts\/1421\/revisions"}],"predecessor-version":[{"id":1434,"href":"https:\/\/surfrock66.com\/index.php?rest_route=\/wp\/v2\/posts\/1421\/revisions\/1434"}],"wp:attachment":[{"href":"https:\/\/surfrock66.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/surfrock66.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/surfrock66.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}