home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.54k stars 29.46k forks source link

Stream is not live #22941

Closed TarheelGrad1998 closed 4 years ago

TarheelGrad1998 commented 5 years ago

Home Assistant release with the issue: 91.1

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.): Docker Foscam R4 camera

Component/platform: Stream

Description of problem: I'm not explicitly using the streaming service, but viewing the stream from Lovelace UI. I see the still of the camera in the picture entity card, and it is current. When I click the still, the stream may be old, sometimes days old. This is with "Preload Stream" enabled (without, it never seems to load).
I've seen it with other cameras as well, but the R4 seems to always do it.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

  - platform: foscam
    ip: <local ip>
    port: 88
    username: !secret camera_user
    password: !secret camera_password
    name: Home Camera

Traceback (if applicable):

Additional information:

tube0013 commented 5 years ago

I'm seeing the same thing, with a generic cam (wyze with Xiaomi-Dafang-Hacks) and on 0.91.2 I just posted to the forums as well.

https://youtu.be/i3HQevp-M3A

delete1234 commented 5 years ago

Same issue here. Setup with blue iris. The stream is not live. Stream is old, maybe 12 hours.. After restart the stream is only seconds behind. Then after some hours the delay is back..

BertilJ commented 5 years ago

I've got the same behaviour, although it's not that the stream is old, it locks to the same "clip". Don't know what else to describe it with.

Sometimes it works for a few days with a normal lag of ~20 sec, but suddenly the live-stream locks to a specific time, every time the stream is viewed it starts at the same time stamp and runs for 18 seconds before starting to try to load again and is never able to load properly. First I thought this to be a browser issue, but it isn't. I've opened it from several computers and mobiles and the 18 sec "stream" is always teh same 18 sec.

TarheelGrad1998 commented 5 years ago

Good clarification BertilJ. Yes the "old" is usually the same clip for me as well for some time. I haven't yet nailed down where that clip comes from (i.e. if it's from the last restart or what) and I have been restarting hass a lot lately, adding this or tweaking that.

I have also tried from different devices and even networks and can see the same video. So whatever it is is "cached" inside hass somewhere.

droopanu commented 5 years ago

I see a similar behavior when this bug is triggered: https://github.com/home-assistant/home-assistant/issues/22741#issuecomment-480122018

They might be the same issue...

droopanu commented 5 years ago

@tube0013: are your able to reproduce the issue by rebooting the camera while stream preload is enabled?

tomeeka commented 5 years ago

I have the same issue with 2 rtsp enabled xiaofang cameras. Does not matter if preload is enabled or not. Morover if a stream is opened on the lovelace UI after a few hours my home assistant stops responding. Automations are not working, the web UI is not available. There is nothing new in the log file from that time. Home assistant is still in the process list.

Skeletorjus commented 5 years ago

Exact same issue as tomeeka. Have tried to enable debug logging, but there's nothing of interest to be found. Only way to get Home Assistant to function again is to restart it through a terminal/SSH-session. This is running hass.io on a Debian-server (not on a Pi).

droopanu commented 5 years ago

I've seen that issue too. It happens when the streaming platform loses connectivity to the camera, and gets "stuck" and then after a while it tries to stop streaming. The way I managed to reproduce it by starting streaming a camera, rebooting the camera, and then close the streaming window. After 5 minutes, the stream times out and tries to stop, and HomeAssistant hangs completely.

sendorm commented 5 years ago

Same issue. The problem can be created on post 0.90 versions. If the camera gets disconnected (for instance remove power to camera) HA hangs up.

droopanu commented 5 years ago

I think I have figured out how to fix the issue.

https://github.com/home-assistant/home-assistant/pull/23617

If you are using HomeAssistant (not hass,io) you can try to manually apply the patch and see if it fixes it for you. Easiest way to patch would be to edit lib/python3.6/site-packages/homeassistant/components/stream/__init__.py in your homeassistant installation folder and add the following line: options['stimeout'] = '5000000' right after the options['rtsp_flags'] = 'prefer_tcp' line.

Make sure the number of spaces in front of this line is exactly the same as on the line above. It should look like this:

    # For RTSP streams, prefer TCP
    if isinstance(stream_source, str) \
            and stream_source[:7] == 'rtsp://' and not options:
        options['rtsp_flags'] = 'prefer_tcp'
        options['stimeout'] = '5000000'

After this change, restart homeassistant.

After applying this change, if the camera loses connection, the stream gets closed and you lose the lookback for the next recording as the stream needs to be restarted. Next time the stream gets started, you should regain the lookback functionality.

Mark612 commented 5 years ago

I've seen the same issue, "not live", with Amcrest cameras. D-Link cameras seem to work fine.

When I put in the stimeout patch mentioned above, the Amcrest live stream no longer works.

delete1234 commented 5 years ago

Any news or fixes on this issue?

droopanu commented 5 years ago

It's fixed in 0.93 for me

delete1234 commented 5 years ago

Nothing new for me. I'm on latest. Running cameras through blueiris.. 20 hours or so after reboot the stream hangs. Just loops the same clip over and over. Reboot and its fixed...and the loop again.. Annoying.

jyrki69 commented 5 years ago

Same issue here running 0.96.5. Stream running for about 20 hours before it hangs. Reboot fixes it for another 20 hours or so.

This didn't happen when my cameras was setup with platform: mjpg, but occured when I changed to platform: generic. Cameras running through Blue Iris.

fleshinachair commented 4 years ago

same issue for me too on latest hass.io

stale[bot] commented 4 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

germanotero commented 3 years ago

This is still an issue, I have several cameras, NEST and Unifi, and generic ones... and I get 20s delay on all of them