Examples
Use as a library
Section titled “Use as a library”import { playVideo } from "ascii-stream";
await playVideo("video.mp4", { ramp: "detailed", fps: 15, fill: false,});How it works
Section titled “How it works”ffprobereads the source’s resolution, frame rate, and duration- the target ASCII resolution is fit to the terminal size, corrected for character cell aspect ratio
ffmpegdecodes and scales the video directly to that resolution, streaming raw RGB frames- each frame is converted to ASCII by brightness, with per-frame contrast stretching for clarity
- frames are written straight to the terminal at the source frame rate
Windows install notes
Section titled “Windows install notes”Some npm configurations block install scripts by default (allow-scripts), which prevents ffmpeg-static from downloading its bundled binary. If stream runs but errors on ffmpeg, allow scripts and reinstall:
npm config set allow-scripts=true --location=usernpm uninstall -g ascii-streamnpm install -g ascii-streamIf the stream command isn’t recognized after a global install, npm’s global bin folder likely isn’t on PATH. Check where it installs:
npm config get prefixAdd that folder to your PATH environment variable, then open a new terminal window.