Screencast and convert to Gif

Rykka at 2014/08/21

本文地址:http://rykka.me/screen_cast2gif.html

Screencast and convert to gif, under linux(Ubuntu 14.04).

The latter solution is better in gif format only. but can not get other formats and can not modify.

e.g.: A Three Minutes ScreenCast in 2.6MB

Step by step solution

Screencapture: Kazam:

sudo add-apt-repository ppa:and471/kazam-daily-builds
sudo apt-get update
sudo apt-get install kazam

ffmpeg:

sudo add-apt-repository ppa:jon-severinsson/ffmpeg

gifsicle:

sudo apt-get install gifsicle

Using:

  1. Kazam capture and Save (with or without screenkey)

  2. Crop:

    ffmpeg -i rst_quick_start.mp4 -vf "crop=790:720:320:250"  rst_quick_crop.mp4
    
  3. ffmpeg convert to gif:

    # -t duration -r fps -s size -y (no ask overwrite)
    ffmpeg -y -i autotype.mp4 -t 48 -r 12 -pix_fmt rgb24 out.gif
    
  4. gifsicle resize gif:

    gifsicle --delay=5 --loop out.gif > anim.gif
    

All in one solution

This one is much better if only need gif format.

http://askubuntu.com/questions/107726/how-to-create-animated-gif-images-of-a-screencast

sudo add-apt-repository ppa:fossfreedom/byzanz
sudo apt-get update && sudo apt-get install byzanz

window: mhc.sh

region: region.sh

(need https://github.com/lolilolicon/xrectsel)

Additional Tools

Screen Key:

sudo apt-get install screenkey