Last active
October 19, 2018 17:48
-
-
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
This file contains hidden or 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/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}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.