Skip to main content

Convert asciinema .cast files to GIF and MP4, with a generic demo-recording engine

Project description

PyPI version Python Development Status Maintenance PyPI License


๐ŸŽฌ cast-studio

Convert asciinema .cast recordings into GIF and MP4 โ€” and scaffold a generic demo-recording engine for any Python project.


๐Ÿ“ฆ Installation

uv add cast-studio

System requirement: ffmpeg must be installed.

brew install ffmpeg        # macOS
apt-get install ffmpeg     # Ubuntu / Debian

๐Ÿš€ Features

  • โœ… cast โ†’ GIF โ€” High-quality 256-colour GIF via ffmpeg palette pass
  • โœ… cast โ†’ MP4 โ€” H.264/x264 CRF-18 MP4 ready for GitHub Releases
  • โœ… Catppuccin Mocha theme โ€” Beautiful dark terminal rendering with Pillow
  • โœ… Generic demo engine โ€” cast-run + demo.cfg for any project
  • โœ… Any shell command โ€” Record pytest runs, scripts, CLIs โ€” not just pytest
  • โœ… Multi-line descriptions โ€” Pipe-separated description lines per run
  • โœ… python-base-command CLI โ€” Structured, loggable CLI with cast / cast-render / cast-init

โš™๏ธ Configuration

No .env needed. All config lives in demo.cfg:

PROJECT="my-library"
SUBTITLE="A short description"
INSTALL_CMD="pip install my-library"
REPO_URL="github.com/you/my-library"
PYPI_URL="pypi.org/project/my-library"

PYTEST=".venv/bin/pytest"
TESTS="tests/"

PAUSE_INTRO=2       # seconds after intro screen
PAUSE_BETWEEN=2     # seconds between runs
PAUSE_OUTRO=3       # seconds on outro screen

define_runs() {
  add_run "RUN 1 โ€” feature A" "Short description." "$PYTEST $TESTS --flag"
  add_run "RUN 2 โ€” script"   "Another feature."    "python scripts/my_script.py"
}

add_run "Title" "Line 1|Line 2" "any shell command" โ€” use | for multi-line descriptions.


๐Ÿ› ๏ธ How to Use

  1. Install โ€” uv add cast-studio (and brew install ffmpeg asciinema)
  2. Create .cfg โ€” customise demo.cfg with your project's runs
  3. Record โ€” asciinema rec -c "cast-run demo/demo.cfg" demo.cast
  4. Render โ€” cast-render demo.cast assets/demo --gif-only --title "my demo" โ†’ assets/demo.gif
  5. Embed โ€” add ![demo](assets/demo.gif) to your README

๐Ÿš€ Quick Start

# 1. Install
uv add cast-studio
brew install ffmpeg asciinema   # macOS

# 2. Create demo/demo.cfg โ€” set PROJECT, SUBTITLE, INSTALL_CMD, define_runs()

demo/demo.cfg structure:

# โ”€โ”€ project metadata โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
PROJECT="cast-studio"
SUBTITLE="Convert asciinema .cast files to GIF and MP4"
INSTALL_CMD="uv add cast-studio"
REPO_URL="github.com/aviz92/cast-studio"
PYPI_URL="pypi.org/project/cast-studio"

# โ”€โ”€ timing (seconds) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
PAUSE_INTRO=2
PAUSE_BETWEEN=2
PAUSE_OUTRO=3

# โ”€โ”€ runs โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
define_runs() {
  add_run \
    "STEP 1 โ€” cast-init  โ”‚  scaffold demo scripts into your project" \
    "Creates run_demo.sh (the engine) and demo.cfg (your project config).|One command sets up the full demo recording workflow." \
    "cast-init --dest /tmp/cast-studio-demo --force"

  add_run \
    "STEP 2 โ€” demo.cfg  โ”‚  inspect the generated config" \
    "Edit PROJECT, SUBTITLE, INSTALL_CMD, and define_runs().|Add any shell command โ€” pytest, scripts, CLIs โ€” using add_run." \
    "cat /tmp/cast-studio-demo/demo.cfg"

  add_run \
    "STEP 3 โ€” cast-render  โ”‚  render a .cast file to GIF" \
    "Renders each frame as a PNG using Pillow (Catppuccin Mocha theme).|Then encodes a high-quality 256-colour GIF via ffmpeg palette pass." \
    "cast-render demo.cast assets/demo --gif-only --title \"cast-studio demo\""

  add_run \
    "STEP 4 โ€” cast-render  โ”‚  render to MP4" \
    "H.264/x264 CRF-18 encode โ€” ready for GitHub Releases or Twitter.|Use --hold to extend the last frame so viewers can read the outro." \
    "cast-render demo.cast assets/demo --mp4-only --hold 5.0 --title \"cast-studio demo\""

  add_run \
    "STEP 5 โ€” cast  โ”‚  unified runner" \
    "The cast command auto-discovers all sub-commands.|cast render / cast init / cast --help โ€” one entry point for everything." \
    "cast --help"
}
# 3. Record
asciinema rec -c "bash cast-run demo/demo.cfg" assets/demo/demo.cast

# 4. Render to GIF and MP4
cast-render assets/demo/demo.cast assets/demo/demo --gif-only --title "my-library demo"  # -> `assets/demo/demo.gif`
cast-render assets/demo/demo.cast assets/demo/demo --mp4-only --title "my-library demo"  # -> `assets/demo/demo.mp4`

# 5. Embed in README
# ![demo](assets/demo.gif)

๐ŸŽฅ Demo

demo


CLI Reference

cast-render

Flag Default Description
cast_file โ€” Path to .cast file
output_base โ€” Output path without extension
--title "" Title bar text
--gif-only โ€” Produce GIF only
--mp4-only โ€” Produce MP4 only
--render-fps 30 Internal PNG frame rate
--gif-fps 10 GIF output FPS
--mp4-fps 30 MP4 output FPS
--hold 3.0 Seconds to hold last frame
--keep-frames โ€” Keep temporary PNG frames

๐Ÿค Contributing

If you have a helpful pattern or improvement to suggest: Fork the repo Create a new branch Submit a pull request I welcome additions that promote clean, productive, and maintainable development.


๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


๐Ÿ™ Thanks

Thanks for exploring this repository!
Happy coding!

GitHub ย  PyPI ย  Blog ย  LinkedIn

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cast_studio-0.1.3.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cast_studio-0.1.3-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file cast_studio-0.1.3.tar.gz.

File metadata

  • Download URL: cast_studio-0.1.3.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cast_studio-0.1.3.tar.gz
Algorithm Hash digest
SHA256 06988a0a2565091964d8707d8a871e1bc141c7dff159956d04a799577e4a283d
MD5 aa7e3f0be4a4bb2a4d2ab0dbcf258e65
BLAKE2b-256 ef78a45cb6f53716b42b3dfe7ffba4319146d190456e8bd2c2d416af962781ff

See more details on using hashes here.

File details

Details for the file cast_studio-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: cast_studio-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cast_studio-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4846833e390eb5031d95d4c77e76dd8b5b13369a6f7958280341e1dd13fef8b2
MD5 c63b605948aecf2113cf225eeb2cbb2d
BLAKE2b-256 5cf6e0960e1d38766e406a600fe49df05348d015c041dc93771ab33a654cc2bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page