How to generate gif from avi using ffmpeg? [closed]

I had a similar problem trying to generate high quality animated gif from a series of images extracted from a movie.

For some reasons the animated gif generated with ffmpeg only contains 103 colors assumable using a fixed 256 level system color palette resulting in horrific result. My solution was instead

ffmpeg -i video.avi -t 10 out%02d.gif

then

gifsicle --delay=10 --loop *.gif > anim.gif

Quality is then quite good. You can find gifsicle here

Edit: Updated the post to reflect Alex Kahn's suggestions.