Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Using asciinema

asciinema rec
# commands here
exit
asciicast2gif <input path> <output_path>.gif

Console Gif with ttyrec

ttyrec
# Record stuff
$HOME/go/bin/ttygif -in ttyrc --out <name>.gif

Console Gif to MP4

ttyrec
# Record stuff
$HOME/go/bin/ttygif -in ttyrc --out <name>.gif
ffmpeg -i <name> -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" <name>.mp4

Install asciinema2gif

https://github.com/asciinema/asciicast2gif

brew install npm
brew install imagemagick
npm install imagemin-gifsicle
npm install asciinema2gif

Cast file sizes.

du -h /var/folders/r5/8lyv5xyd0t7_tbg01_g83m8j0n2gvc/T/*.cast
4.0K    /var/folders/r5/8lyv5xyd0t7_tbg01_g83m8j0n2gvc/T/tmp0l25xv9a-ascii.cast
4.0K    /var/folders/r5/8lyv5xyd0t7_tbg01_g83m8j0n2gvc/T/tmp378tyj9i-ascii.cast
8.0K    /var/folders/r5/8lyv5xyd0t7_tbg01_g83m8j0n2gvc/T/tmp8d5igiov-ascii.cast
4.0K    /var/folders/r5/8lyv5xyd0t7_tbg01_g83m8j0n2gvc/T/tmp_f8ns354-ascii.cast
4.0K    /var/folders/r5/8lyv5xyd0t7_tbg01_g83m8j0n2gvc/T/tmpnq68bsgm-ascii.cast
4.0K    /var/folders/r5/8lyv5xyd0t7_tbg01_g83m8j0n2gvc/T/tmpqdmefkgf-ascii.cast
4.0K    /var/folders/r5/8lyv5xyd0t7_tbg01_g83m8j0n2gvc/T/tmpt_eo2wkc-ascii.cast

Gif File Size

asciicast2gif /var/folders/r5/8lyv5xyd0t7_tbg01_g83m8j0n2gvc/T/tmp0l25xv9a-ascii.cast test.gif
==> Loading /var/folders/r5/8lyv5xyd0t7_tbg01_g83m8j0n2gvc/T/tmp0l25xv9a-ascii.cast...
==> Spawning PhantomJS renderer...
==> Generating frame screenshots...
==> Combining 13 screenshots into GIF file...
==> Done.
du -h test.gif
40K    test.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment