From 1ed87f69878b85daf94cde4c7b187939d9e15778 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Wed, 8 Jun 2022 14:50:17 +0300 Subject: tools/video-util.sh: refactoring and improvements --- tools/video-util.sh | 130 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 94 insertions(+), 36 deletions(-) (limited to 'tools') diff --git a/tools/video-util.sh b/tools/video-util.sh index 35d0af0..08d8938 100755 --- a/tools/video-util.sh +++ b/tools/video-util.sh @@ -15,13 +15,14 @@ CYAN=$(tput setaf 6) input= output= command= -roi_file= motion_threshold=1 ffmpeg_args="-nostats -loglevel error" dvr_scan_args="-q" verbose= config_dir=$HOME/.config/video-util config_dir_set= +write_data_prefix= +write_data_time= _time_started= @@ -53,7 +54,7 @@ echowarn() { } die() { - >&2 echo "error: $@" + echoerr "$@" exit 1 } @@ -119,24 +120,35 @@ config_set_prev_mtime() { } usage() { - cat <<-_EOF - usage: $PROGNAME OPTIONS command - - Options: - -i|--input input file/directory - -o|--output output file/directory - --roi-file path to file with ROI sets - -mt motion threshold - -v, -vv, vx be verbose - --config-dir config directory - - Commands: - fix, mass-fix fix video timestamps - mass-fix-mtime fix mtimes of recordings - motion detect motion - snapshot take video snapshot - - _EOF + cat <&2 echo "using ${BOLD}$config_dir${RST} as config directory" fi [ -z "$command" ] && die "command not specified" @@ -351,7 +389,12 @@ case "$command" in motion) check_input_file - do_motion + do_motion "$input" + ;; + + mass-motion) + check_input_dir + do_mass_motion "$input" ;; snapshot) @@ -364,6 +407,21 @@ case "$command" in echoinfo "saved to $output" ;; + write-mtime-config) + if [ -z "$write_data_prefix" ] || [ -z "$write_data_time" ]; then + die "--write-data is required, see usage" + fi + + if [[ $write_data_time == record_* ]]; then + write_data_time=$(filename_as_unixtime "$write_data_time") + [ -z "$write_data_time" ] && die "invalid filename" + elif ! [[ $write_data_time =~ '^[0-9]+$' ]] ; then + die "invalid timestamp or filename" + fi + + config_set_prev_mtime "$write_data_prefix" "$write_data_time" + ;; + *) echo "error: invalid command '$command'" ;; -- cgit v1.2.3