bin/mov2-gif: add -S flag (scale), fix optional 2nd arg

This commit is contained in:
Henrik Lissner 2017-05-10 14:33:09 +02:00
parent 4a3342c626
commit f12f7c845e

View file

@ -15,10 +15,11 @@ PALETTE="/tmp/palette.png"
usage() { usage() {
cat <<EOL cat <<EOL
Usage: $0 [-fsth] [videofile] [destfile] Usage: $0 [-fsSth] SOURCE_FILE [destfile]
-f [FPS] set frames per second -f [FPS] set frames per second
-s [hh:mm:ss] set starting time (like -ss in ffmpeg) -s [hh:mm:ss] set starting time (like -ss in ffmpeg)
-S [W:H] set width/height (either can be -1 for auto)
-t [hh:mm:ss] set the duration to capture (like -t in ffmpeg) -t [hh:mm:ss] set the duration to capture (like -t in ffmpeg)
-h this help -h this help
EOL EOL
@ -29,10 +30,11 @@ trap cleanup EXIT
# #
fps=30 fps=30
while getopts hf:s:t: opt; do while getopts hf:s:t:S: opt; do
case $opt in case $opt in
f) fps="$OPTARG" ;; f) fps="$OPTARG" ;;
s) start="-ss $OPTARG" ;; s) start="-ss $OPTARG" ;;
S) scale=",scale=$OPTARG:flags=lanczos" ;;
t) duration="-t $OPTARG" ;; t) duration="-t $OPTARG" ;;
h) usage h) usage
exit exit
@ -59,8 +61,8 @@ elif [[ ! -f $1 ]]; then
fi fi
src="$1" src="$1"
dest="${2:-${${src##*/}%.mov}.gif}" dest="${2:-${src%.*}.gif}"
flags="fps=${fps}" flags="fps=${fps}$scale"
# stats_mode=full favors motion, causing the resulting palette to better # stats_mode=full favors motion, causing the resulting palette to better
# accomodate fades and transitions. # accomodate fades and transitions.