Capture CLI Output as Animated GIF

5

2

Some questions and answers on codegolf have helpful animated GIFs which display the output of a command line program.

Some GIFs look great, like this one from the Make me a fake loader question:

great gif

Others look corrupt and choppy, like this one from this answer:

corrupt gif

What are some methods for making great GIFs of command line program output?

(Assume Windows 7 is the platform, although macOS/BSD/Linux answers would be appreciated.)

Hydraxan14

Posted 2016-12-19T18:20:06.550

Reputation: 578

Answers

2

LICEcap

A helpful fellow on the codegolf meta told me about LICEcap. This is the kind of program I was looking for!

LICEcap can capture an area of your desktop and save it directly to .GIF (for viewing in web browsers, etc) or .LCF (see below).

LICEcap is an intuitive but flexible application (for Windows and now OSX), that is designed to be lightweight and function with high performance.

Hydraxan14

Posted 2016-12-19T18:20:06.550

Reputation: 578

5

You can recording your terminal with asciinema and then pass it through a2gif.

sickill

Posted 2016-12-19T18:20:06.550

Reputation: 406

2

There are multiple methods to go about this. My approach usually would involve using a screen capture software, editing and than convert, This may be rather time consuming and quite cumbersome if you are trying to make a quick GIF of the CLI.

However, for Windows you can use Gifify. It's a great open source utility from GITHUB. Which you can find here.

gifify is a shell script for converting screen recordings into GIFs that can be embedded conveniently into places like Slack channels or GitHub issues and pull requests.

For Linux or Ubuntu rather you can use something a bit similar or at least easier to install and run like ImageMagick.

sudo apt-get install imagemagick

Now you can create a gif from number of pictures(jpg) using:

convert -delay 20 -loop 0 *.jpg myimage.gif

More information.

MAC

For MAC you can also utlizie Github using QuickTime, ffmpeg, and gifsicle. The process is somewhat similar to the steps you could take on Linux as well.

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

Open "Quicktime Player", Go to File -> New Screen Recording Selected screen portion by dragging a rectangle, recorded 13 second video. Go to File -> Export -> As Movie Saved the video in full quality with the filename in.mov To convert in.mov into out.gif (filesize: 48KB), open Terminal to the folder with in.mov and run the following command:

ffmpeg -i in.mov -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif

Github link

ttgif is also another notable option for MAC as well. This more so on the side of converting terminal recordings to animated gifs

https://github.com/icholy/ttygif

Anthony D.

Posted 2016-12-19T18:20:06.550

Reputation: 104

1I was hoping there'd be a more user-friendly way to do this in Windows than ffmpeg or imagemagick. Also, wouldn't Gifify be more suitable for Linux than Windows, since it is a bash shell script front-end for ffmpeg? – Hydraxan14 – 2016-12-19T19:48:04.070

1

You could attempt to try Gifsicle. There is a Windows port that is available, although I have not given it a try. https://www.lcdf.org/gifsicle/

– Anthony D. – 2016-12-19T19:51:27.943