Last active
June 5, 2020 19:28
-
-
Save nasahapps/44bfe068b17d71b64b9d52103c5dd093 to your computer and use it in GitHub Desktop.
Converts a .mov file to a gif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
scale=400 | |
while [ -n "$1" ]; do | |
case "$1" in | |
-s) | |
scale="$2" | |
shift | |
shift | |
;; | |
-*) | |
echo "Option $1 not recognized" | |
shift | |
;; | |
*) break ;; | |
esac | |
done | |
if [ $# != 2 ]; then | |
echo "Invalid params" | |
echo "Usage: mov_to_gif.sh [-s <width in pixels>] <input file> <output directory>" | |
exit 1 | |
fi | |
if [ ! -d $2 ]; then | |
echo "Creating dir $2" | |
echo | |
echo | |
mkdir $2 | |
fi | |
echo "Creating frames from .mov file..." | |
echo | |
echo | |
ffmpeg -i "$1" -vf scale=$scale:-1 -r 10 $2/out%3d.png | |
echo | |
echo "Creating gif from frames..." | |
echo | |
convert -delay 8 -loop 0 $2/out*.png $2/animation.gif | |
echo "Deleting frames" | |
rm $2/*.png | |
echo "Conversion done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment