A high-performance, latency-free RTSP stream reader for real-time AI inference.
Project description
📹 TrueFrame
A robust, latency-free RTSP stream reader for Python, designed to fetch the absolute latest frame.
TrueFrame gives you a clean, dependency-light Python interface to any RTSP stream. It intelligently handles connection drops and buffer management, ensuring you always get the most recent frame without smearing, artifacting, or latency buildup.
✨ Features
- 🚀 Zero Latency: Uses a background thread to continuously flush the stream buffer, so
read()always returns the latest frame. - 🔌 Robust Reconnects: Automatically handles stream interruptions and attempts to reconnect without user intervention.
- 🖼️ Simple & Clean API: An intuitive interface that's easy to integrate. Use it as a context manager for automatic resource cleanup.
- 🗂️ Modular Design: A clean, SOLID-based architecture (
Camera,FrameGrabber,Stream) for better maintainability. - ⚡ Minimal Dependencies: Only needs
opencv-pythonandnumpy. - 🐍 Context Manager: Built-in
__enter__and__exit__for safe and easy resource management.
📥 Installation
pip install trueframe
Or, to install directly from source:
pip install .
🚀 Quick Start
import cv2
from trueframe import TrueFrame
# Replace with your RTSP stream URL
RTSP_URL = 'rtsp://user:pass@192.168.1.100:554/stream'
def main():
# Use a 'with' statement for automatic resource management
with TrueFrame(RTSP_URL) as stream:
print(f"Connecting to {RTSP_URL}...")
while True:
# Read the latest frame
frame = stream.read()
# If a frame was received, display it
if frame is not None:
cv2.imshow("TrueFrame RTSP Stream", frame)
# Press 'q' to exit the loop
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Clean up
cv2.destroyAllWindows()
print("Stream stopped.")
if __name__ == "__main__":
main()
⚙️ Core Components
| Class | Description |
|---|---|
TrueFrame |
The main, user-facing class that provides the simple read()/stop() API. |
Stream |
A facade that coordinates the Camera and FrameGrabber components. |
Camera |
A low-level wrapper around cv2.VideoCapture for connecting and grabbing. |
FrameGrabber |
The background worker that runs in a separate thread to continuously fetch frames. |
🐍 Requirements
- Python 3.8+
opencv-pythonnumpy
🤝 Contributing
Issues and pull requests are welcome! Please file an issue if you encounter any problems or have suggestions for improvements.
Built with ❤️ for smooth video streaming. MIT Licensed.
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 trueframe-0.1.0.tar.gz.
File metadata
- Download URL: trueframe-0.1.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ad96b545c3279c7166105121e21f5cb2da951fb4817d019d11725dde657b1aa
|
|
| MD5 |
ae9f240d85c44dada45c5729560e97dc
|
|
| BLAKE2b-256 |
926eef152837dbe95af38c094df86ff57072641d4ed8125fa711b09815c64f1b
|
Provenance
The following attestation bundles were made for trueframe-0.1.0.tar.gz:
Publisher:
publish.yml on ytcalifax/trueframe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trueframe-0.1.0.tar.gz -
Subject digest:
3ad96b545c3279c7166105121e21f5cb2da951fb4817d019d11725dde657b1aa - Sigstore transparency entry: 1155259231
- Sigstore integration time:
-
Permalink:
ytcalifax/trueframe@2a2353039cc2aae9922cd601d9ffa0095ecc8464 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/ytcalifax
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2a2353039cc2aae9922cd601d9ffa0095ecc8464 -
Trigger Event:
release
-
Statement type:
File details
Details for the file trueframe-0.1.0-py3-none-any.whl.
File metadata
- Download URL: trueframe-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68857818627f34cbdc27d98b6e8ba90288614b44bb3051846acc98f2efd964a8
|
|
| MD5 |
0692f852fff0edf3ca300716933f7a5a
|
|
| BLAKE2b-256 |
2adf0bd97b4b61a25f43c0f062cce4844d6d4a30e336eb8268f4d99095320bdf
|
Provenance
The following attestation bundles were made for trueframe-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on ytcalifax/trueframe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trueframe-0.1.0-py3-none-any.whl -
Subject digest:
68857818627f34cbdc27d98b6e8ba90288614b44bb3051846acc98f2efd964a8 - Sigstore transparency entry: 1155259234
- Sigstore integration time:
-
Permalink:
ytcalifax/trueframe@2a2353039cc2aae9922cd601d9ffa0095ecc8464 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/ytcalifax
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2a2353039cc2aae9922cd601d9ffa0095ecc8464 -
Trigger Event:
release
-
Statement type: