Last active
February 17, 2018 11:10
-
-
Save ashdavies/3fd0fd02de64eea0941dd6c62082b75b to your computer and use it in GitHub Desktop.
Export an optimised GIF from an MP4
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/sh | |
if [[ ${1:(-4)} != ".mp4" ]]; then | |
echo "Invalid input file $1" | |
exit 1 | |
fi | |
palette="${1%.*}-palette.png" | |
filters="fps=25,scale=320:-1:flags=lanczos" | |
gif=${1%.*}.gif | |
echo "Converting $1 to $gif" | |
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette | |
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $gif | |
rm $palette |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment