Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video is not being displayed #44

Open
Ashish013 opened this issue Feb 3, 2021 · 11 comments
Open

Video is not being displayed #44

Ashish013 opened this issue Feb 3, 2021 · 11 comments

Comments

@Ashish013
Copy link

Hey @whitphx, I've tracked this repo from the forums. And when I'm trying to access the website for a project I'm working on, it is taking forever to display even the simple video loopback. So is this a problem from myside or is the site broken ?

Screenshot (269)

@whitphx
Copy link
Owner

whitphx commented Feb 4, 2021

Hi, thank you for reporting.
I conformed the problem occurred, but in my case, it was finally successful after trying several times reloading the page and clicking the start button.
Probably it was because the VM instance of Streamlit Sharing is not powerful enough to launch the server-side WebRTC process quickly and it causes connection timeout. Another possibility is that the network interface of the VM instance has some limitations such as blocking some ports, but I can't see the managed backend like that anyway.

However, there are many other potential obstacles to establish WebRTC connection to remote peers.
If the sample app still does not work in your case, please try the following things to identify the cause.

  • Run the example on your local environment, following the README.
    • Connecting from localhost to localhost is the easiest way to succeed. If it is successful while the cloud-based demo fails, there are some problems on the network between your local environment to the remote host (Streamlit Sharing server). For example, inside a office network, the FW can be configured to drop some packets (FYI: Using relay servers, called TURN server, can solve this problem as Google Meet or Zoom may do, but this sample app does not now because it takes cost).
  • Try this page: https://streamlit-webrtc-example.herokuapp.com/ , which is the same app hosted on a different host, Heroku. If it is successful, the problem possibly resides in Streamlit Sharing.
  • If all above failed, check the log printed on the console of your web browser and send it to me. Some error might have occurred on the client-side.

@Ashish013
Copy link
Author

Ashish013 commented Feb 4, 2021

Hey @whitphx, thanks a lot for getting back so fast. I've tried running the example locally and it works like a charm 💯 .
Kudos to you, ❤️ the work you're doing for the community.

I've also tried the app hosted on heroku and the outcome is the same as the app hosted on streamlit. Looking forward to complete web-rtc through streamlit without any hiccups.

Edit 1: While running the app locally and operating in a few modes, I've observed that the app's misbehaves in 2 ways:

  1. The same problem as the one hosted on streamlit/heroku where the video player keeps on loading.
  2. A faded live video stream is seen running in the previous app mode. And the highlighted video which is meant to run the current app mode keeps on loading like the problem stated in 1). The screenshot attached below demonstrates the stated behavior.

Screenshot (271)

In both the case I've observed a similar error log printed in the terminal, as attached below:

[2021-02-04 21:57:57,595]    INFO from ice in ice.py:1008: Connection(0) Consent to send expired
[2021-02-04 21:58:22,962]    INFO from ice in ice.py:1008: Connection(2) Consent to send expired

@whitphx
Copy link
Owner

whitphx commented Feb 7, 2021

Thank you for the report!
I will check it.

@superwhyun
Copy link

Thank you for your great work!
In my case, when I tried object detection after launching streamlit server, it works well. But, when I stop the streaming and start again, it stucked.

@superwhyun
Copy link

superwhyun commented Mar 11, 2021

I found a solution.

in the app.py:321,

<Before>
            if webrtc_ctx.video_transformer:
                while True:
                    result = webrtc_ctx.video_transformer.result_queue.get()
                    labels_placeholder.table(result)

<After>
            while True:
                if webrtc_ctx.video_transformer:    
                    result = webrtc_ctx.video_transformer.result_queue.get()
                    labels_placeholder.table(result)
                else:
                    break

This needs to be reflected to the example codes accordingly.
Thanks.

@whitphx
Copy link
Owner

whitphx commented Mar 12, 2021

Thank you for the report!

While this problem may be related to #73 and I'm working on fixing the fundamental issue,
your workaround looks nice to avoid the problem with the current version! Thank you and I will reflect it to the sample app.

@Usama3059
Copy link

@Ashish013 same problem does you find any solution

@whitphx
Copy link
Owner

whitphx commented Apr 8, 2021

The problem has still been happening sometimes and I updated the fix suggested in #44 (comment) .

Timeout must be set to queue.get() to avoid being stuck forever.

result = webrtc_ctx.video_transformer.result_queue.get(timeout=1.0)

I updated app.py in #120

@SolomonLartey
Copy link

@whitphx any times I try to run the app.py I receive “Your app is having trouble loading the streamlit_webrtc.webrtc_streamer component”.how can I solve this issue

@Esdsnqxz
Copy link

@whitphx any times I try to run the app.py I receive “Your app is having trouble loading the streamlit_webrtc.webrtc_streamer component”.how can I solve this issue

hi,did u solve this problem?

@AIOnGraph
Copy link

Exception in callback Transaction.__retry()

handle: <TimerHandle when=3215181.568628646 Transaction.__retry()>

Traceback (most recent call last):

File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto

self._sock.sendto(data, addr)

AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/lib/python3.9/asyncio/events.py", line 80, in _run

self._context.run(self._callback, *self._args)

File "/home/adminuser/venv/lib/python3.9/site-packages/aioice/stun.py", line 312, in __retry

self.__protocol.send_stun(self.__request, self.__addr)

File "/home/adminuser/venv/lib/python3.9/site-packages/aioice/ice.py", line 266, in send_stun

self.transport.sendto(bytes(message), addr)

File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto

self._fatal_error(

File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error

self._loop.call_exception_handler({

AttributeError: 'NoneType' object has no attribute 'call_exception_handler'

Exception in callback Transaction.__retry()

handle: <TimerHandle when=3215243.142471571 Transaction.__retry()>

Traceback (most recent call last):

File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto

self._sock.sendto(data, addr)

AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/lib/python3.9/asyncio/events.py", line 80, in _run

self._context.run(self._callback, *self._args)

File "/home/adminuser/venv/lib/python3.9/site-packages/aioice/stun.py", line 312, in __retry

self.__protocol.send_stun(self.__request, self.__addr)

File "/home/adminuser/venv/lib/python3.9/site-packages/aioice/ice.py", line 266, in send_stun

self.transport.sendto(bytes(message), addr)

File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto

self._fatal_error(

File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error

self._loop.call_exception_handler({

AttributeError: 'NoneType' object has no attribute 'call_exception_handler'

This error comes when i deploy my app on streamlit. the webcam not started and give me this error.
here is my webcam code
if option == "📷 Webcam":
st.sidebar.write("Using Webcam")
try:
print(000000000000000000000000000000000000000000000000000000000000000)
webrtc_ctx = webrtc_streamer(
key="example",
video_processor_factory=lambda: processor,
mode=WebRtcMode.SENDRECV,
media_stream_constraints={"video": True, "audio": False},
rtc_configuration=rtc_configuration,
async_processing=True,
# video_frame_callback=processor.recv
)
print(webrtc_ctx,55555555555555555555555555555555555555555555555)
except Exception as e:
st.error(f"An error occurred: {e}")
if webrtc_ctx and webrtc_ctx.video_processor:
webrtc_ctx.video_processor.confidence_threshold = confidence_threshold
webrtc_ctx.video_processor.nms_threshold = nms_threshold
print(webrtc_ctx.video_processor,4444444444444444444444444444444444444444444444444444444444)

        fix this issue if someone solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants