Skip to content

Instantly share code, notes, and snippets.

@wearhere
Created October 22, 2015 00:06
Show Gist options
  • Save wearhere/4ac5c33363b69fa0e8c5 to your computer and use it in GitHub Desktop.
Save wearhere/4ac5c33363b69fa0e8c5 to your computer and use it in GitHub Desktop.
A pretty good-quality way to create a GIF from a 10-second 720p screencast (recorded using Quicktime Player).
# Run these commands in the Terminal. Prerequisite: you have Homebrew (http://brew.sh/) installed.
#
# Thanks to http://superuser.com/a/556031 for this technique.
# 1. Install ffmeg. Only need to do this once.
brew install ffmpeg
# 2. Generate a color palette from the video to avoid dithering (http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html).
# Default options:
# - fps=20 (Speeds up the GIF a little bit)
# - scale=600:-1 (Makes the GIF 600px wide with the height scaled to preserve the aspect ratio)
# Use these same options in the next command.
ffmpeg -y -i /path/to/movie.mov -vf fps=20,scale=600:-1:flags=lanczos,palettegen palette.png
# 3. Output the GIF using the palette. Produces `output.gif` in the same directory.
ffmpeg -y -i /path/to/movie.mov -i palette.png -filter_complex "fps=20,scale=600:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
# 4. Delete `palette.png` produced by step 2.
rm palette.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment