How to stream IP camera in webrtc_streamer

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,
rtc_configuration=RTCConfiguration(
{“iceServers”: [{“urls”: [“stun:stun.l.google.com:19302”]}]},
media_stream_constraints={“video”: True, “audio”: False},
)
)

TIA

Hi there,

Thanks for sharing your question with the community! Check out our guidelines on how to post an effective question here – in particular, please format your code snippet properly and explain what is going wrong with your current code.

Caroline :balloon:

i want stream ip camera in my streamlit app ,by default when i run streamlit app it is showing sys and web cam as video source?
So my question is how to change video source using webrtc_streamer.

1 Like

Try something like this

#### IMPORT #####
import cv2
import time
import streamlit as st

### CONNECT TO CAMERA 
# either like this using your own camera IP
capture = cv2.VideoCapture('rtsp://192.168.1.64/1')
# or like this
capture = cv2.VideoCapture('rtsp://username:password@192.168.1.64/1')

### Check box to turn on camera
run = st.checkbox("Turn on camera",value=False)

### MAKE PLACE HOLDER FOR VIDEO FRAMES
FRAME_WINDOW =st.image([])

### GRAB NEW IMAGE
if run:
    x, frame = camera.read()
    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    time.sleep(0.025)

Hi @ KHUBAIB_AHMED did you find any other ways to do it?

Webrtc won’t support rtsp i think