From aabd735fd2086c9a4e5cd7e6842f1a0a1fb3f090 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Tue, 7 Jun 2022 01:33:16 +0300 Subject: [PATCH] tools/video-util.sh: do_motion: don't proceed if no motion detected --- tools/video-util.sh | 28 +++++++++++++++++----------- 1 file 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 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]}"