Skip to content

Instantly share code, notes, and snippets.

@ikonst
Last active March 1, 2018 23:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikonst/4150662c1b64e92f781358f6f74207a5 to your computer and use it in GitHub Desktop.
Save ikonst/4150662c1b64e92f781358f6f74207a5 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
# Converts a Quicktime movie to a GIF aniamtion.
# Useful for screen recordings.
# Preliminary step with palette required to make it look good
# without dithering artifacts.
FPS=10
PALETTE=$(mktemp).png
MOV=$1
[[ -n "$GIF" ]] || GIF="${MOV%.*}".gif
[[ -n "$MOV" ]] || {
echo "Syntax: $0 [mov] [gif]"
exit 1
}
which ffmpeg || {
echo "Error: ffmpeg missing"
exit 1
}
ffmpeg -i $MOV -vf palettegen $PALETTE
ffmpeg -i $MOV -i $PALETTE -r $FPS -lavfi "scale=320:-1 [x]; [x][1:v] paletteuse" $GIF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment