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.41k stars 189 forks source link

Support docker #7

Open whitphx opened 3 years ago

whitphx commented 3 years ago

It seems aiortc currently does not support port range configuration because aioice, aiortc's dependency, lacks that fucntionality: https://github.com/aiortc/aioice/blob/ed002999545cb1fee35eb372cb3df64c24652c9d/src/aioice/ice.py#L789

whitphx commented 3 years ago

https://github.com/aiortc/aioice/issues/2

stalkerg commented 2 years ago

For docker you can use sysctl tcp port range:

    sysctls:
      net.ipv4.ip_local_port_range: "40000 40010"
whitphx commented 2 years ago

Thank you, this must be helpful info!

whitphx commented 2 years ago

The app seems to work on Docker in my env (m1 mac) wIthout configuring net.ipv4.ip_local_port_range... 🤔

Docker command to run:

    docker run \
        --rm \
        -it \
        -p 8501:8501 \
        -v `pwd`:/srv \
        streamlit-webrtc \
        poetry run streamlit run app.py

The log which shows the port 55453, which is not bound to the container, is used for signaling.

[2022-03-28 14:24:41,560]   DEBUG from streamlit_webrtc.webrtc in /srv/streamlit_webrtc/webrtc.py:407: _process_offer_thread_impl starts
[2022-03-28 14:24:42,660]    INFO from streamlit_webrtc.webrtc in /srv/streamlit_webrtc/webrtc.py:94: Track video received
[2022-03-28 14:24:42,661]    INFO from streamlit_webrtc.webrtc in /srv/streamlit_webrtc/webrtc.py:134: Set <aiortc.rtcrtpreceiver.RemoteStreamTrack object at 0x407dbcf730> as an input video track with video_processor <class 'streamlit_webrtc.process.AsyncVideoProcessTrack'>
[2022-03-28 14:24:42,662]    INFO from streamlit_webrtc.webrtc in /srv/streamlit_webrtc/webrtc.py:149: Add a track <streamlit_webrtc.process.AsyncVideoProcessTrack object at 0x407dbcd160> of kind video to <aiortc.rtcpeerconnection.RTCPeerConnection object at 0x40320ae7c0>
[2022-03-28 14:24:42,687]    INFO from aioice.ice in /root/.cache/pypoetry/virtualenvs/streamlit-webrtc-o9msT97p-py3.9/lib/python3.9/site-packages/aioice/ice.py:1061: Connection(1) Check CandidatePair(('172.17.0.2', 55453) -> ('192.168.3.3', 57620)) State.FROZEN -> State.WAITING
[2022-03-28 14:24:42,687]    INFO from aioice.ice in /root/.cache/pypoetry/virtualenvs/streamlit-webrtc-o9msT97p-py3.9/lib/python3.9/site-packages/aioice/ice.py:1061: Connection(1) Check CandidatePair(('172.17.0.2', 55453) -> ('192.168.3.8', 57781)) State.FROZEN -> State.WAITING
[2022-03-28 14:24:42,766]    INFO from streamlit_webrtc.webrtc in /srv/streamlit_webrtc/webrtc.py:472: ICE connection state is checking
[2022-03-28 14:24:42,767]    INFO from aioice.ice in /root/.cache/pypoetry/virtualenvs/streamlit-webrtc-o9msT97p-py3.9/lib/python3.9/site-packages/aioice/ice.py:1061: Connection(1) Check CandidatePair(('172.17.0.2', 55453) -> ('192.168.3.3', 57620)) State.WAITING -> State.IN_PROGRESS
[2022-03-28 14:24:43,923]    INFO from aioice.ice in /root/.cache/pypoetry/virtualenvs/streamlit-webrtc-o9msT97p-py3.9/lib/python3.9/site-packages/aioice/ice.py:1061: Connection(1) Check CandidatePair(('172.17.0.2', 55453) -> ('192.168.3.8', 57781)) State.WAITING -> State.IN_PROGRESS
[2022-03-28 14:24:43,924]    INFO from aioice.ice in /root/.cache/pypoetry/virtualenvs/streamlit-webrtc-o9msT97p-py3.9/lib/python3.9/site-packages/aioice/ice.py:1061: Connection(1) Check CandidatePair(('172.17.0.2', 55453) -> ('192.168.3.3', 57620)) State.IN_PROGRESS -> State.SUCCEEDED
[2022-03-28 14:24:43,924]    INFO from aioice.ice in /root/.cache/pypoetry/virtualenvs/streamlit-webrtc-o9msT97p-py3.9/lib/python3.9/site-packages/aioice/ice.py:1061: Connection(1) Check CandidatePair(('172.17.0.2', 55453) -> ('my.global.ip.address', 57620)) State.FROZEN -> State.WAITING
[2022-03-28 14:24:43,925]    INFO from aioice.ice in /root/.cache/pypoetry/virtualenvs/streamlit-webrtc-o9msT97p-py3.9/lib/python3.9/site-packages/aioice/ice.py:1061: Connection(1) Check CandidatePair(('172.17.0.2', 55453) -> ('my.global.ip.address', 57781)) State.FROZEN -> State.WAITING
[2022-03-28 14:24:43,929]    INFO from aioice.ice in /root/.cache/pypoetry/virtualenvs/streamlit-webrtc-o9msT97p-py3.9/lib/python3.9/site-packages/aioice/ice.py:1061: Connection(1) Check CandidatePair(('172.17.0.2', 55453) -> ('192.168.3.8', 57781)) State.IN_PROGRESS -> State.SUCCEEDED
[2022-03-28 14:24:43,945]    INFO from aioice.ice in /root/.cache/pypoetry/virtualenvs/streamlit-webrtc-o9msT97p-py3.9/lib/python3.9/site-packages/aioice/ice.py:1061: Connection(1) Check CandidatePair(('172.17.0.2', 55453) -> ('my.global.ip.address', 57620)) State.WAITING -> State.IN_PROGRESS
[2022-03-28 14:24:43,972]    INFO from aioice.ice in /root/.cache/pypoetry/virtualenvs/streamlit-webrtc-o9msT97p-py3.9/lib/python3.9/site-packages/aioice/ice.py:1061: Connection(1) Check CandidatePair(('172.17.0.2', 55453) -> ('my.global.ip.address', 57781)) State.WAITING -> State.IN_PROGRESS
[2022-03-28 14:24:43,977]    INFO from aioice.ice in /root/.cache/pypoetry/virtualenvs/streamlit-webrtc-o9msT97p-py3.9/lib/python3.9/site-packages/aioice/ice.py:1061: Connection(1) ICE completed
[2022-03-28 14:24:44,037]    INFO from streamlit_webrtc.webrtc in /srv/streamlit_webrtc/webrtc.py:472: ICE connection state is completed