This shows you the differences between two versions of the page.
Last revisionBoth sides next revision | |||
fuss:motion [2017/11/21 16:02] – created office | fuss:motion [2018/04/10 17:42] – office | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Schedule Motion Movement Detection ====== | ||
+ | The following script should be run every minute (placed in ''/ | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/sh | ||
+ | ########################################################################### | ||
+ | ## Copyright (C) Wizardry and Steamworks 2017 - License: GNU GPLv3 ## | ||
+ | ## Please see: http:// | ||
+ | ## rights of fair usage, the disclaimer and warranty conditions. | ||
+ | ########################################################################### | ||
+ | ## The script uses motion to start and stop motion detection such that ## | ||
+ | ## the camera will start recording only within the given time intervals. ## | ||
+ | ## ## | ||
+ | ## To use the script, drop into / | ||
+ | ## will be called every minute by crontab and pause or start detection. | ||
+ | ########################################################################### | ||
+ | |||
+ | ########################################################################### | ||
+ | ## CONFIGURATION | ||
+ | ########################################################################### | ||
+ | |||
+ | # The detection URL to the motion webserver. | ||
+ | MOTION_URL_DETECTION=http:// | ||
+ | |||
+ | # The start time after which recording should start (HHmm) | ||
+ | START_TIME=0705 | ||
+ | |||
+ | # The end time after which recording should stop (HHmm) | ||
+ | PAUSE_TIME=1700 | ||
+ | |||
+ | ########################################################################### | ||
+ | ## INTERNALS | ||
+ | ########################################################################### | ||
+ | |||
+ | # Get the current recording status. | ||
+ | DETECTION_STATUS=`curl -s $MOTION_URL_DETECTION"/ | ||
+ | |||
+ | # Get the current time. | ||
+ | CURRENT_TIME=`date +%H%M` | ||
+ | |||
+ | # Whether the current time falls between the defined start and stop times. | ||
+ | test `[ $CURRENT_TIME -ge $START_TIME ] && [ $CURRENT_TIME -le $PAUSE_TIME ]` | ||
+ | case $? in | ||
+ | 0) | ||
+ | case $DETECTION_STATUS in | ||
+ | PAUSE) | ||
+ | logger "Start recording..." | ||
+ | # Instruct the camera to start detection and recording. | ||
+ | curl -s $MOTION_URL_DETECTION"/ | ||
+ | ;; | ||
+ | esac | ||
+ | ;; | ||
+ | *) | ||
+ | case $DETECTION_STATUS in | ||
+ | ACTIVE) | ||
+ | logger "Stop recording..." | ||
+ | # Instruct the camera to start detection and recording. | ||
+ | curl -s $MOTION_URL_DETECTION"/ | ||
+ | ;; | ||
+ | esac | ||
+ | ;; | ||
+ | esac | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====== Reduce CPU Usage ====== | ||
+ | |||
+ | Motion can be very CPU intensive when capturing streams such that the following tips can be used as a guide to lowering the CPU usage considerably: | ||
+ | |||
+ | * Determine the exact width, height and framerate that the camera is capable of, select the lowest resolution that the camera offers and change '' | ||
+ | * Edit ''/ | ||
+ | < | ||
+ | ffmpeg_video_codec mp4: | ||
+ | </ | ||
+ | |||
+ | in order to benefit from hardware accelerated video capturing. This option alone should lower the CPU consumption considerably and the hardware acceleration is now present on Raspberry Pi 2 and 3. |