Skip to content

Instantly share code, notes, and snippets.

@irace
Created January 30, 2017 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irace/a81f95c0a596342427403c87a567ea82 to your computer and use it in GitHub Desktop.
Save irace/a81f95c0a596342427403c87a567ea82 to your computer and use it in GitHub Desktop.
GIF.sh
#!/bin/bash
#
# A simple script to generate an animated gif from an mp4 file.
#
# Some notes:
# - To use this you need both ffmpeg and imagemagick installed. You can 'brew install' both of them.
# - Our version of github enterprise has a 10MB size limit per file. Make sure your gifs are below that limit.
#
# This is based on https://gist.github.com/dergachev/4627207
#
# Example usage: ./make-gif.sh my-input-video.mp4
# Notes on the arguments:
#
# -r 10 tells ffmpeg to reduce the frame rate from 25 fps to 10
# -s 320x568 tells ffmpeg the max-width and max-height
# --delay=5 tells imagemagick to delay 50ms between each frame
ffmpeg -i $1 -s 320x568 -r 10 -f image2pipe -vcodec ppm - | convert -delay 5 -layers Optimize -loop 0 - out.gif
# Gifsicle version. This requires you to 'brew install gifsicle' before using.
# This is way faster and generates smaller (filesize) gifs, but the gifs are lower quality than imagemagick's.
# ffmpeg -i $1 -s 320x568 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment