Rust ASCII Terminal Video Engine
A multithreaded Rust CLI engine that intercepts media streams, executes hardware-accelerated frame extraction via FFmpeg, and renders real-time ASCII-mapped video synchronized with an isolated audio thread directly within the terminal.
Tech stack
- Languages
Performance & metrics
- Zero-GUI overhead; rendering throughput is strictly CPU-bound, relying entirely on terminal
stdoutflushing speeds rather than GPU acceleration - Effectively mitigates audio drift by continuously recalculating elapsed epoch deltas (
duration_since(start)) rather than relying on naive fixed-interval thread blocks
Why I built it
Standard GUI media players introduce massive rendering overhead for basic media consumption. I engineered this utility to explore terminal-based rendering and concurrent Audio/Video (A/V) synchronization at a low level. It automates the pipeline from network ingestion to frame extraction, applying a custom luminance matrix to map raw pixels to ASCII characters, entirely bypassing traditional OS graphics pipelines.
Architecture & decisions
The orchestrator utilizes system hooks to drive yt-dlp and ffmpeg sub-processes for network acquisition and discrete I/O extraction. To ensure precise A/V synchronization, the architecture branches execution into distinct OS threads: an isolated audio sink via rodio and a primary video rendering loop. The render loop calculates sub-millisecond deltas against a fixed frame rate (30 FPS) using std::time::Instant. It applies the Rec. 601 luma formula (0.299R + 0.587G + 0.114B) to map spatial pixel intensity to a predefined ASCII density array, pushing the resulting buffer directly to stdout utilizing crossterm ANSI escape sequences.
Key features
- 01Automated OS-level media ingestion and decoding pipeline leveraging discrete
yt-dlpandffmpegsub-processes - 02Mathematical pixel-to-ASCII density mapping utilizing the Rec. 601 relative luminance standard
- 03Multithreaded A/V synchronization engine enforcing strict frame-time deltas via dynamic thread sleeping
- 04Hardware-agnostic terminal rendering executing frame-buffer clears and draws entirely within the CLI environment