Skip to content

Latest commit

 

History

History
82 lines (55 loc) · 2.59 KB

terminal-recording.adoc

File metadata and controls

82 lines (55 loc) · 2.59 KB

Recording the Terminal

Recording

Setup a tmux Session Optimized for Recording

# Create new tmux session for recording
$ tmux new-session -s recording-studio

# Run the resize-window command to set tmux window to good size for recording
:resize-window -y 24 -x 80

# Set the prompt to something very simple
# For Bash, I like:
$ PS1='\\$ '

# For Zsh, I like:
$ PROMPT='$ '

Generate the Recording

We can record a terminal session directory with Asciinema. However, as detailed here it can be helpful to discard timing information if your typing is inconsistent or you need to pause and look something up during recording. scriptreplay_ng is the only tool I’ve found that allows you to discard timing information. This makes each keystroke appear at a consistent interval and makes for a more polished presentation.

Steps:

  1. Install scriptreplay_ng if you haven’t already install script

  2. Record the session:

$ record-script-session <session name>

# Do what you want to record
$ ...
# Ctrl-D to exit

Convert the Recording to Asciinema format

Inside the tmux session configured for terminal record, begin the recording:

asciinema rec --command "scriptreplay-ng recording.txt"

Converting to an Animated GIF

Sometimes it’s necessary to convert the terminal record into a format that can be viewed anywhere.

The asciinema agg tool converts asciinema recordings into animated GIFs. The generated GIF file can then be converted to another format like MP4.

Steps:

  1. Install asciinema/agg.

  2. Run agg <ASCIINEMA FILE> <OUTPUT GIF FILE> with any options you want.

I’ve found the following options to be good:

agg --font-size 21 --rows 20 --theme asciinema --speed 1.3

Converting the GIF to an MP4 Video

Steps:

  1. Install ffmpeg if you don’t already have it installed.

  2. Run ffmpeg -i <GIF FILE> -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" <OUTPUT MP4 FILE>