Quantcast
Channel: Amagob IT Blog
Viewing all articles
Browse latest Browse all 13

Motion Webcam motion recorder

$
0
0

I’m just loving this application. A few posts back I explained how I had to reinstall my Proxmox server and bind my usb port to a container to assign my webcam to that app. Well, that worked great. Motion is awesome, just run through the config file and type motion and you start capture images and videos from your webcam on detecting motion. My full config page is available on my wiki here:

http://www.amagob.com/wiki/index.php/Motion

Further to that, I configured cron to start and stop the application when there isn’t supposed to be anyone motion, and a script that checks for new photos every minute and send me an email.

* 7-19 * * 1-5 /opt/motion/msurveillance
00 7 * * 1,2,5 motion
30 8 * * 3,4 motion
00 17 * * 1,2,5 killall motion
30 18 * *3,4 killall motion

(if you’re still figuring out:
Line 1:  run the script every minute from 7h to 19h Monday to Friday
Line 2: Start Motion Monday, Tuesday, Friday at 7h
Line 3: Start Motion Wednesday, Thursday at 8h30
Line 4: Stop Motion Monday, Tuesday, Friday at 17h
Line 5: Stop Motion Wednesday,Thursday at 18h30
and yes I’ve faked these values of course..)

If you wonder how I send my email to the  Internet, well, I use Exim to relay my email with my gmail account (not with 2 factor authentication), check my wiki here for configuration

http://www.amagob.com/wiki/index.php/EmailRelay

and my script to check my folder for new images is as follows

 

#/bin/bash
#
# if file "LastPhototxt" exist,
#   read file, get name_of_last_photo(emailed)
#   Get name of "lastphotojpg"(file) compare with name in "lastphototxt"
#
#     if name is different
#      send photo by email
#      copy lastphotojpg in file lastphototxt
#     fi
#
# else,
# create file lasphototxt
# write lastphotojpg to file lastPhototxt
#

LastPhotojpgpath=`ls -t /opt/motion/*20*.jpg | head -1`
LastPhotojpg=`basename "$LastPhotojpgpath"`

if [ -f /opt/motion/LastPhototxt ]
 then

	for line in $(cat /opt/motion/LastPhototxt)
	do
		if [ $LastPhotojpg != $line ] ; then
			$(mpack -s 'Motion at Home' -a  $LastPhotojpgpath  absando@amagob.com,par2503@g
mail.com)
			$(echo $LastPhotojpg > /opt/motion/LastPhototxt)
			$(logger msurveillance $LastPhotojpg sent by email)
		fi

	done;
else
	$(touch LastPhototxt)
	$(echo $LastPhotojpg > /opt/motion/LastPhototxt)
fi

There are other applications that does the same and I just saw today a freeware that runs on Windows which does all that as well. It’s called YAWCam. Check it out and let me know what you think.. ;)


Viewing all articles
Browse latest Browse all 13

Trending Articles