Skip to main content

webcam2rtsp

webcam2rtsp streams a local laptop or USB webcam over RTSP using Python and GStreamer. It supports Linux, macOS, and Windows when the matching GStreamer camera source plugin is installed.

Default stream URL:

rtsp://<computer-ip>:8854/webcam1

Features

  • RTSP server with configurable bind address, port, and mount path
  • Platform defaults for Linux, macOS, and Windows webcams
  • Configurable camera device, resolution, framerate, and H.264 bitrate
  • Custom GStreamer source support for unusual camera drivers
  • Compatible with VLC, FFplay, and other RTSP clients

Install GStreamer

macOS

brew install gstreamer gst-plugins-base gst-plugins-good gst-libav gst-plugins-bad gst-plugins-ugly pygobject3

If Python cannot find the GStreamer libraries, export these variables:

webcam2rtsp --print-env

The command detects /opt/homebrew on Apple Silicon Macs and /usr/local on Intel Macs. It prints values like PATH, DYLD_LIBRARY_PATH, GI_TYPELIB_PATH, GST_PLUGIN_PATH, and GST_PLUGIN_SYSTEM_PATH_1_0 only when those paths exist.

Linux

Debian/Ubuntu:

sudo apt update
sudo apt install -y python3-gi python3-gst-1.0 gir1.2-gst-rtsp-server-1.0 \
  gstreamer1.0-tools gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
  gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly

Fedora:

sudo dnf install -y python3-gobject gstreamer1 gstreamer1-plugins-base \
  gstreamer1-plugins-good gstreamer1-plugins-bad-free gstreamer1-plugins-ugly \
  gstreamer1-rtsp-server

Windows

PyGObject usually does not install from normal PyPI on Windows. If you see No module named gi or Could not find a version that satisfies the requirement PyGObject, do not keep retrying pip install PyGObject.

Recommended Windows setup:

  1. Install MSYS2 from:
https://www.msys2.org/
  1. Open the MSYS2 UCRT64 shell.

  2. Install Python, PyGObject, GStreamer, plugins, and RTSP server bindings:

pacman -S --needed mingw-w64-ucrt-x86_64-python mingw-w64-ucrt-x86_64-python-gobject mingw-w64-ucrt-x86_64-gstreamer mingw-w64-ucrt-x86_64-gst-plugins-base mingw-w64-ucrt-x86_64-gst-plugins-good mingw-w64-ucrt-x86_64-gst-plugins-bad mingw-w64-ucrt-x86_64-gst-plugins-ugly mingw-w64-ucrt-x86_64-gst-libav mingw-w64-ucrt-x86_64-gst-rtsp-server
  1. Install webcam2rtsp using the MSYS2 Python:
python -m pip install webcam2rtsp
webcam2rtsp-doctor

Install webcam2rtsp

After installing GStreamer for your operating system:

python -m pip install webcam2rtsp

If you want pip to also try installing the Python PyGObject binding on macOS or Linux, use the optional extra:

python -m pip install "webcam2rtsp[pygobject]"

For Debian/Ubuntu virtual environments that use python3-gi from apt, create the environment with system packages visible:

python3 -m venv --system-site-packages .venv
source .venv/bin/activate
python -m pip install webcam2rtsp

Verify the native GStreamer setup:

webcam2rtsp-doctor

On macOS and Windows, webcam2rtsp automatically detects common GStreamer install paths before importing PyGObject. If your shell still needs the same values permanently, print them with:

webcam2rtsp --print-env

Then add the printed lines to your shell profile, such as ~/.zshrc on macOS.

For local development from this repository:

git clone https://github.com/CosminBMemetea/webcam2rtsp.git
cd webcam2rtsp
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -e .

On Debian/Ubuntu, prefer this venv command when using python3-gi from apt:

python3 -m venv --system-site-packages venv

requirements.txt is intentionally empty for runtime dependencies. The gi module comes from native PyGObject packages installed through Homebrew, apt, dnf, pacman, or another operating-system package manager.

Local development can run the same checks with:

python -m webcam2rtsp --doctor
python -m webcam2rtsp --print-env

Run

Use the default webcam:

python -m webcam2rtsp

Open the stream from another machine on the same network:

rtsp://<computer-ip>:8854/webcam1

Local test with FFplay:

ffplay rtsp://127.0.0.1:8854/webcam1

Configuration

python -m webcam2rtsp \
  --address 0.0.0.0 \
  --port 8554 \
  --mount-point /camera \
  --device /dev/video2 \
  --width 1280 \
  --height 720 \
  --framerate 30 \
  --bitrate 2500

Device examples:

# Linux
python -m webcam2rtsp --device /dev/video0

# macOS
python -m webcam2rtsp --device 0

# Windows
python -m webcam2rtsp --device 0

Use a custom GStreamer source when the default source is not right for your camera:

python -m webcam2rtsp --source "autovideosrc"
python -m webcam2rtsp --source "dshowvideosrc device-name=\"Integrated Camera\""

Available options:

python -m webcam2rtsp --help

Publish to PyPI

Build the package:

python -m pip install --upgrade build twine
python -m build

Check the package metadata:

python -m twine check dist/*

Upload to TestPyPI first:

python -m twine upload --repository testpypi dist/*

Upload to PyPI when the TestPyPI package installs correctly:

python -m twine upload dist/*

Platform Defaults

  • Linux: v4l2src device="/dev/video0"
  • macOS: avfvideosrc device-index=0
  • Windows: mfvideosrc device-index=0

License

MIT

Metadata

Release files for webcam2rtsp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for webcam2rtsp 0.1.0
File Size Uploaded Provenance Actions
webcam2rtsp-0.1.0.tar.gz 11.1 kB Without provenance Details for webcam2rtsp-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for webcam2rtsp 0.1.0
File Interpreter ABI Platform Actions
webcam2rtsp-0.1.0-py3-none-any.whl Python 3 none any Details for webcam2rtsp-0.1.0-py3-none-any.whl

Total release size: 21.2 kB

Release files / webcam2rtsp-0.1.0.tar.gz

Download URL webcam2rtsp-0.1.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
39bffedbabad9a7f304d044b83c7b5636096f5ab0418792713379bc3d085cbb1
BLAKE2b-256 checksum
How to use checksums
41d25478cf19fd637ab2a9bbe848b02f30e88ce4299740151634574cb1d5598b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / webcam2rtsp-0.1.0-py3-none-any.whl

Download URL webcam2rtsp-0.1.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54b635c0e88a66537dd377b8bc02a3afa4e442084dec91b33bfad3d7b87ea604
BLAKE2b-256 checksum
How to use checksums
71d667d926719f4dbb91f2671f74bcc344bad7fb6e6fdadcc7ee9f646da684e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Security for webcam2rtsp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page