Lightweight remote image/video preview server for Python scripts
Project description
previewier
Lightweight Python 3.10+ library for remote preview of images/video from scripts running on servers.
Goals
- Minimal integration into existing scripts.
- Lightweight HTTP preview (MJPEG) without heavy web frameworks.
- Optional RTSP stream for standard players.
- Optional recording to file with PyAV and configurable codec/container.
Install
Base package:
pip install -e .
With optional features:
pip install -e ".[opencv,av]"
Quick start (minimal code changes)
from previewier import PreviewServer
server = PreviewServer(
host="0.0.0.0",
http_port=8080,
enable_http=True,
enable_rtsp=True,
rtsp_port=8554,
rtsp_path="/preview",
rtsp_codec="libx264",
save_path="recordings/out.mp4",
save_codec="libx264",
fps=25,
)
server.start()
# In your frame loop:
# frame: numpy ndarray, BGR, shape [H, W, 3]
server.publish_frame(frame)
# On shutdown:
server.stop()
Context manager mode:
from previewier import PreviewServer
with PreviewServer(host="0.0.0.0", http_port=8080) as server:
# frame loop
server.publish_frame(frame)
HTTP preview URL:
http://<server-ip>:8080/(live MJPEG page)http://<server-ip>:8080/snapshot.jpg(latest frame)
RTSP URL:
rtsp://<server-ip>:8554/preview
API
PreviewServer(...) key options:
enable_http=True: enable built-in MJPEG HTTP server.enable_rtsp=False: enable RTSP publish via PyAV.rtsp_codec="libx264": RTSP codec, e.g.libx264,libx265,mpeg4.save_path=None: if set, writes video using PyAV.save_codec="libx264": recording codec, e.g.libx264,libx265,mpeg4,mjpeg.save_pix_fmt="yuv420p": output pixel format for recorder.
Methods:
start() / stop()publish_frame(frame)for ndarray BGR framepublish_jpeg(jpeg_bytes)if you already have JPEG bytes
Notes
- For
publish_frame, install at least one JPEG backend:- OpenCV:
pip install previewier[opencv] - Pillow:
pip install previewier[pillow]
- OpenCV:
- RTSP mode requires PyAV:
pip install previewier[av]. - RTSP mode publishes to an external RTSP server endpoint (for example MediaMTX).
- If
host="0.0.0.0", RTSP publish target is normalized to127.0.0.1. - Recording requires PyAV:
pip install previewier[av].
Example
See examples/basic_cv2.py.
Development
Install dev tools in your .venv:
python -m pip install -e ".[dev]"
Enable git hooks:
pre-commit install --hook-type pre-commit --hook-type pre-push
pre-commit run --all-files
Test coverage is enforced by pytest config:
- minimum total coverage:
80% - command:
python -m pytest --cov=previewier --cov-report=term-missing --cov-fail-under=80
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 previewier-0.1.0.tar.gz.
File metadata
- Download URL: previewier-0.1.0.tar.gz
- Upload date:
- Size: 152.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64b23a19d3a298d048b945c2775a1d4ca8e2a6bab049316baba600cb7110302c
|
|
| MD5 |
5aaf9fa88bb2bca0c1c91b84234ca55b
|
|
| BLAKE2b-256 |
012c3dbf184acde6ab93e5a5409df050b846c2f41bca18942d2afee336ae0f2f
|
File details
Details for the file previewier-0.1.0-py3-none-any.whl.
File metadata
- Download URL: previewier-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c05a658176132b78a390de68c32aca175852867a1966895d120615a2e78a817
|
|
| MD5 |
d3676831f128731aae9ceb1231c6b177
|
|
| BLAKE2b-256 |
68221f96985ab10af2e8f452f157db430d1c942824227195d4babacc29c03485
|