diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-06-07 01:33:16 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-06-07 01:33:16 +0300 |
commit | aabd735fd2086c9a4e5cd7e6842f1a0a1fb3f090 (patch) | |
tree | 8723d9611845c0c7c8450a2924ddabbef063069f /tools/video-util.sh | |
parent | 6093cd56b0e9c5a5d8f00b6740c6d75ab61fb67f (diff) |
tools/video-util.sh: do_motion: don't proceed if no motion detected
Diffstat (limited to 'tools/video-util.sh')
-rwxr-xr-x | tools/video-util.sh | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/tools/video-util.sh b/tools/video-util.sh index c6abf16..7ba0d30 100755 --- a/tools/video-util.sh +++ b/tools/video-util.sh @@ -216,18 +216,24 @@ do_motion() { timecodes="${timecodes[@]}" timecodes=${timecodes// /,} - local output_dir="$(dirname "$input")/motion" - if ! [ -d "$output_dir" ]; then - mkdir "$output_dir" || die "do_motion: mkdir($output_dir) failed" - debug "do_motion: created $output_dir directory" - fi + if [ -z "$timecodes" ]; then + debug "do_motion: no motion detected" + else + debug "do_motion: detected timecodes: $timecodes" + + local output_dir="$(dirname "$input")/motion" + if ! [ -d "$output_dir" ]; then + mkdir "$output_dir" || die "do_motion: mkdir($output_dir) failed" + debug "do_motion: created $output_dir directory" + fi - local fragment - while read line; do - fragment=($line) - debug "do_motion: writing fragment start=${fragment[0]} duration=${fragment[1]} filename=$output_dir/${fragment[2]}" - ffmpeg $ffmpeg_args -i "$input" -ss ${fragment[0]} -t ${fragment[1]} -c copy -y "$output_dir/${fragment[2]}" </dev/null - done < <($DIR/process-motion-timecodes.py --source-filename "$input" --timecodes "$timecodes") + local fragment + while read line; do + fragment=($line) + debug "do_motion: writing fragment start=${fragment[0]} duration=${fragment[1]} filename=$output_dir/${fragment[2]}" + ffmpeg $ffmpeg_args -i "$input" -ss ${fragment[0]} -t ${fragment[1]} -c copy -y "$output_dir/${fragment[2]}" </dev/null + done < <($DIR/process-motion-timecodes.py --source-filename "$input" --timecodes "$timecodes") + fi } #dvr_scan_fake() { |