# Create a full colour palette from a source
ffmpeg -y -i <input> -vf fps=15,scale=1024:-1:flags=lanczos,palettegen palette.png
# Export a GIF from the source, using the palette
ffmpeg -y -i <input> -i palette.png -filter_complex "fps=15,scale=800:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
See other useful combinations here: https://gist.github.com/dergachev/4627207