Skip to content

Instantly share code, notes, and snippets.

@rachellawson
Last active September 1, 2015 13:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rachellawson/3168e8abeca9b46ff30b to your computer and use it in GitHub Desktop.
Save rachellawson/3168e8abeca9b46ff30b to your computer and use it in GitHub Desktop.
Create a d.o compatible mini movie gif rather than a static screenshot
#!/bin/sh
# Create an animated GIF of a screen recording to upload to d.o
# Usage: creategif input_file.mp4 output_file.gif
# As described at http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
palette="/tmp/palette.png"
filters="fps=15,scale=1280:-1:flags=lanczos"
# GIF supports a 256 colour palette. Determine the best palette and store as temp file
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
# Use the stored palette to encode the GIF
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
@rachellawson
Copy link
Author

You'll need to install ffmpeg (Mac: brew install ffmpeg) and have this script somewhere handy.

Use the QuickTime app on your Mac to record a screen recording and then save as a file somewhere - mp4 format is good.

Put this script in /usr/local/bin and run it on the file which will give you a gif file to upload to d.o BUT CHECK HOW BIG IT IS before uploading!!

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