Converting mp4 to animated GIF

This is something I have found quite helpful while generating animated demos of Scratch movements. Worth to keep it handy.

ffmpeg -i input.mp4 -pix_fmt rgb24 output.gif
ffmpeg -ss 00:00:00.000 -i input.mp4 -pix_fmt rgb24 -r 10 -s 320x240 -t 00:00:10.000 output.gif
convert -layers Optimize output.gif output_optimized.gif

Source: How can I get ffmpeg to convert a .mov to a .gif?