Skip to content

Instantly share code, notes, and snippets.

@robinraszka
Forked from stephenlb/animated-gif.md
Created May 25, 2016 20:10
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 robinraszka/e360076a8434b39ee308a460badb8f23 to your computer and use it in GitHub Desktop.
Save robinraszka/e360076a8434b39ee308a460badb8f23 to your computer and use it in GitHub Desktop.
DIY How to make your own HD Animated GIF Generator

HD Animated GIF Generator

You can make your own HD animated GIF generator.
Follow along with these commands to get started.

HD Animated GIF Generator

git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --disable-yasm ## may need to disable yasm
sudo make install

Create the HD Animated GIF Generator

Make a new file called hd-gif and add the following text.

#!/bin/sh

## echo
## echo "USAGE"
## echo
## echo "./hd-gif source.mp4 dest.gif FPS RESOLUTION"
## echo "./hd-gif video.mp4 animated.gif 30 480"
## echo

fps=$3
res=$4
palette="/tmp/palette.png"
filters="fps=$fps,scale=$res:-1:flags=lanczos"
paletteops="stats_mode=diff"
paletteops=""

#echo "./ffmpeg -v warning -i $1 -vf $filters,palettegen=$paletteops -y $palette"
./ffmpeg -v warning -i $1 -vf "$filters,palettegen=$paletteops" -y $palette
./ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2

Make Executable: chmod +x hd-gif

Now you can use your hd-gif script like this: ./hd-gif video.mkv anim.gif 24 480

Source Blog

http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html#usage

Upload to imgur for Hosting and .webm

You will finally want to upload to http://imgur.com to provide free hosting and easy quick links. If your gif is over 7mb then Imgur will convert it to WebM format for performance.

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