Skip to main content

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-python and numpy.
  • 🐍 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-python
  • numpy

🤝 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trueframe-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trueframe-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

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

Hashes for trueframe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3ad96b545c3279c7166105121e21f5cb2da951fb4817d019d11725dde657b1aa
MD5 ae9f240d85c44dada45c5729560e97dc
BLAKE2b-256 926eef152837dbe95af38c094df86ff57072641d4ed8125fa711b09815c64f1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for trueframe-0.1.0.tar.gz:

Publisher: publish.yml on ytcalifax/trueframe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for trueframe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68857818627f34cbdc27d98b6e8ba90288614b44bb3051846acc98f2efd964a8
MD5 0692f852fff0edf3ca300716933f7a5a
BLAKE2b-256 2adf0bd97b4b61a25f43c0f062cce4844d6d4a30e336eb8268f4d99095320bdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for trueframe-0.1.0-py3-none-any.whl:

Publisher: publish.yml on ytcalifax/trueframe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page