Convert MP4 to GIF #

1. Simplest method:

$ ffmpeg -i in.mp4 out.gif

out.gif did not display in Finder, Safari, or Preview, but worked in Firefox and Chrome.

2. Oft-cited method using ffmpeg and convert:

$ ffmpeg -i in.mp4 -r 10 frames/frame%03d.png
$ convert -delay 5 -loop 0 frames/frame*.png out.gif

out.gif was over 14 times larger than in.mp4.

3. Best results obtained via this advice:

$ ffmpeg -y -i in.mp4 -vf palettegen palette.png
$ ffmpeg -y -i in.mp4 -i palette.png -filter_complex paletteuse -r 10 out.gif

out.gif was smaller than in.mp4, playable everywhere, and very high quality.

/nix | May 24, 2018


Subscribe or visit the archives.