One of the best tools I use is ffmpeg. It can take most video from a screencast tool such as kazam and convert it to another format.
Install this from software-center - it is automatically installed if you install the excellent ubuntu-restricted-extras package.
Kazam can output in the video formats mp4 or webm. Generally you get better results outputting in mp4 format.
Example GIF making syntax
The basic syntax to convert video to gif is:
ffmpeg -i [inputvideo_filename] -pix_fmt rgb24 [output.gif]
GIFs converted - especially those with a standard 25/29 frame-per-second can be very large. For example - a 800Kb webm 15-second video at 25fps can output to 435 MB!
You can reduce this by a number of methods:
Framerate
Use the option -r [frame-per-second]. For example
ffmpeg -i Untitled_Screencast.webm -r 1 -pix_fmt rgb24 out.gif
Size reduced from 435 MB to 19 MB
File-size limit
Use the option -fs [filesize]. For example
ffmpeg -i Untitled_Screencast.webm -fs 5000k -pix_fmt rgb24 out.gif
Note: This is an approximate output file size so the size can be slightly bigger than specified.
Size of output video
Use the option -s [widthxheight]. For example
ffmpeg -i Untitled_Screencast.webm -s 320x200 -pix_fmt rgb24 out.gif
This reduced the example 1366x768 video size down to 26 MB
Loop forever
Sometimes you might want the GIF to loop forever.
Use the option -loop_output 0. For example
ffmpeg -i Untitled_Screencast.webm -loop_output 0 -pix_fmt rgb24 out.gif
Further optimise and shrink
If you use imagemagick convert with a fuzz factor between 3% and 10% then you can dramatically reduce the image size
convert output.gif -fuzz 3% -layers Optimize finalgif.gif
Finally
Combine some of these options to reduce to something manageable for Ask Ubuntu.
ffmpeg -i Untitled_Screencast.webm -loop_output 0 -r 5 -s 320x200 -pix_fmt rgb24 out.gif
Followed by
convert output.gif -fuzz 8% -layers Optimize finalgif.gif
Example
