Skip to content

Instantly share code, notes, and snippets.

@nguyentruongtho
Forked from berikv/gifify
Created December 5, 2016 15:56
Show Gist options
  • Save nguyentruongtho/0162e296e9b1c75d9903c8d509642a85 to your computer and use it in GitHub Desktop.
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.
#!/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