-
Notifications
You must be signed in to change notification settings - Fork 17
GIF Howto
There are several ways to make a relatively high quality GIF screencast.
Why not ffcast rec a.gif
? Because unfortunately FFmpeg produces very low
quality GIF encodes by default.
The best quality is achieved by recording to a series of PNG images, and post-process them using ImageMagick / GraphicsMagic.
First, use the rec
sub-command to record to PNGs, e.g.:
mkdir -p /tmp/0; cd /tmp/0
ffcast -w rec -r 20 %04d.png
Take note, here we record at 20 fps, therefore, to match the speed, the GIF frame delay must be 50 ms.
Next, convert the PNG images to GIF:
convert -loop 0 -delay 5 *.png -layers Optimize a.gif
Note convert
can have a lot of resource impact. Consider using -limit
.
If you don't care too much about perfect quality, or if you've already recorded to a video, try this method.
First, use the rec
sub-command to record a video, e.g.:
ffcast -w rec /tmp/a.mp4
Next, convert the video to a high quality GIF with FFmpeg:
ffmpeg -i a.mp4 -vf palettegen -f image2 -c:v png - |
ffmpeg -i a.mp4 -i - -filter_complex paletteuse a.gif
Or more conveniently, use v2gif.sh.
Now we have the GIF, but what if you want to shave off some frames at the
beginning or end, or to insert some other frames, or to slow down some
frames, etc? The answer is to use convert
or gifsicle
. Go RTFM :)