Terminal video player
Terminal video player — plays mp4, gif, avi, webm on the fly, rendering each frame as ASCII, ANSI 256-color, truecolor half-blocks, or via modern graphics protocols (sixel / kitty / iTerm2). PHP port of tplay, glyph, and video-to-ascii.
composer require sugarcraft/sugar-reel
php examples/play.php video.mp4 # play a video
php examples/play.php # synthetic test pattern (no file needed)
# Programmatic:
use SugarCraft\Reel\Player;
$player = Player::open('clip.mp4', cols: 80, rows: 24);
(new \SugarCraft\Core\Program($player))->run();
| Mode | Description | Terminal requirement |
|---|---|---|
| ascii | Grayscale luminance ramp | Any |
| ansi256 | 256-color cube + grey ramp | 256-color |
| truecolor | 24-bit RGB truecolor | 24-bit color |
| halfblock | 24-bit ▀ half-blocks, 2x vertical resolution | 24-bit color |
| sixel | Sixel raster graphics protocol (DEC) | Sixel-capable |
| kitty | Kitty graphics protocol (DCS APC) | Kitty-compatible |
| iterm2 | iTerm2 inline image (OSC 1337) | iTerm2 / WezTerm |
| Key | Action |
|---|---|
| Space | Pause / resume |
| ← | Seek backward 10 frames |
| → | Seek forward 10 frames |
| [ | Decrease playback speed (-0.25x, min 0.25x) |
| ] | Increase playback speed (+0.25x, max 4.0x) |
| 0-9 | Seek to 0-90% of video duration |
| m | Cycle to next rendering mode |
| q / Esc | Quit |
| resize | Terminal resize (SIGWINCH) re-scales video automatically |
| Class | Method | Description |
|---|---|---|
| Reel | ::open(path) | Open a video file |
| Reel | ::new() | Create unbound player (synthetic test pattern) |
| Reel | withMode(Mode) | Set rendering mode |
| Reel | withSize(cols, rows) | Set terminal cell dimensions |
| Reel | withFps(?float) | FPS override (null = auto-detect) |
| Reel | withLoop(bool) | Enable/disable loop |
| Reel | play() | Run the player |
| Player | ::open(path, cols, rows, fps, mode, loop) | Open a video source |
| Player | ::openForTest(decoder, cols, rows, fps, mode, loop) | Open with injected decoder for testing |
| LumaRamp | ::char(luma, ramp) | Map 0-255 luminance to character |
| LumaRamp | ::compute(r, g, b) | Compute BT.601 luma from RGB |
VHS-recorded GIFs of every example shipped with the app. Regenerated automatically on every push that touches the source.