How can I use streamlit-webrtc with droidcam in Window 11

Hi. I’m new with streamlit-webrtc. I used to deploy face recognition model with cv2 but streamlit doesn’t fit well with cv2 so I decided to move to streamlit-webrtc. My laptop doesn’t have camera so I have to connect cv2 with droidcam and it works ok but when I migrate to streamlit-webrtc I don’t find out any document about connecting between droidcam and streamlit-webrtc.
Can you give me some way to connect? Thanks.

Hello @hungpham3112 ,
To connect DroidCam with Streamlit-WebRTC, you can use the cv2 library in combination with the streamlit-webrtc library, follow the below steps:

  1. Start DroidCam on your mobile device and ensure that your mobile device and laptop are connected to the same network.
  2. Run the following code in a Python file (e.g., using Streamlit:
    import cv2
    import numpy as np
    import streamlit as st
    import streamlit_webrtc as webrtc

def main():
st.title(“DroidCam Stream”)

# Create a VideoTransformer class that handles video frames
class VideoTransformer(webrtc.VideoTransformerBase):
    def transform(self, frame):
        # Convert the frame to RGB format
        img_rgb = cv2.cvtColor(frame.to_ndarray(), cv2.COLOR_BGR2RGB)
        # Process the frame (e.g., perform face recognition, etc.)
        # ...

        # Return the processed frame in BGR format
        return cv2.cvtColor(img_rgb, cv2.COLOR_RGB2BGR)

# Configure the WebRTC stream
webrtc_ctx = webrtc.Streamer(

# Connect to the DroidCam video stream
cap = cv2.VideoCapture('http://your_droidcam_ip:port/video')

# Start the Streamlit app
while webrtc_ctx.video_transformer:
    # Read a frame from the DroidCam video stream
    ret, frame =
    if not ret:

    # Push the frame to the Streamlit-WebRTC app

# Cleanup resources

if name == “main”:

I hope your doubt gets resolved!

Hi. thanks for your supporting, but when I use your code, it raised
AttributeError: module 'streamlit_webrtc' has no attribute 'Streamer'. It seems some update in new streamlit_webrtc accroding to streamlit_rtc README

For users since versions <0.20

VideoTransformerBase and its transform method have been marked as deprecated in v0.20.0. Please use VideoProcessorBase#recv() instead. Note that the signature of the recv method is different from the transform in that the recv has to return an instance of av.VideoFrame or av.AudioFrame.

Also, webrtc_streamer()'s video_transformer_factory and async_transform arguments are deprecated, so use video_processor_factory and async_processing respectively.

See the samples in for their usage.