asciinema2video
v1.0.2
Published
Convert asciinema .cast files to video (MP4)
Downloads
89
Maintainers
Readme
asciinema2video
Convert asciinema .cast files to video (MP4) using Node.js and Puppeteer.
Features
- 🎥 Convert
.castfiles to high-quality MP4 videos - 🎨 Support for asciinema player themes
- ⚡ Adjustable playback speed
- 📐 Customizable video dimensions
- 🎬 60 FPS output for smooth playback
Installation
You can run it directly using npx:
npx asciinema2video input.cast -o output.mp4Or install globally via npm:
npm install -g asciinema2videoUsage
Basic Usage
npm run dev -- input.cast -o output.mp4Or after building:
node dist/cli.js input.cast -o output.mp4Or if installed globally:
asciinema2video input.cast -o output.mp4Options
$ asciinema2video --help
Usage: asciinema2video [options] <input>
Convert asciinema cast file to video
Arguments:
input Path to .cast file
Options:
-o, --output <path> Output video path (default: "output.mp4")
--width <number> Width of the video (default: "800")
--height <number> Height of the video (default: "600")
--theme <string> Asciinema theme (choices: "asciinema", "dracula", "gruvbox-dark", "monokai", "solarized-dark",
"solarized-light", "tango", "nord", default: "asciinema")
--speed <number> Playback speed (default: "1")
--scale <number> Player scale (default: "2")
-h, --help display help for command
Examples:
$ asciinema2video demo.cast -o demo.mp4
$ asciinema2video demo.cast --width 1920 --height 1080 --theme draculaThemes
Available themes include:
asciinema(default)draculamonokaisolarized-darksolarized-lighttangonord
For a full list of supported themes, please refer to the asciinema-player documentation.
Examples
# Basic conversion
asciinema2video demo.cast -o demo.mp4
# Custom dimensions
asciinema2video demo.cast -o demo.mp4 --width 1920 --height 1080
# Faster playback
asciinema2video demo.cast -o demo.mp4 --speed 2
# Different theme
asciinema2video demo.cast -o demo.mp4 --theme monokaiHow It Works
- Loads the asciinema player in a headless browser (Puppeteer)
- Renders the
.castfile using the asciinema-player library - Records the browser screen while the terminal recording plays
- Outputs the recording as an MP4 video using FFmpeg
Requirements
- Node.js 20+
- FFmpeg (bundled via
ffmpeg-static) - Graphical Environment: Since this tool uses Puppeteer (Chrome) to record
he screen, it requires a graphical environment.
- On Linux servers (headless), you may need to use
Xvfb(X virtual framebuffer).xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" asciinema2video input.cast
- On Linux servers (headless), you may need to use
Dependencies
- puppeteer: Headless browser automation
- asciinema-player: Official asciinema player
- puppeteer-screen-recorder: Screen recording for Puppeteer
- ffmpeg-static: Bundled FFmpeg binary
- commander: CLI argument parsing
Creating a Sample Cast File
You can create a .cast file using the asciinema CLI:
# Install asciinema
brew install asciinema # macOS
# or
apt-get install asciinema # Linux
# Record a session
asciinema rec demo.cast
# Convert to video
asciinema2video demo.cast -o demo.mp4License
MIT
