High-performance terminal video visualization and recording library.
Project description
TermVis
Watch video streams and monitor CV models directly over SSH — no X11, no GUI required.
Built with Rust + OpenCV. Renders frames as high-fidelity half-block characters with lossless incremental compression and Fourier sharpening.
Performance actively optimized with Claude Code: dirty-rect rendering, raw pointer pixel access, pre-allocated ANSI buffers, and zero-copy compression paths.
Why
When you're working on a remote GPU server via SSH, you have no way to see what your vision model is actually looking at. Downloading frames one by one is slow, and streaming high-res video over a laggy connection is painful.
TermVis addresses this by:
- Converting video frames to half-block (
▀) characters with 24-bit color, effectively doubling terminal vertical resolution. - Compressing only the diff between frames using a Delta-XOR + Zlib scheme (
.lzdxformat), so static backgrounds cost almost nothing. - Applying DFT (Fourier) sharpening on the fly to recover edge detail at terminal resolutions.
Install
pip install termvis
Quick Start
import termvis
# Preview a webcam or video file
termvis.quick_play(0) # camera index
termvis.quick_play("clip.mp4") # or a file path
Press q to quit.
API
TermVis class
from termvis import TermVis
Use as a context manager — it hides the cursor and switches to the alternate screen buffer on enter, and restores terminal state on exit.
with TermVis() as tv:
...
| Method | Description |
|---|---|
render(frame_bgr) |
Render an OpenCV BGR frame to the terminal. Handles color conversion and adaptive resizing. |
poll_key() |
Non-blocking key read. Returns a string like 'q', 'esc', 'enter', or None. |
start_recording(path) |
Start saving frames to a .lzdx file. |
stop_recording() |
Flush and close the current recording. |
play_recorded(path, sharpen=0.3) |
Play back a .lzdx recording. sharpen controls DFT filter strength (0.0–1.5). |
get_mapping_info() |
Returns a dict with terminal dimensions, render height, and original frame size. |
map_coords(col, row) |
Translate 1-based terminal character coordinates to original frame pixel coordinates. |
quick_play(source=0)
High-level helper for camera or file preview. q to quit.
Examples
See the examples/ directory:
| File | What it shows |
|---|---|
basic_demo.py |
Minimal render loop |
interactive_painter.py |
Draw on a high-res canvas using terminal mouse clicks |
remote_control_demo.py |
Mouse event parsing and coordinate mapping |
remote_desktop.py |
Mirror a physical display into SSH with mouse passthrough |
How it works
Rendering — Each terminal cell holds two pixels stacked vertically via the ▀ half-block character, with independent 24-bit foreground/background colors. This doubles effective vertical resolution.
Compression — Consecutive frames are XOR'd and the diff is zlib-compressed. Static regions compress to near-zero. The result is stored as .lzdx (Delta-XOR).
Engine — Pixel sampling and byte manipulation run in a Rust core via PyO3, keeping the hot path off the Python GIL.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file termvis-0.1.9-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: termvis-0.1.9-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 232.8 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a835e791d520fb93af84fef646bc65ecb56c48c73942e8c8b38f793cf731c36c
|
|
| MD5 |
1aed74e66ddbcf0dec03b05f580f9e33
|
|
| BLAKE2b-256 |
46563b5b71441294a010514f41818272f52b61db7dcc6cdd4bb6a9dd3a8f67d1
|
File details
Details for the file termvis-0.1.9-cp38-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: termvis-0.1.9-cp38-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 16.5 MB
- Tags: CPython 3.8+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93e5fa778f208f7abd77c69638b674058a26cfe874b268872240a8fcbf04d6ee
|
|
| MD5 |
3b2746f4f8c91ce201e6f0097537bc67
|
|
| BLAKE2b-256 |
5654e12ead8cec8626f5209509ffc373a9205c66db8f78112d08eb56a0cdbe85
|
File details
Details for the file termvis-0.1.9-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: termvis-0.1.9-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 360.4 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
559dc4e626dff55bfe9e247a137a947a92c792bba6870f5cb9b2add3bd15619c
|
|
| MD5 |
418a4191b877e345a4bc704b3d83a092
|
|
| BLAKE2b-256 |
312b59230faf3458463072d02a6120fd2813fd0ea8438abedcf9ddcceff1569a
|