Bash script: screencast GIF (via temp .avi) - lmmx/devnotes GitHub Wiki

Using ffcast with xrectsel

mkdir /home/louis/opt/FFcast
chmod 777 /home/louis/opt/FFcast
cd FFcast && ./bootstrap && ./configure --enable-xrectsel --prefix /usr --libexecdir /usr/lib --sysconfdir /etc && make && make DESTDIR="/home/louis/opt/FFcast" install
chmod 755 /home/louis/opt/FFcast

If unable to located package autoreconf install dh-autoreconf

sudo apt-get install dh-autoreconf

via

./bootstrap && ./configure --enable-xrectsel --prefix /usr --libexecdir /usr/lib --sysconfdir /etc && make && make DESTDIR="/home/louis/opt/FFcast" install
  • Installing ffcast with xrectsel seems to require installation of xrectsel and adding on PATH first, but then oddly manages to delete xrectsel upon installation. Delete xrectsel from your PATH statement in .bashrc (it will be in {ffcast_DESTDIR}/usr/bin/ alongside ffcast
export PATH=$PATH:/home/louis/opt/FFcast/usr/bin
  • Delete git source directories
  • Now that ffcast is a command, it can be used in a bash script to make a screencast (GIF via temporary avi video file), and this script can also be put onto the PATH for ease of use via.
  • Create a file in /usr/local/bin/ named e.g. gifcast (and chmod 755 it) :
#!/bin/bash
TMP_AVI=$(mktemp /tmp/outXXXXXXXXXX.avi)
ffcast -s % ffmpeg -y -f x11grab -show_region 1 -framerate 15 \
    -video_size %s -i %D+%c -codec:v huffyuv                  \
    -vf crop="iw-mod(iw\\,2):ih-mod(ih\\,2)" $TMP_AVI         \
&& convert -set delay 10 -layers Optimize $TMP_AVI out.gif

gifcast is now a command to create out.gif from the screen in whichever directory you're running in :smiley:

  • Note: if the script errors out with error: external command '%' not found, try removing the % in the script after -s (see man pages)

Related: Gif terminal manipulation/optimisation