ffcast -s ffmpeg -r 20 -vcodec huffyuv out.avi
convert -layers Optimize -set delay 10 out.avi out.gif
ffcast, did some
I ran the recording commands in another terminal. More polished script for your
$PATH at the end of this answer.
FFcast helps the user interactively select a screen region and hands over the geometry to an external command, such as FFmpeg, for screen recording.
ffcast is the glorious product of some hacking at the Arch Linux community (mainly lolilolicon). You can find it on github (or in the AUR for Archers). Its dependency list is just
Internally, it works by invoking
libx11 (the same standard function
scrot uses) and letting the user select a screen region. It then substitutes the correct dimensions for
%d in the given command. There's a preset for
ffmpeg, which automatically inserts the correct selection area flags for it to record video.
You can also append
ffmpeg flags right after the command. I set
-r 15 to capture at 15 frames per second and
-vcodec huffyuv for lossless recording. (Play with these if you want a different size/quality tradeoff.)
ImageMagick can read
.avi videos and has some GIF optimisation tricks that drastically reduce file size while preserving quality: The
-layers Optimize to
convert invokes the general-purpose optimiser. The ImageMagick manual has a page on advanced optimisations too.
This is what I have in my
$PATH to initially record into a temporary file.
ffcast -s ffmpeg -y -r 20 -vcodec huffyuv $TMP_AVI \
&& convert -set delay 10 -layers Optimize $TMP_AVI out.gif