sudo apt-get install ffmpeg imagemagick
ffmpeg -t <duration> -ss <starting position in hh:mm:ss format> -i <input_video> out%04d.gif
ffmpeg -ss 00:00:02 -t 14 -i 02.mp4 02.gif
References
http://askubuntu.com/questions/648603/create-animated-gif-from-mp4-video-via-command-line
http://xmodulo.com/convert-video-animated-gif-image-linux.html