thatll do
parent
ddef839399
commit
8af32661eb
|
|
@ -23,6 +23,17 @@ main() {
|
||||||
echo recording=$recording >&2
|
echo recording=$recording >&2
|
||||||
api "/api/recording/video/$recording" > /tmp/movement_detection_via_api_ffmpeg.sh.mp4
|
api "/api/recording/video/$recording" > /tmp/movement_detection_via_api_ffmpeg.sh.mp4
|
||||||
|
|
||||||
|
if video_has_movement; then
|
||||||
|
echo "$recording" >> ${SENTRYSHOT_DIR:-/tmp}/movement_detection_via_api_ffmpeg.sh.txt
|
||||||
|
else
|
||||||
|
echo no movement in "$recording"
|
||||||
|
api "/api/recording/delete/$recording" \
|
||||||
|
-X DELETE
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
video_has_movement() {
|
||||||
local fps=$(_ffprobe -i /tmp/movement_detection_via_api_ffmpeg.sh.mp4 2>&1 | grep -o '[0-9]*\.*[0-9]* fps' | head -n 1 | awk '{print $1}')
|
local fps=$(_ffprobe -i /tmp/movement_detection_via_api_ffmpeg.sh.mp4 2>&1 | grep -o '[0-9]*\.*[0-9]* fps' | head -n 1 | awk '{print $1}')
|
||||||
local inspection="$(_ffmpeg -i /tmp/movement_detection_via_api_ffmpeg.sh.mp4 -vf 'select=not(mod(n\,'${fps%.*}')),select=gte(scene\,0),metadata=print:file=-' -an -f null - 2> /dev/null | paste - -)"
|
local inspection="$(_ffmpeg -i /tmp/movement_detection_via_api_ffmpeg.sh.mp4 -vf 'select=not(mod(n\,'${fps%.*}')),select=gte(scene\,0),metadata=print:file=-' -an -f null - 2> /dev/null | paste - -)"
|
||||||
local scores=($(echo "$inspection" | awk '{print $NF}' | sed 's/.*=//'))
|
local scores=($(echo "$inspection" | awk '{print $NF}' | sed 's/.*=//'))
|
||||||
|
|
@ -49,20 +60,13 @@ main() {
|
||||||
has_change=true
|
has_change=true
|
||||||
else
|
else
|
||||||
local max_flattened_score=$(echo "${flattened_scores[@]:5:${#flattened_scores[@]}-10}" | tr ' ' '\n' | sort -n | tail -n 1)
|
local max_flattened_score=$(echo "${flattened_scores[@]:5:${#flattened_scores[@]}-10}" | tr ' ' '\n' | sort -n | tail -n 1)
|
||||||
echo "${max_flattened_score#*.} > ${threshold#*.}"
|
echo "has movement? $max_flattened_score > $threshold" >&2
|
||||||
if [[ "${max_flattened_score#*.}" > "${threshold#*.}" ]]; then
|
if awk "BEGIN { exit !($max_flattened_score > $threshold)}"; then
|
||||||
has_change=true
|
has_change=true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $has_change; then
|
$has_change
|
||||||
echo "$recording" >> ${SENTRYSHOT_DIR:-/tmp}/movement_detection_via_api_ffmpeg.sh.txt
|
|
||||||
else
|
|
||||||
echo no movement in "$recording"
|
|
||||||
api "/api/recording/delete/$recording" \
|
|
||||||
-X DELETE
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
api() {
|
api() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue