First, save the input video as individual frames at 10 FPS:
ffmpeg -i input.mp4 -vf scale=500:-1:flags=lanczos,fps=10 frames/ffout%03d.png
Next, join the frames up again to make the gif:
ffmpeg -i ./frames/ffout%03d.png output.gif
Bonus to optimise the gif with gifsicle:
gifsicle -O3 output.gif -o output-optimized.gif