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.36k stars 182 forks source link

"START" in duplicate window/tab stops recording in previous windows/tabs #564

Closed Mifodix closed 2 years ago

Mifodix commented 2 years ago

Streamlit-webrtc used as audio recorder: while True: audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=1)

How to reproduce:

If change some streamlit widget in Browser1, sound recording resume.

whitphx commented 2 years ago

I could not reproduce the bug. Can you provide the complete code and your environment information to reproduce the bug? FYI, I tested it with the code below:

import queue

import streamlit as st
from streamlit_webrtc import (
    RTCConfiguration,
    WebRtcMode,
    webrtc_streamer,
)

webrtc_ctx = webrtc_streamer(
    key="sendonly-audio",
    mode=WebRtcMode.SENDONLY,
    audio_receiver_size=256,
    rtc_configuration=RTCConfiguration(
        {"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]}
    ),
    media_stream_constraints={"audio": True},
)

status = st.empty()

while True:
    if webrtc_ctx.audio_receiver:
        try:
            audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=1)
            status.write([audio_frame.to_ndarray() for audio_frame in audio_frames])
        except queue.Empty:
            status.warning("Queue is empty. Abort.")
            break
    else:
        print("AudioReciver is not set. Abort.")
        break

additionally, what does it mean for the browser1 to stop receiving the frames? Does webrtc_ctx.audio_receiver.get_frames throw an exception? Does it return None? Is it frozen?

Mifodix commented 2 years ago

After update to last versions of requirements i can't reproduce bug.