diff --git a/testdata/moonfire-nvr/movement_detection_via_api_ffmpeg.sh b/testdata/moonfire-nvr/movement_detection_via_api_ffmpeg.sh index 782ac7a..5c7cb35 100644 --- a/testdata/moonfire-nvr/movement_detection_via_api_ffmpeg.sh +++ b/testdata/moonfire-nvr/movement_detection_via_api_ffmpeg.sh @@ -74,17 +74,20 @@ main() { echo "$uuid.$recording" >> /tmp/movement_detection_via_api_ffmpeg.sh.txt echo "$cksum" >> /tmp/movement_detection_via_api_ffmpeg.sh.txt else - local next_recording=$(( ${recordings[recording_idx]} - 1 )) - local span="$recording" - if [ "$recording" != "$next_recording" ]; then - span="$recording-$next_recording" + local next_recording=${recordings[recording_idx]} + if [ -z "$next_recording" ] || [ "$recording" == "$next_recording" ]; then + next_recording="$recording" + else + next_recording=$((next_recording-1)) fi - echo no movement in "$span" - for stream in ${streams[@]}; do - api "/api/cameras/$uuid/$stream/view.mp4" \ - -X DELETE \ - -H 'Content-Type: application/json' \ - -d "$(printf '{"s": "%s"}' "$span")" + echo no movement in "$recording..$next_recording" + for j in $(seq $recording $next_recording); do + for stream in ${streams[@]}; do + api "/api/cameras/$uuid/$stream/view.mp4" \ + -X DELETE \ + -H 'Content-Type: application/json' \ + -d "$(printf '{"s": "%s"}' "$j")" + done done fi done