]> git.donarmstrong.com Git - catcam.git/commitdiff
add initial version of motion_detected.sh
authorDon Armstrong <don@donarmstrong.com>
Fri, 9 Dec 2016 19:17:00 +0000 (13:17 -0600)
committerDon Armstrong <don@donarmstrong.com>
Fri, 9 Dec 2016 19:17:00 +0000 (13:17 -0600)
motion_detected.sh [new file with mode: 0755]

diff --git a/motion_detected.sh b/motion_detected.sh
new file mode 100755 (executable)
index 0000000..0387d78
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+EMAIL="foo@example.com"
+
+MOVIE="$1"
+OGG_MOVIE="${MOVIE%%.avi}.ogg"
+MP4_MOVIE="${MOVIE%%.avi}.mp4"
+
+FILENAME=$(basename "$1")
+OGG_FILE="${FILENAME%%.avi}.ogg"
+MP4_FILE="${FILENAME%%.avi}.mp4"
+JPG_FILE="${MOVIE%%.avi}.jpg"
+HTML_FILE="${FILENAME%%.avi}.html"
+
+ffmpeg -i "$MOVIE" -vcodec libtheora -qscale:v 7 -acodec libvorbis "$OGG_MOVIE" >/dev/null 2>&1;
+ffmpeg -i "$MOVIE" -vcodec mpeg4 "$MP4_MOVIE" >/dev/null 2>&1;
+
+LENGTH="$(ffprobe -i "$MOVIE" -show_entries format=duration -v quiet -of csv=p=0)"
+
+ffmpeg -ss 00:00:$(echo 'scale=2;' $LENGTH / 2) -i "$MOVIE" -vframes 1 -q:v 2 "$JPG_FILE" >/dev/null 2>&1;
+
+scp -i /home/motion/motionuser_rsa "$OGG_MOVIE" "$MP4_MOVIE" "$JPG_FILE" motionuser@rzlab.ucr.edu:cat_pics/.;
+cat <<EOF | ssh -i /home/motion/motionuser_rsa motionuser@rzlab.ucr.edu "cat - > cat_pics/$HTML_FILE";
+<html><head><title>Cat Pics $HTML_FILE</title></head>
+<body>
+<video autoplay controls loop>
+<source src="$OGG_FILE" type="video/ogg">
+<source src="$MP4_FILE" type="video/mp4">
+</video></body></html>
+EOF
+
+#cat -<<EOF |mailx -s "Motion detected $FILENAME" "$EMAIL"
+#Motion detected on the cat cam!
+#
+#http://rzlab.ucr.edu/debian/.cat/$HTML_FILE
+#EOF