How can I get ffmpeg to convert a .mov to a .gif?

The order of command line arguments matters. This command line should work but will generate a giant file:

ffmpeg -i yesbuddy.mov -pix_fmt rgb24 output.gif

Note that you probably want to reduce the frame rate and size when you convert, as well as specify a start time and duration. You probably do not want to convert the entire file at its original resolution and frame rate.

ffmpeg -ss 00:00:00.000 -i yesbuddy.mov -pix_fmt rgb24 -r 10 -s 320x240 -t 00:00:10.000 output.gif

The file size will still be huge. You may be able to use ImageMagick's GIF optimizer to reduce the size:

convert -layers Optimize output.gif output_optimized.gif

After converting:

ffmpeg -i input.mp4 input.gif 

Try optimize frames:

convert input.gif -verbose -coalesce -layers OptimizeFrame input_optframe.gif

And use gifsicle to make final optimization:

gifsicle -O2 input_optframe.gif -o optimized.gif

Got 6.8mb GIF from 12.2mb video with almost the same quality!


I made a tool that bundles FFmpeg, ImageMagick and giflossy into a single easy to use command line program that you can install in one line: https://github.com/vvo/gifify

I recommend anyone willing to turn videos => GIF to use it instead of trying to spend a lot of time browsing 3 documentation websites to understand how to resize the GIF or change the start/end time.