Generate palette from input. Scale is the width of the output, height is generated based on aspect ratio.
ffmpeg -y -t 3 -i input.mov -vf fps=25,scale=320:-1:flags=lanczos,palettegen palette.png
Generate GIF
ffmpeg -t 3 -i input.mov -i palette.png -filter_complex "fps=25,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif