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
71.05k stars 29.72k forks source link

Stream unable to load rtsps video from Unifi camera #79039

Closed KitHubek closed 1 year ago

KitHubek commented 1 year ago

The problem

Errors at log

Iam using rtsp cam strem. My cam is Unifi cam intefrated with Unifi Protect

What version of Home Assistant Core has the issue?

2022.9.6

What was the last working version of Home Assistant Core?

i dont remember

What type of installation are you running?

Home Assistant OS

Integration causing the issue

STREAM

Link to integration documentation on our website

https://www.home-assistant.io/integrations/stream

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.stream.stream.camera.mycam_2
Source: components/stream/__init__.py:416
Integration: Stream (documentation, issues)
First occurred: 23 września 2022 14:58:18 (124 occurrences)
Last logged: 18:55:48

Error from stream worker: Error demuxing stream: [Errno 5] I/O error: 'rtsps://IP.AD.DR.ESS:7441/udjdidudj?enableSrtp'; last error log: [tls] The specified session has been invalidated for some reason.
Error from stream worker: Error opening stream (INVALIDDATA, Invalid data found when processing input) rtsps://IP.AD.DR.ESS:7441/udjdidudj?enableSrtp
Error from stream worker: Error demuxing stream while finding first packet: [Errno 5] I/O error: 'rtsps://IP.AD.DR.ESS:7441/udjdidudj?enableSrtp'; last error log: [tls] The specified session has been invalidated for some reason.
Error from stream worker: Stream has no video

Additional information

No response

homeassistant commented 1 year ago

stream documentation stream source (message by IssueLinks)


Hey there @hunterjm, @uvjustin, @allenporter, mind taking a look at this issue as it has been labeled with an integration (stream) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

oyvindhauge commented 1 year ago

I have the same issue. Since I just replaced my UNVR I am not certain when it appeared, but it must be after October 5th. I am running supervised on Ubuntu. Error messages have appeared several hundred times per camera.

Edit: the same video stream work with Frigate, however I had to turn of audio due to some multiplex issue some time back.

uvjustin commented 1 year ago

@AngellusMortis Have you seen this issue before?

AngellusMortis commented 1 year ago

I get occasional stream errors pretty consistently. However, since it is background streaming like 10 cameras at once 24/7, occasional network errors seem pretty expected to me. They have never stopped the cameras from working for me.

The only issue I have is that a lot of times they buffer for the first few segments in Lovelace, but I assume that is a frontend issue.

uvjustin commented 1 year ago

Have you seen any errors from TLS / RTSPS?

garry0garry commented 1 year ago

Who is calling the h264Preview_01_sub thread? I can't find it in settings.

Logger: homeassistant.components.stream.stream.camera.cam11
Source: components/stream/__init__.py:428
Integration: Stream (documentation, issues)
First occurred: 09:51:10 (2 occurrences)
Last logged: 09:51:26

Error from stream worker: Error demuxing stream: [Errno 110] Operation timed out: 'rtsp://****:****@192.168.50.27:554/h264Preview_01_sub'; last error log: [mp4] Application provided duration: -900 / timestamp: 232162930 is out of range for mov/mp4 format
Error from stream worker: Error opening stream (INVALIDDATA, Invalid data found when processing input) rtsp://****:****@192.168.50.27:554/h264Preview_01_sub
garry0garry commented 1 year ago

HA 2022.11.2

Logger: root
Source: components/stream/worker.py:261
First occurred: 09:51:50 (1 occurrences)
Last logged: 09:51:50

Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 418, in _run_worker
    stream_worker(
  File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 598, in stream_worker
    muxer.mux_packet(packet)
  File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 261, in mux_packet
    self._av_output.mux(packet)
  File "av/container/output.pyx", line 212, in av.container.output.OutputContainer.mux
  File "av/container/output.pyx", line 233, in av.container.output.OutputContainer.mux_one
  File "av/container/core.pyx", line 292, in av.container.core.Container.err_check
  File "av/error.pyx", line 336, in av.error.err_check
av.error.PermissionError: [Errno 1] Operation not permitted: '<none>'; last error log: [mp4] Malformed AAC bitstream detected: use the audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)
uvjustin commented 1 year ago

Who is calling the h264Preview_01_sub thread? I can't find it in settings.

Logger: homeassistant.components.stream.stream.camera.cam11
Source: components/stream/__init__.py:428
Integration: Stream (documentation, issues)
First occurred: 09:51:10 (2 occurrences)
Last logged: 09:51:26

Error from stream worker: Error demuxing stream: [Errno 110] Operation timed out: 'rtsp://****:****@192.168.50.27:554/h264Preview_01_sub'; last error log: [mp4] Application provided duration: -900 / timestamp: 232162930 is out of range for mov/mp4 format
Error from stream worker: Error opening stream (INVALIDDATA, Invalid data found when processing input) rtsp://****:****@192.168.50.27:554/h264Preview_01_sub

Although the error message is similar, this is unrelated to the original issue. Along with their other limitations, Reolink cameras have buggy RTSP implementations. Try using RTMP instead. If that doesn't work, please open a new issue.

uvjustin commented 1 year ago

Have you seen any errors from TLS / RTSPS?

@AngellusMortis I don't have any RTSPS feeds to test on, so it's hard for me to track this down. I think Unifi cams are the main cameras that use RTSPS. Does the stream component work with RTSPS on your end?

AngellusMortis commented 1 year ago

I get the random network errors, but they generally do not persist.

I did just get the error that is in the OP really badly on UniFi OS v3.0.10 and UniFi Protect v2.6.16, but those are both Early Access versions and I just updated/rebooted my NVR and they went away (we have explicit docs for UniFi Protect that Early Access versions are not supported).

uvjustin commented 1 year ago

Thanks for the info. Since these errors seem to be resolved by a UniFi update, this seems more of an issue from UniFi rather than from HA. @KitHubek @oyvindhauge Which version of UniFi Protect are you running? Try updating to see if it resolves your issue.

home-assistant[bot] commented 1 year ago

Hey there @briis, @bdraco, mind taking a look at this issue as it has been labeled with an integration (unifiprotect) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `unifiprotect` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign unifiprotect` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


unifiprotect documentation unifiprotect source (message by IssueLinks)

oyvindhauge commented 1 year ago

Thanks for the info. Since these errors seem to be resolved by a UniFi update, this seems more of an issue from UniFi rather than from HA. @KitHubek @oyvindhauge Which version of UniFi Protect are you running? Try updating to see if it resolves your issue.

I am currently running UniFi OS UNVR 2.5.11 and Protect 2.2.6, and I am pretty sure I ran the same version when I saw the error messages. Due to all the errors, I stopped using the Protect cameras and rather started using the Firgate stream from the same camera. I did unfortunately just restart my installation and thus purged the logs (been away for a few days). I currently do not see these error messages, but the server has just been up a few mins. I will update my message later if the come back.

AngellusMortis commented 1 year ago

The only thing I can really tell you to do is restart the UniFi console. The issue should hopefully go away (it did on my console). I think there was a TLS issue on the console's side that cause this to happen recently.

There is nothing that can be done from the Home Assistant side.

AngellusMortis commented 1 year ago

@home-assistant close