whitphx / streamlit-webrtc

Real-time video and audio processing on Streamlit
https://discuss.streamlit.io/t/new-component-streamlit-webrtc-a-new-way-to-deal-with-real-time-media-streams/8669
MIT License
1.38k stars 185 forks source link

get device : chrome webpage show 'component error' #1201

Closed hcgprague closed 1 year ago

hcgprague commented 1 year ago

when starting streamlir run app.py with URL: http://localhost:8501 , the webpage could get camera device correctly. when starting streamlir run app.py with (IP) URL: http://10.146.11.214:8501 , the webpage could not show camera device list , it show'component error' .

yusuf-jkhan1 commented 1 year ago

Yeah same. I'm trying to get this to work inside a docker container so I can use it in a deployed app running inside docker. But cannot get it to work. I can get the app to run locally though without docker

whitphx commented 1 year ago

Generally, HTTPS is needed to access the camera and microphone, except localhost (see https://github.com/whitphx/streamlit-webrtc#https).

Please inform:

yusuf-jkhan1 commented 1 year ago
streamlit==1.19.0
streamlit-webrtc==0.44.6
Python 3.9
chrome browser = Version 109.0.5414.119 (Official Build) (arm64)
MacOS Ventura 13.2.1

Hmm okay. Yeah I guess when I'm running it locally it's not serving via https. But I'm deploying the app via azure websites which does serve the app via https. Although I didn't add any nginx server in my docker container.

I'm running this file of yours: https://github.com/whitphx/streamlit-webrtc/blob/c172483efd4566b18d3500e914285079117b5b35/pages/audio_filter.py

Locally it works fine. When I use your the below dockerfile (based off of your dev dockerfile base image and initial commands) and run it locally or from within azure webapps it fails.

FROM python:3.9

RUN apt-get update && apt-get install -y \
    ffmpeg \
    libgl1 \
 && rm -rf /var/lib/apt/lists/*

WORKDIR /app

EXPOSE 8501

COPY requirements.txt ./requirements.txt

RUN python -m pip install -r requirements.txt
COPY . .
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
WORKDIR /app

ENTRYPOINT ["streamlit", "run", "dev.py", "--server.port=8501", "--server.address=0.0.0.0"]

Do you have an example dockerfile that you use for deployments?

whitphx commented 1 year ago

@yusuf-jkhan1 Thank you. It seems the problem is not the HTTPS-related one that I have mentioned because the component should show a clearer error in that case at least on Chrome.

So can you get the full error log on the browsers' developer tool console?


Do you have an example dockerfile that you use for deployments?

I'm not using Docker for any deployments. The Dockerfile in the repository is just an experimental one, and I develop Streamlit apps without Docker and deploy them to Docker-less environments such as Streamlit Cloud.

hcgprague commented 1 year ago

I found out the solution : it should run ssl-proxy before start streamlit run app.py , then chrome would get the video device correctly when URL is https://IP/.....