Skip to content
bas3linePublic

About

Play videos in your terminal, with sound — half-block colour, dithered braille dots, or ASCII. Rust + ffmpeg.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tplay

Play a video in your terminal, with sound. Rust, decoding through ffmpeg.

tplay samples/demo.mp4 --dots

Install

Needs ffmpeg on PATH:

brew install ffmpeg          # macOS
sudo apt install ffmpeg      # Debian/Ubuntu

Then:

cargo install --path .

Use

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 open

Everything 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.

Picture modes

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.

Tuning the dots

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.
  • --dither picks the kernel. atkinson passes on only 6/8 of the error, so blacks stay black and edges stay hard. bayer thresholds 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. floyd has the smoothest gradients and the most shimmer.
  • --black sets the input black point. Coded "black" in a video sits near 16/255, and without a floor the dither sprays dots through every shadow.

How it works

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.

Licence

MIT. samples/demo.mp4 is generated by ffmpeg and carries the same licence.

About

Play videos in your terminal, with sound — half-block colour, dithered braille dots, or ASCII. Rust + ffmpeg.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages