I’ve written a tool specifically for maximum quality:
https://gif.ski
ffmpeg -i video.mp4 frame%04d.png
gifski -o clip.gif frame*.png
It generates good per-frame palettes, but also combines palettes across frames, achieving even thousands of colors per frame.
If you want to reduce the video dimensions, add a scaling filter:
ffmpeg -i video.mp4 -vf scale=400:240 frame%04d.png
If you want to reduce the frame rate, add the fps
filter:
ffmpeg -i video.mp4 -vf fps=12 frame%04d.png
You can combine the filters with -vf scale=400:240,fps=12