whitphx / streamlit-webrtc

Real-time video and audio streams over the network, with Streamlit.
https://discuss.streamlit.io/t/new-component-streamlit-webrtc-a-new-way-to-deal-with-real-time-media-streams/8669
MIT License
1.27k stars 176 forks source link

Low quality video streaming #1570

Open tunahsu opened 3 months ago

tunahsu commented 3 months ago

Why is the video streaming quality poor even though I've set the resolution to the highest resolution of the webcam in the media_stream_constraints? The quality is still worse than directly opening the camera using Windows.

Here is my code:

ctx = webrtc_streamer(
    key='stream-detection',
    video_processor_factory=VideoProcessor,
    media_stream_constraints={
        'video': {
            'width': 1920
            },
        'audio': False
    },
    rtc_configuration={
        'iceServers': [{'urls': ['stun:stun.l.google.com:19302']}]
    },
)
tunahsu commented 3 months ago

I noticed that it takes some time for the frame size to gradually increase, from 640x360 to 960x540 to 1280x720 to 1920x1080. I know that WebRTC adjusts the frame size adaptively based on network speed. Is there any way to fix it at 1920x1080 from the beginning?