Skip to main content

A minimal RTSP client implemented with the Python standard library only.

Project description

rtspy

A minimal RTSP client implemented with the Python standard library only.

rtspy provides a small, requests-like API for common RTSP operations such as OPTIONS, DESCRIBE, SETUP, PLAY, PAUSE, and TEARDOWN.

Features

  • Pure Python, no third-party runtime dependencies
  • Lightweight client object with persistent session support
  • One-shot request helper similar to requests.request
  • Basic redirect handling
  • Minimal SDP helpers for duration and range parsing
  • RTSP-only URL validation (rtsp://)

Requirements

  • Python 3.8+

Installation

This package is not published yet.

When published to PyPI, install with:

pip install rtspy

For local development right now:

git clone <your-repo-url>
cd rtspy

Quick Start

import rtspy

client = rtspy.Client("rtsp://example.com/live")
resp = client.describe()

print(resp.status_code)
print(resp.headers)
print(resp.text)

client.close()

One-shot request style:

import rtspy

resp = rtspy.request("OPTIONS", "rtsp://example.com/live")
print(resp.status_code, resp.reason)

URL Support

Only rtsp:// URLs are supported.

If a non-RTSP URL is used, rtspy raises ValueError or RTSPError depending on the operation.

API Overview

Client

Client(rtsp_server_uri, timeout=8.0, user_agent="rtspy/0.1", allow_redirects=True, max_redirects=5, auto_connect=True)

Main methods:

  • options(uri=None, headers=None)
  • describe(uri=None, headers=None)
  • setup(uri=None, headers=None, transport="RTP/AVP/TCP;unicast;interleaved=0-1")
  • play(uri=None, headers=None, range_header=None)
  • pause(uri=None, headers=None)
  • teardown(uri=None, headers=None)
  • set_parameter(uri=None, headers=None, body=None)
  • get_parameter(uri=None, headers=None, body=None)
  • request(method, uri=None, headers=None, body=None, allow_redirects=None, max_redirects=None)

Response

Response contains:

  • status_code
  • reason
  • version
  • headers
  • body
  • raw

Convenience properties:

  • text
  • body_text
  • body_lines
  • body_kv
  • npt_range
  • duration_seconds

Error Handling

  • RTSPError: base exception for protocol/parsing related issues
  • RTSPConnectionError: connection and socket-level failures

License

This project is licensed under the terms in LICENSE.

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

rtspy-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

rtspy-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file rtspy-0.1.0.tar.gz.

File metadata

  • Download URL: rtspy-0.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for rtspy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c3e0d3a97196986c59ebe02e6b2cd7417d4dff4c11d3457e95cea0a04087308
MD5 d3bdcc617bf102e5bb9e46c9bb912851
BLAKE2b-256 ffcecf66f563e60b6e67bbede643f28a1f134fd32c8c05c6401b52b513aeba78

See more details on using hashes here.

File details

Details for the file rtspy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rtspy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for rtspy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1f21707aa9323232ad47d2447691ffc66350a67e7a06c91149a14201512068e
MD5 1aa78cacbaafc5e1ece99ab665fe8760
BLAKE2b-256 061c2e4f101ea602773643a7e92279e829e9eeb6899f4bd57ba051d3f6dc98a0

See more details on using hashes here.

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