Skip to content

Instantly share code, notes, and snippets.

@simonfranzen
Last active October 19, 2018 17:48
Show Gist options
  • Save simonfranzen/a9f660a1d489296a66a274855e56da1f to your computer and use it in GitHub Desktop.
Save simonfranzen/a9f660a1d489296a66a274855e56da1f to your computer and use it in GitHub Desktop.
GIF from video // Run with $ sh gif.bash -i=InputFile.mov -o=OutputFile
#!/bin/bash
# Run with $ sh gif.bash -i=InputFile.mov -o=OutputFile
for i in "$@"
do
case $i in
-i=*|--input=*)
INPUT_FILE="${i#*=}"
;;
-o=*|--output=*)
OUTPUT_FILE="${i#*=}"
;;
*)
# unknown option
;;
esac
done
PALETTE_FILE=palette.png
ffmpeg -y -i "${INPUT_FILE}" -vf fps=10,scale=320:-1:flags=lanczos,palettegen "${PALETTE_FILE}"
ffmpeg -ss 0 -i "${INPUT_FILE}" -i "${PALETTE_FILE}" -filter_complex "fps=10,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" "${OUTPUT_FILE}.gif"
rm "${PALETTE_FILE}"
@simonfranzen
Copy link
Author

Needs ffmpeg to be installed.

It uses palettegen for higher quality gifs.

Creates a 320 width GIF from given input video. Accepts all video formats like .mp4, .mov etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment