Installation¶
Install the library¶
Webcam capture and snapshot encoding require the optional OpenCV extra:
Check the media tools¶
easy-rtsp orchestrates external media tools rather than bundling large binaries. Run:
You need FFmpeg and ffprobe for decoding and publishing. MediaMTX is required for a proper locally hosted RTSP stream and for LAN/WebRTC access.
This command can download MediaMTX and prints platform-specific FFmpeg guidance. See Dependencies for environment-variable overrides.
Publish your first stream¶
With MediaMTX installed, the CLI prints:
Open that URL in VLC, ffplay, OBS, or another RTSP client. Press ++ctrl+c++ to stop the stream cleanly.
Use the Python API¶
from easy_rtsp import Stream
stream = Stream.from_file("clip.mp4").serve("live")
print(stream.viewer_url)
try:
stream.wait()
finally:
stream.stop()
serve() is non-blocking. Call wait(), keep your own application loop alive, or use the stream as a context manager.
Develop from a clone¶
This project uses uv:
uv sync --extra dev --group docs
uv run pytest
uv run ruff check src tests
uv run --group docs mkdocs serve
The documentation preview is available at http://127.0.0.1:8000 while MkDocs is running.