webcam2rtsp is a Python package for macOS that streams your webcam over RTSP using H.264 encoding and GStreamer.
🖥️ URL: rtsp://localhost:8851/webcam1
- RTSP server accessible on
localhost:8851 - Streams using system webcam with H.264 encoding
- Easy to install and run in a virtual environment
- Compatible with GStreamer-enabled players (VLC, FFplay, etc.)
brew install gstreamer gst-plugins-base gst-plugins-good gst-libav gst-plugins-bad gst-plugins-ugly pygobject3In your terminal (in the project folder):
export DYLD_LIBRARY_PATH=/opt/homebrew/lib:$DYLD_LIBRARY_PATH
export DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib
export GI_TYPELIB_PATH=/opt/homebrew/lib/girepository-1.0Edit your ~/.zshrc (or ~/.bash_profile):
nano ~/.zshrcAnd copy in the end of the .zshrc and .bash_profile at the end.
export DYLD_LIBRARY_PATH=/opt/homebrew/lib:$DYLD_LIBRARY_PATH
export DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib
export GI_TYPELIB_PATH=/opt/homebrew/lib/girepository-1.0Good luck saving the file using using nano editor!
git clone https://github.com/cosminmemetea/webcam2rtsp.git
cd webcam2rtsp
python3 -m venv venv
source venv/bin/activate
pip install -upgrade pip
pip install -r requirements.txt
pip install -e .
python -m webcam2rtspYou can now open the stream at:
rtsp://localhost:8851/webcam1With:
VLC → Open Network Stream
FFplay → ffplay rtsp://localhost:8851/webcam1
Let’s automate this. Create a file named run_webcam2rtsp.command in your project folder:
touch run_webcam2rtsp.command
chmod +x run_webcam2rtsp.commandMIT – Permissive open-source license allowing free use, modification, and distribution for any purpose, with minimal restrictions.
Contributions make this repo better! Whether fixing bugs, adding features, or improving docs, you're welcome. Let's have fun!