How to Stream IP Camera using webrtc streamlit


Hi @ whitphx ,can you help me ,how to run/stream IP camera.
as web cam is working fine by following syntax
webrtc_streamer(key=“key”, video_processor_factory=VideoProcessor,
{“iceServers”: [{“urls”: [“”]}]},
media_stream_constraints={“video”: True, “audio”: False},


To stream an IP camera in Streamlit using the webrtc_streamer function, you can follow these steps:

  1. Install the necessary dependencies:

    • opencv-python: pip install opencv-python
    • aiortc: pip install aiortc
    • av: pip install av
  2. Import the required libraries:

import streamlit as st
from import MediaPlayer
from import MediaRecorder
import cv2
  1. Define the webrtc_streamer function with appropriate parameters:
webrtc_ctx = webrtc_streamer(
    rtc_configuration={"iceServers": [{"urls": [""]}]},
        "video": True,
        "audio": False
  1. Use the cv2 library to capture frames from the IP camera and display them in Streamlit:
if webrtc_ctx.video_receiver:
    # Initialize the VideoCapture object for IP camera
    cap = cv2.VideoCapture("your_ip_camera_url")

    while True:
        # Read frame from IP camera
        ret, frame =

        # Display the frame in Streamlit
        if ret:
            st.image(frame, channels="BGR")

    # Release the VideoCapture object and cleanup

Make sure to replace "your_ip_camera_url" with the actual URL of your IP camera.

Note: Streaming an IP camera may vary depending on the specific camera model and its compatibility with the cv2 library. Additionally, make sure the IP camera is accessible and properly configured for streaming.

Remember to handle any potential errors or exceptions that may occur during the streaming process.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.