-
-
Save nguyentruongtho/0162e296e9b1c75d9903c8d509642a85 to your computer and use it in GitHub Desktop.
Transform a movie file to a gif. Specialised for demo's of Mobile app screen recordings.
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/bash | |
FFMPEG=`which ffmpeg` | |
INFILE=$1 | |
OUTFILE="${INFILE}.gif" | |
TMPFILE="${INFILE}_gifify_palette.png" | |
if ! $FFMPEG -L > /dev/null 2>&1; then | |
echo "Run: brew install ffmpeg" | |
exit -1 | |
fi | |
if [ -e $TMPFILE ]; then | |
echo "Error: tmpfile $TMPFILE already exists" | |
exit -1 | |
fi | |
FILTER="fps=10,scale=320:-1:flags=lanczos" | |
$FFMPEG -i $INFILE -vf "$FILTER,palettegen" -y $TMPFILE | |
$FFMPEG -i $INFILE -i $TMPFILE -lavfi "$FILTER [x]; [x][1:v] paletteuse" -y $OUTFILE | |
if [ -e $TMPFILE ]; then | |
rm $TMPFILE | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment