From b73ba21c078c23e50e8e2f10adb5d60b32a344dd Mon Sep 17 00:00:00 2001 From: Levon Gevorgyan Date: Sat, 15 Jun 2024 19:25:52 -0500 Subject: [PATCH] slightly better --- scripts/estimate_fg.sh | 33 ++++++++++++++++++++++++++++++++- scripts/recc_encode.sh | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/scripts/estimate_fg.sh b/scripts/estimate_fg.sh index 5dbe457..20375f8 100755 --- a/scripts/estimate_fg.sh +++ b/scripts/estimate_fg.sh @@ -1,7 +1,35 @@ #!/bin/bash +usage() { + echo "estimate_fg.sh -i input_file" + return 0 +} + +OPTS='i:' +NUM_OPTS="${#OPTS}" +# only using -i +MIN_OPT=$NUM_OPTS +# using all +MAX_OPT=$NUM_OPTS +test "$#" -lt "$MIN_OPT" && echo "not enough arguments" && usage && exit 1 +test "$#" -gt "$MAX_OPT" && echo "too many arguments" && usage && exit 1 +while getopts "$OPTS" flag; do + case "${flag}" in + i) + INPUT="${OPTARG}" + ;; + *) + echo "wrong flags given" + usage + exit 1 + ;; + esac +done + +test -f "$INPUT" || (echo "file does not exist" && exit 1) +echo "Estimating film grain for $INPUT" && sleep 2 + # global variables -INPUT="bebop.mkv" SEGMENTS=10 SEGMENT_TIME=3 DURATION="$(get_duration "$INPUT")" @@ -71,3 +99,6 @@ encode_segments() { clear cat "$GRAIN_LOG" } + +segment_video +encode_segments diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index 5fb61f6..c7d3c88 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -76,7 +76,7 @@ get_bitrate_audio() { OPTS='i:p:g:' -NUM_OPTS=$(echo $OPTS | wc -m) +NUM_OPTS="${#OPTS}" PRINT_OUT="false" GRAIN="" # only using -i