Skip to content

Instantly share code, notes, and snippets.

@ghchinoy
Last active August 29, 2015 14:23
Show Gist options
  • Save ghchinoy/23ee5334cf610f79214e to your computer and use it in GitHub Desktop.
Save ghchinoy/23ee5334cf610f79214e to your computer and use it in GitHub Desktop.
OS X notes for making an animated gif from a movie

Making an Animated GIF from a Movie Clip

Gifsicle

gifsicle or brew install gifsicle

Extract frames

GIF

ffmpeg -ss 00:28:07 -i video.mkv -t 00:00:10 -s 480x270 -pix_fmt rgb24 -f image2 %03d.gif

Gifsicle

gifsicle --delay=5 --loop *.gif > animation.gif

FFMPEG and ImageMagick

Using ffmpeg from brew install ffmpeg and ImageMagick from brew install imagemagick (I had some ffmpeg flags, but I'm not sure which... possibly --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libass --enable-openssl --enable-nonfree --enable-vda

Extract Frames

  • Start: 00:28:07
  • For how long: ten seconds 00:00:10

PNG

ffmpeg -ss 00:28:07 -i video.mkv -t 00:00:10 -s 480x270 -f image2 %03d.png

List a sequence

  • start from number 6
  • go to number 167
  • skipping every 3
seq -f %03.png 6 3 167

convert to gif

may want to mess with o8x8,8 (7,8,9) to get a color pallete of under 256, in which case replace +map animation.gif with -append -format %k info:

convert -delay 1x8 `seq -f %03g.png 10 3 72` \
          -ordered-dither o8x8,8 \
          -coalesce -layers OptimizeTransparency \
          +map animation.gif

Resources

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