Play a video in your terminal, with sound. Rust, decoding through ffmpeg.
tplay samples/demo.mp4 --dotsNeeds ffmpeg on PATH:
brew install ffmpeg # macOS
sudo apt install ffmpeg # Debian/UbuntuThen:
cargo install --path .tplay clip.mp4 # half-block colour, letterboxed
tplay clip.mp4 --dots # dithered dots, full screen
tplay clip.mp4 --mode ascii --mono # plain characters
tplay https://example.com/clip.mp4 # anything ffmpeg can openEverything is adjustable while it plays, so you rarely need a flag:
| key | does |
|---|---|
space |
pause / resume |
← → |
seek 5 seconds |
↑ ↓ |
volume |
m |
picture mode: half / braille / ascii |
f |
fill the screen or letterbox |
d |
dot pattern: atkinson / floyd / bayer |
[ ] |
sharpen — the main legibility control |
- + |
gamma, for dark footage |
, . |
black point, kills shadow speckle |
a |
auto levels on / off |
0 |
reset the look |
? |
key list |
q |
quit |
--help lists every flag.
half packs two pixels into each cell with ▀ — foreground for the top
pixel, background for the bottom. Full 24-bit colour, the most faithful.
braille packs 2x4 dithered dots into each cell: eight times the sample resolution of half-block, in a one-bit-per-dot look. Brightness is carried by how many dots are lit, so each cell's colour is scaled back up to full brightness and density alone does the shading.
ascii is a plain luminance ramp in colour, for terminals that can't manage the other two.
Usually nothing, because the levels tune themselves: each frame's histogram
sets the black and white points from its 2nd and 99th percentiles, and a gamma
is chosen to lift the median — eased frame to frame so a flicker can't pump the
picture. A frame with less than 0.12 of dynamic range is left alone, so a blank
dark shot stays dark instead of being stretched into noise. Press a to turn
that off, or set --black, --white or --gamma, which turns it off for you.
After that, in order of effect:
--sharpen(default 0.8) unsharp-masks the luminance before dithering. Without it, fine detail is indistinguishable once crushed to one bit.--ditherpicks the kernel.atkinsonpasses on only 6/8 of the error, so blacks stay black and edges stay hard.bayerthresholds against a fixed 8x8 grid, so a still area dithers identically every frame and nothing shimmers — about 3x less redraw churn than Floyd–Steinberg on a static shot.floydhas the smoothest gradients and the most shimmer.--blacksets the input black point. Coded "black" in a video sits near 16/255, and without a floor the dither sprays dots through every shadow.
ffprobe reports size, frame rate and duration. One ffmpeg process scales
straight to the cell grid and pipes raw rgb24 frames into a bounded 8-frame
channel, so decoding runs ahead of drawing without the file landing in memory.
The soundtrack is extracted to a temp WAV and played through rodio, whose
playback position is the master clock — frames wait against it or get dropped
rather than drifting. Rendering diffs each frame against the last at cell level
and emits only what changed, sharing one cursor move across runs of adjacent
cells.
Resizing the terminal re-fits the picture and respawns the decoder at the current position. So do mode and fill changes, since both change the pixel grid.
MIT. samples/demo.mp4 is generated by ffmpeg and carries the same licence.