bin/mov2gif: refactor

This commit is contained in:
Henrik Lissner 2016-11-10 18:39:08 +01:00
parent e2b42cf6fa
commit 318f5d22c7

View file

@ -2,20 +2,19 @@
usage() { echo "Usage: $0 [-f <fps>] [-o <output-dest>] [-h]"; } usage() { echo "Usage: $0 [-f <fps>] [-o <output-dest>] [-h]"; }
if [[ $# = 0 ]]; then if (($# == 0)); then
>&2 echo "No movie file specified" >&2 echo "No movie file specified"
exit exit
elif [[ ! -f "$1" ]]; then elif [[ ! -f $1 ]]; then
>&2 echo "$1 does not exist" >&2 echo "$1 does not exist"
exit exit
fi fi
fps=30 fps=30
src="$1" src="$1"
dest="${$(basename $src)%.mov}.gif" dest="${${src##*/}%.mov}.gif"
while getopts hf:o: opt while getopts hf:o: opt; do
do case $opt in
case "$opt" in
-f) fps="$OPTARG" ;; -f) fps="$OPTARG" ;;
-o) dest="$OPTARG" ;; -o) dest="$OPTARG" ;;
-h) usage -h) usage
@ -34,4 +33,4 @@ flags="fps=${fps}"
ffmpeg -v warning -i "$src" -vf "$flags,palettegen" -y "$palette" ffmpeg -v warning -i "$src" -vf "$flags,palettegen" -y "$palette"
ffmpeg -v warning -i "$src" -i "$palette" -lavfi "$flags [x]; [x][1:v] paletteuse" -y "$dest" ffmpeg -v warning -i "$src" -i "$palette" -lavfi "$flags [x]; [x][1:v] paletteuse" -y "$dest"
[ -f "$palette" ] && rm -f "$palette" [[ -f $palette ]] && rm -f "$palette"