Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Creating GIFs from .MOV files in OSX using FFmpeg and ImageMagick

Convert MOV to GIF using FFmpeg and ImageMagick

I tried a few different techniques to make a GIF via command-line and the following gives me the best control of quality and size. Once you're all setup, you'll be pumping out GIFs in no time!


Install FFmpeg

  • $ brew install ffmpeg [all your options]
    • Example: $ brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

Install ImageMagick

  • $ brew install imagemagick

Now convert!

Grab screenshot from Quicktime (or what you want. I like Screenflow)

  • Open Quicktime > File > New Screen Recordering > After recording 'Save'

Use ffmpeg to slice .mov into high quality .png's

  • $ ffmpeg -i -vf scale=320:-1 -r 10 output/ffout%3d.png
    • '' location of .mov
    • 'scale=320' set scale to what you want
    • '-r 10' set framerate
    • 'output/ffout%3d.png' output pngs in output folder

Use Convert from ImageMagick

  • $ convert -delay 8 -loop 0 output/ffout*.png output/animation.gif
  • 'convert' is the command-line tool from ImageMagick
  • '-dalay' is the delay of 8, you would get a FPS=100/8=12.5
  • '-loop' adds Netscape loop extension to your GIF animation
  • 'output/ffout*.png' is the directory and file names going into the GIF
  • 'output/animation.gif' is the final location and GIF output


Great Articles


This comment has been minimized.

Copy link

@nvenegas nvenegas commented Feb 20, 2017

I found that for a screencast, using the above convert command resulted in the white background of the window in the screencast flickering between different shades of white.


The command line solution is a special +map option, that does a global color reduction to a common palette that is added to all images.

This fixed it right up!


This comment has been minimized.

Copy link

@Craigson Craigson commented Mar 22, 2017

This was very helpful, thank you for posting! However, I ran into a number of issues as a result of the limited colour palette for the multiple PNG versions in the conversion to GIF that resulted in a very dull output. You can achieve much richer colour results using ffmpeg directly and ignoring the ImageMagick step. See this post


This comment has been minimized.

Copy link

@LAITONEN LAITONEN commented Mar 14, 2018

What does $ brew install ffmpeg [all your options] mean?
You list a lot of options below that, but don't specify which ones are required to convert from MOV to GIF.


This comment has been minimized.

Copy link

@sflanders95 sflanders95 commented Dec 22, 2018

I have MacOS Mojave, and brew install ffmpeg fails: Error: You are using macOS 10.14.
The ImageMagick install worked as above: brew install imagemagick

I was able to install ffmpeg using:

$ xcode-select --install ; #  <-- I did this but it may not have been needed.
$ curl | tar xjf -
$ cd ffmpe*
$ ./configure --disable-asm
$ make
$ sudo chown -R $(whoami) /usr/local/bin
$ make install
$ sudo chown -R root /usr/local/bin
$ make clean

From there all of the mov to gif commands above worked just fine.
Thanks for this gist!

fyi: Here was my resulting ffmpeg and ImageMagick versions:

$ ffmpeg -version
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
configuration: --disable-asm
libavutil      56. 22.100 / 56. 22.100
libavcodec     58. 35.100 / 58. 35.100
libavformat    58. 20.100 / 58. 20.100
libavdevice    58.  5.100 / 58.  5.100
libavfilter     7. 40.101 /  7. 40.101
libswscale      5.  3.100 /  5.  3.100
libswresample   3.  3.100 /  3.  3.100
$ convert -version
Version: ImageMagick 7.0.7-31 Q16 x86_64 2018-05-07
Copyright: © 1999-2018 ImageMagick Studio LLC
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment