Skip to main content

agg - asciinema gif generator

agg is a command-line tool for generating animated GIF files from asciicast v2 files produced by asciinema terminal recorder.

It uses Kornel Lesiński's excellent gifski library to produce optimized, high quality GIF output with accurate frame timing.

agg is a successor to asciicast2gif.

Demo

Building

Building from source requires Rust compiler (1.56.0 or later) and Cargo package manager. You can install both with rustup.

To download source code, build agg binary and install it in $HOME/.cargo/bin run:

cargo install --git https://github.com/asciinema/agg

You need to ensure $HOME/.cargo/bin is in your shell's $PATH.

Alternatively, you can manually download source code and build agg binary with:

git clone https://github.com/asciinema/agg
cd agg
cargo build --release

This produces an executable file in release mode (--release) at target/release/agg. There are no other build artifacts so you can copy the binary to a directory in your $PATH.

Building via Docker

Alternatively, if you have Docker, Podman or another Docker-compatible tool installed you can use it to build agg container image. This doesn't require Rust toolchain installed on your machine.

Build the image with the following command:

docker build -t agg .

Then run agg like this:

docker run --rm -it -u $(id -u):$(id -g) -v $PWD:/data agg demo.cast demo.gif

If you use Podman in root-less mode:

podman run --rm -it -v $PWD:/data agg demo.cast demo.gif

Usage

Basic usage:

agg demo.cast demo.gif

The above command renders a GIF file with default theme (dracula), font size 14px.

You can also provide an asciinema.org URL as the first argument:

agg https://asciinema.org/a/569727 starwars.gif

Additional options are available for customization. For example, the following command selects Monokai theme, larger font size, 2x playback speed:

agg --theme monokai --font-size 20 --speed 2 demo.cast demo.gif

Run agg -h to see all available options. Current options are:

    --cols <COLS>
        Override terminal width (number of columns)

    --font-dir <FONT_DIR>
        Use additional font directory

    --font-family <FONT_FAMILY>
        Specify font family [default: "JetBrains Mono,Fira Code,SF Mono,Menlo,Consolas,DejaVu
        Sans Mono,Liberation Mono"]

    --font-size <FONT_SIZE>
        Specify font size (in pixels) [default: 14]

    --fps-cap <FPS_CAP>
        Set FPS cap [default: 30]

-h, --help
        Print help information

    --idle-time-limit <IDLE_TIME_LIMIT>
        Limit idle time to max number of seconds [default: 5]

    --line-height <LINE_HEIGHT>
        Specify line height [default: 1.4]

    --no-loop
        Disable animation loop

    --renderer <RENDERER>
        Select frame rendering backend [default: fontdue] [possible values: fontdue, resvg]

    --rows <ROWS>
        Override terminal height (number of rows)

    --speed <SPEED>
        Adjust playback speed [default: 1]

    --theme <THEME>
        Select color theme [possible values: asciinema, dracula, monokai, solarized-dark,
        solarized-light, custom]

-v, --verbose
        Enable verbose logging

-V, --version
        Print version information

Fonts

By default agg uses common monospaced font for a given platform, that can be found on its default font family list. The list includes DejaVu Sans Mono and Liberation Mono (found on most Linux distros), SF Mono and Menlo (found on macOS), Consolas (found on Windows), with addition of my personal favourites like JetBrains Mono and Fira Code. The fonts are not included in agg and must be present on the system. To see the default value run agg --help and look for --font-family. In addition there's implicit fallback to DejaVu Sans (not Mono) which helps with rendering symbols like ⣽ or ✔ amongst others.

If you want to use another font family then pass a comma-separated list like this:

agg --font-family "Source Code Pro,Fira Code" demo.cast demo.gif

As long as the fonts you want to use are installed in one of standard system locations (e.g. /usr/share/fonts or ~/.local/share/fonts on Linux) agg will find them. You can also use --font-dir=/path/to/fonts option to include extra fonts. --font-dir can be specified multiple times.

To verify agg picks up your font run it with -v (verbose) flag:

agg -v --font-family "Source Code Pro,Fira Code" demo.cast demo.gif

It should print something similar to:

[INFO agg] selected font families: ["Source Code Pro", "Fira Code", "DejaVu Sans", "Noto Emoji"]

This list may also include implicit addition of DejaVu Sans fallback (mentioned earlier), as well as Noto Emoji (see section below).

Here's how to use Nerd Fonts with agg:

  1. Download one of the patched font sets from https://github.com/ryanoasis/nerd-fonts/releases/latest , e.g. JetBrainsMono.zip
  2. Unzip them into ~/.local/share/fonts (on Linux) or install with system font manager (macOS, Windows)
  3. Specify font family like this:
agg --font-family "JetBrainsMono Nerd Font Mono" demo.cast demo.gif

Emoji

Currently agg supports only monochrome emojis via Noto Emoji font.

Install Noto Emoji font on your system or, point agg to a folder containing NotoEmoji-*.ttf files with --font-dir.

Note that Noto Color Emoji font is not supported. Be aware that some distros ship this color font by name like "noto-fonts-emoji". This is not what you need.

Color themes

There are several built-in color themes you can use with --theme option:

  • asciinema
  • dracula (default)
  • monokai
  • solarized-dark
  • solarized-light

If your asciicast file includes theme definition then it's used automatically unless --theme option is explicitly specified.

A custom, ad-hoc theme can be used with --theme option by passing a series of comma-separated hex triplets defining terminal background color, default text color and a color palette:

--theme bbbbbb,ffffff,000000,111111,222222,333333,444444,555555,666666,777777

The above sets terminal background color to bbbbbb, default text color to ffffff, and uses remaining 8 colors as SGR color palette.

Additional bright color variants can be specified by adding 8 more hex triplets at the end. For example, the equivalent of the built-in Monokai theme is:

--theme 272822,f8f8f2,272822,f92672,a6e22e,f4bf75,66d9ef,ae81ff,a1efe4,f8f8f2,75715e,f92672,a6e22e,f4bf75,66d9ef,ae81ff,a1efe4,f9f8f5

Additional GIF optimization

GIF encoder used by agg, gifski, produces great looking GIF files, although this often comes at a cost - file size.

gifsicle can be used to shrink the produced GIF file:

gifsicle --lossy=80 -k 128 -O2 -Okeep-empty demo.gif -o demo-opt.gif

Every recording is different so you may need to tweak the lossiness level (--lossy), number of colors (-k) and other options to suit your needs.

Consulting

I offer consulting services for asciinema project. See https://asciinema.org/consulting for more information.

License

© 2022 Marcin Kulik.

All code is licensed under the Apache License, Version 2.0. See LICENSE file for details.

Metadata

Release files for asciinema-gif-generator 1.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asciinema-gif-generator 1.4.3
File Size Uploaded
asciinema_gif_generator-1.4.3.tar.gz 15.7 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for asciinema-gif-generator 1.4.3
File
asciinema_gif_generator-1.4.3-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
asciinema_gif_generator-1.4.3-py3-none-win32.whl Python 3 none Windows x86-32 Details
asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details
asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_i686.whl Python 3 none Linux musl 1.2+ x86-32 Details
asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_armv7l.whl Python 3 none Linux musl 1.2+ ARMv7l Details
asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl Python 3 none Linux glibc 2.17+ x86-32 Details
asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl Python 3 none Linux glibc 2.17+ ARMv7l Details
asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
asciinema_gif_generator-1.4.3-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
asciinema_gif_generator-1.4.3-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details

Total release size: 65.1 MB

Release files / asciinema_gif_generator-1.4.3.tar.gz

Download URL asciinema_gif_generator-1.4.3.tar.gz
Size 15.7 MB
Tags Source
SHA-256 checksum
How to use checksums
facace2adae895ffb8ed0abe97f8a3542a8ea7d15d5e1f39339520355e50219f
BLAKE2b-256 checksum
How to use checksums
f80c1b5afe84317a6ebbb803d2101ab48a8a6a6b35d9767ce361f1eefb7ef218
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-win_amd64.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-win_amd64.whl
Size 3.6 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
9c1fb8b785f77f09b73e4ea9b2cbe319597bb380d2851f25f8e7639a39392b74
BLAKE2b-256 checksum
How to use checksums
6e911d75e9cac79c8e3a7158f18168f07b1efd6e27bb2d8a1b2fa5e8fa6bee16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-win32.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-win32.whl
Size 3.4 MB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
5a7bebcb756c6eb8d88a1f3a0a72bd0828e689797da6175630d34702c84371bb
BLAKE2b-256 checksum
How to use checksums
1a4d91ed68b00bc340acd61119be88d337b9bd9da1e25941234deedea54c6542
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_x86_64.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_x86_64.whl
Size 4.4 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
0929aad9dbf8da4281dd96df75e9bfcc4d4d12f8492d9f5c416dfa6ec3663cce
BLAKE2b-256 checksum
How to use checksums
0f3fd2358a4c02cd2c6a6c536f128beaaeb84815937cefd41f8a5f45178f902c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_i686.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_i686.whl
Size 4.4 MB
Tags Linux musl 1.2+ x86-32 Python 3
SHA-256 checksum
How to use checksums
c400e9e7ffb6516c1d8d5e5f2eba747b10ddbdf1a8dc081edacc1c73821bc88e
BLAKE2b-256 checksum
How to use checksums
180da22607bde05ec3b1adbad6e9966287b97e84238c0164d93fb11a3be6a697
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_armv7l.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_armv7l.whl
Size 4.2 MB
Tags Linux musl 1.2+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
f83c377048f5ce27da18ed3389c381a0ad316c5e8ec2ab336ae84348e5561fce
BLAKE2b-256 checksum
How to use checksums
80d5110522ec2afeaf4ed2d0d942955c85a43cc368e82f33cb8882b4df09d1af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_aarch64.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_aarch64.whl
Size 4.3 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
848d51c64f9d8cbfc63f9ce82080bca748f00fd906b16018f883207bb7a5f975
BLAKE2b-256 checksum
How to use checksums
9eaa559e472d082d8bb4285a63bffa9aeebffdf699de27f291507aca40681435
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
d020df56d7b1ccf4daab176953857899f63435ef218b0ecd095d81aa7f402b16
BLAKE2b-256 checksum
How to use checksums
2da33e9698c2575969dd8fb8ca199d143ff33d879567373459be518c7d9f7cbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Size 4.6 MB
Tags Linux glibc 2.17+ x86-32 Python 3
SHA-256 checksum
How to use checksums
30ba7219bc406c409266aa2b0a9ed4b94aeab15eda46ec4d49f295c48caa74e2
BLAKE2b-256 checksum
How to use checksums
b9953084a45e13c00f7fb1b947cd7eaaa5a7c0704c7587c153f7c2730db40c72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 4.1 MB
Tags Linux glibc 2.17+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
356d2c91a101b10b7865c9e64017fbf7a8b37cac8ed5b9d2d413cdebaf4f9b2f
BLAKE2b-256 checksum
How to use checksums
e7bbaacce0f75a57a8fad9060227ddb4ea5b12bf2a9867ae8daa609ad0380ac5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 4.3 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
749e2d5af4f2cc34b535403d57b97d27ae0883cbac13d5c2967a45a6a771719b
BLAKE2b-256 checksum
How to use checksums
478d533a804c4a7aec238841c823bfe9db74b9ab54313ac377e32ed65fcc9477
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-macosx_11_0_arm64.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-macosx_11_0_arm64.whl
Size 3.8 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
750269db7955e23dbd62a4aa187e53560d65038cb17887402417818fa1e3c2c5
BLAKE2b-256 checksum
How to use checksums
ffa5fa65d48c860430ed33d2a8c347e7ff6b0bccdc95b2cc1f9f99d3ae5939db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / asciinema_gif_generator-1.4.3-py3-none-macosx_10_12_x86_64.whl

Download URL asciinema_gif_generator-1.4.3-py3-none-macosx_10_12_x86_64.whl
Size 4.0 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
c2bf2c634de490e6b8a158b928f26c010ebaffb636688d57f73d553a19ccd6ad
BLAKE2b-256 checksum
How to use checksums
cd775f73a8e9bc6fc4307522ec896685c88a67c8f2bb3bb018b7fb0e9d9b9915
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release history Release notifications | RSS feed

This release

1.4.3 This release

13 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page