commit 4fe0af4e6a4a15ee4796a857e79ad0fe9b72c0f1 Author: Dylan <dylanpdx@gmail.com> Date: Wed Dec 28 18:09:25 2022 +0000 Misc. changes to MP4 Looping function commit 42ef8845c38c5a74e56da3c5f035d5a6c091c86a Author: Dylan <dylanpdx@gmail.com> Date: Tue Dec 27 20:00:22 2022 +0000 Abandoning raw gif conversion for now; looping vid instead commit b61938b340a02ac8cfab02048b7e9deaf87edbf5 Author: Dylan <dylanpdx@gmail.com> Date: Tue Dec 27 19:38:58 2022 +0000 More work on WIP gif generation commit 3bc6e7e0da1ce6ae905c80bbbaaa55a68050de52 Author: Dylan <dylanpdx@gmail.com> Date: Mon Dec 26 14:46:46 2022 +0000 Experimental gif conversion
64 lines
1.4 KiB
Bash
64 lines
1.4 KiB
Bash
#!/bin/bash -e
|
|
|
|
usage(){
|
|
echo "Usage: $0 [options] output"
|
|
echo "Options:"
|
|
echo " --help Show this help"
|
|
echo " -u, --url URL of the video"
|
|
echo " -w, --max-width Maximum width of the output"
|
|
echo " -h, --max-height Maximum height of the output"
|
|
echo " -t, --threads Number of threads to use"
|
|
exit 1
|
|
}
|
|
|
|
URL=""
|
|
MAXW=400
|
|
MAXH=267
|
|
THREADS=1
|
|
OUTPUT="out.gif"
|
|
FPS=10
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--help)
|
|
usage
|
|
;;
|
|
-u|--url)
|
|
URL="$2"
|
|
shift
|
|
;;
|
|
-w|--max-width)
|
|
MAXW="$2"
|
|
shift
|
|
;;
|
|
-h|--max-height)
|
|
MAXH="$2"
|
|
shift
|
|
;;
|
|
-t|--threads)
|
|
THREADS="$2"
|
|
shift
|
|
;;
|
|
-f|--fps)
|
|
FPS="$2"
|
|
shift
|
|
;;
|
|
-*)
|
|
echo "Unknown option: $1"
|
|
usage
|
|
;;
|
|
*)
|
|
OUTPUT="$1"
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# make unique temp directory
|
|
TEMPDIR=$( mktemp -d )
|
|
|
|
./ffmpeg -i "$URL" -vf "scale=if(gte(iw\,ih)\,min($MAXW\,iw)\,-2):if(lt(iw\,ih)\,min($MAXH\,ih)\,-2)" -threads $THREADS "$TEMPDIR/frame%04d.png"
|
|
./gifski -o "$TEMPDIR/out.gif" --fast --fps $FPS --quality=90 $TEMPDIR/frame*.png
|
|
#./gifsicle -O3 "$TEMPDIR/out.gif" -o "$OUTPUT"
|
|
mv "$TEMPDIR/out.gif" "$OUTPUT"
|
|
rm -rf "$TEMPDIR" |