Skip to content

Instantly share code, notes, and snippets.

@berikv
Last active December 21, 2021 16:51
Show Gist options
  • Save berikv/98e07aa2ef07d9677a190ebc84532859 to your computer and use it in GitHub Desktop.
Save berikv/98e07aa2ef07d9677a190ebc84532859 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=$(command -v 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
@berikv
Copy link
Author

berikv commented Dec 21, 2021

This is now DEPRECATED, use https://github.com/berikv/gifify instead!

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