FFmpeg provides simple usage to convert video such as .mkv, .mp3, .mp4, .mov to .gif.
ffmpeg -i <input.video> out.gif
Well, the file size of out.gif is sometimes a bit too big. In such a case, it's better to use
-r option to specify frame rate.
ffmpeg -i my-sample.mkv -r 10 out.gif
-r 10, my sample video file got 20% smaller. With
-r 5 or less, it would be much smaller.
The official documentation on video options is here.