Closed JaHaa88 closed 2 years ago
Hey there @hunterjm, mind taking a look at this issue as its been labeled with an integration (onvif
) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)
I'm having the same issue - hassio on a RPI4 in my case with two 810A cameras. I saw errors using the Reolink integration and added some lovelace cards which do display the static periodic images fine. Whilst hunting down another problem I saw errors in the log opening the RTMP stream and switched to RTSP with no luck - the live previews don't work still but the errors in my log have now changed:
2021-02-27 07:59:41 ERROR (Recorder) [libav.mp4] Malformed AAC bitstream detected: use the audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg) 2021-02-27 07:59:41 ERROR (Recorder) [root] Uncaught exception Traceback (most recent call last): File "av/container/output.pyx", line 23, in av.container.output.close_output File "av/container/core.pyx", line 257, in av.container.core.Container.err_check File "av/error.pyx", line 323, in av.error.err_check File "av/container/pyio.pyx", line 39, in av.container.pyio.pyio_write_gil ValueError: I/O operation on closed file. 2021-02-27 07:59:49 ERROR (stream_worker) [libav.mp4] Malformed AAC bitstream detected: use the audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg) 2021-02-27 07:59:49 ERROR (stream_worker) [homeassistant.components.stream.worker] Stream connection failed: rtsp://homeassistant:password@192.168.1.41:554/h264Preview_01_sub Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 56, in stream_worker _stream_worker_internal(hass, stream, quit_event) File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 293, in _stream_worker_internal mux_video_packet(packet) # mutates packet timestamps File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 213, in mux_video_packet buffer.output.mux(packet) File "av/container/output.pyx", line 204, in av.container.output.OutputContainer.mux File "av/container/output.pyx", line 227, in av.container.output.OutputContainer.mux_one File "av/container/core.pyx", line 257, 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: ''; 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)
I then switched back to RTMP with the sub (and not main) stream and now have working previews. As I understand it the main stream is H265 and the sub is H264.
I'm still seeing errors in the log - but they're referring to RTSP. I can see both cameras live.. Weird. Gonna reboot the server..
Core 2021.2.3, HA OS 5,12, Integration: https://github.com/fwestenberg/reolink_dev
Rebooted, still got live streams in lovelace. No errors in the log this time - will keep an eye on it.
So for now RTMP + stream 'sub' - works!
No luck for me. I tried the RTMP stream with the generic component with no success.
After tinkering around i found that disabling the stream component (commenting out in config) all camera components started to work. I now can see the live stream (main and sub) in the Onvif integration, generic and ffmpeg component.
So the stream component is clear causing the above mentioned errors.
Only the generic component does show the main stream in 4k fluent the other components bring the entire server to a stand still. But this however is unrelated i think and probable due the the ffmpeg handling of H265 streams.
Just saw this - it's essentially the same issue as #41932. The problem is coming from the audio stream - due to the options we use, the bitstream filter to correct the audio track is not automatically applied, and we currently have no way to apply it using the current library. We were able to work around it with other cameras by disabling the audio stream either by disabling it outright or selecting an unusable codec, but admittedly this is kind of a hack. I will see if there is a way we can detect these problematic audio streams and disable them automatically so we don't have to resort to adding a separate option to disable the audio streams manually. Can someone run this code snippet on a problematic camera feed and tell me what it prints out?
import av
input_container=av.open("rtsp://yourcamerasrtspurl")
audio_stream=input_container.streams.audio[0]
i=0
for packet in input_container.demux(audio_stream):
if packet.size > 2:
packet_view=memoryview(packet)
print(packet_view[0], packet_view[1])
if i > 5:
break
i+=1
input_container.close()
Hi uvjustin,
Thanks for the feedback. I have tried to disable de audio on the camera itself with no luck.
I can surely run the code. But i have no idea how >.<.
stream documentation stream source (message by IssueLinks)
From the bash shell in your container, type "python3
". That should bring up the python interpreter. Then run the code snippet I pasted above, filling in your rtsp url in place of the yourcamerasrtspurl
. To exit the interpreter, just type exit()
i get this syntax error:
`
audio_stream=input_container.streams.audio[0]
i=0 for packet in input_container.demux(audio_stream): ... if packet.size > 2: ... packet_view=memoryview(packet) ... print(packet_view[0], packet_view[1]) ... if i > 5: ... break ... i+=1 ... input_container.close() File "
", line 8 input_container.close() ^ SyntaxError: invalid syntax `
i have done this is the 'execute bash' in portainer.
The indentations/spaces are important in python - the body of the for statement and the if statement have to be indented consistently. Can you try again?
Sorry, i can't get it to work.
Thanks for the screenshot. Add one extra blank line before the input_container.close()
line.
Than i get this:
Great, I think that might be enough for me to work on a fix. Thanks
okee great! thank you for the support.
I am seeing the same behaviour with a Reolink RLC-510WA on 2021.4.3. Is this fixed in 2021.4? And if not, when is it likely to arrive? Apologies if this is a stupid question, I'm not sure how to tell from Github.
2021-04-10 16:04:33 INFO (MainThread) [homeassistant.components.stream] Started stream: rtsp://****:****@192.168.1.22:554/h264Preview_01_sub
2021-04-10 16:04:39 ERROR (stream_worker) [libav.mp4] Malformed AAC bitstream detected: use the audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)
2021-04-10 16:04:39 ERROR (stream_worker) [root] Uncaught thread exception
Traceback (most recent call last):
File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 203, in _run_worker
stream_worker(self.source, self.options, segment_buffer, self._thread_quit)
File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 288, in stream_worker
segment_buffer.mux_packet(packet)
File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 99, in mux_packet
self._stream_buffer.output.mux(packet)
File "av/container/output.pyx", line 204, in av.container.output.OutputContainer.mux
File "av/container/output.pyx", line 227, in av.container.output.OutputContainer.mux_one
File "av/container/core.pyx", line 258, 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)
I am having the same issue with RLC-810A. Cannot get the stream working at all, even with audio disabled. Would be great to see some movement on this.
I was able to get this working with the Reolink HAC component as noted above: https://github.com/fwestenberg/reolink_dev
A google search shows there seems to be some kind of problem with Reolink's RTSP implementation and ffmpeg. There are documented problems on several video projects. A common workaround is to use the RTMP feed. Try using the RTMP feed in stream_source
and see if you still have the same issue. The urls for main and sub stream look something like:
rtmp://192.168.1.100/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=password
rtmp://192.168.1.100/bcs/channel0_sub.bcs?channel=0&stream=0&user=admin&password=password
I tried all sorts of combinations (different streams) between RTSP and RTMP without luck. The only thing I could get working was https://github.com/fwestenberg/reolink_dev. Glad to see this is re-opened and going to get another look and potential fix.
What version of HA are you on? Make sure you are on 2021.4 or later. Can you post the errors in your log when using the RTMP stream?
I am on the latest, 2021.5.1. Yeah, I can get you the logs later on today.
In 2021.6.3 most of the audio stream are not working, in VLC the same audio streams are working
FosCam R2 via Shinobi Video (ceoverted to AAC) - not working:
Dahua via Shinobi Video (converted to AAC) - working:
In 2021.6.3 most of the audio stream are not working, in VLC the same audio streams are working
FosCam R2 via Shinobi Video (ceoverted to AAC) - not working:
Dahua via Shinobi Video (converted to AAC) - working:
Audio support in the stream component is limited. Some of this is codec related (only mp3 and aac are supported), and some of it is pyav (the library we use to access ffmpeg) related (some aac streams require bitstream filters which are not enabled in pyav).
@krushmike Did you get a chance to capture your logs?
Hi! I also have a similar problem. I run the docker image: homeassistant/raspberrypi4-homeassistant:latest (pulled today) on a rpi4.
When trying to stream video from my Reolink RLC-810A i get the following error. (I get alot if different errors but this seems to be one oft he first to appear.
I have tried all combinations of rtsp/rtmp, mainstream substream i could think of. Still not been able to stream från the camera. (works just fine in VLC).
2021-07-30 16:10:46 INFO (MainThread) [homeassistant.components.stream] Started stream: rtsp://****:****@172.25.0.102:554/
2021-07-30 16:10:47 WARNING (stream_worker) [homeassistant.components.stream.worker] ADTS AAC detected - disabling audio stream
2021-07-30 16:10:47 ERROR (stream_worker) [libav.mp4] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 90179 >= 90179
2021-07-30 16:10:47 ERROR (stream_worker) [root] Uncaught thread exception
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.9/threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 213, in _run_worker
stream_worker(self.source, self.options, segment_buffer, self._thread_quit)
File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 384, in stream_worker
segment_buffer.mux_packet(packet)
File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 132, in mux_packet
self._av_output.mux(packet)
File "av/container/output.pyx", line 204, in av.container.output.OutputContainer.mux
File "av/container/output.pyx", line 227, in av.container.output.OutputContainer.mux_one
File "av/container/core.pyx", line 258, in av.container.core.Container.err_check
File "av/error.pyx", line 336, in av.error.err_check
av.error.ValueError: [Errno 22] Invalid argument: '<none>'; last error log: [mp4] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 90179 >= 90179
Same issue with Reolink 822A - connected via the Reolink NVR. Updated still-picture in Lovelace, but not working on either RTSP or RTMP. I've tried both the HACS Reolink_dev and the OVNIF. One of the integrations seem to work with Live stream. Firmware updated, running on latest 2021.8.4 version of HA. Please suggest or help. Thanks in advance :)
@PRebs64 when I upgraded to the beta 2021.8.0b5 it resolved all my problems. Im not sure if the changes have been merged into the stable releases. See #53761
Thanks AnkerStål - I've now installed core version 2021.8.0b5 and tried to add the camera's one by one again. Sadly enough it is still the same issue. Pre-view (still picture) is updated, but streaming does not start up. NVR firmware is up to date. As info, under Supervisor it says, that latest version is 2021.8.4 (which I was on b4). Any other suggestions or info I can provide to move closer to a resolution/work around?
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 has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
The problem
Unable to get a Reolink camera's to work in HA. There are multiple errors in the log which boil down too: Malformed AAC bitstream
The error looks very similar to the following issue: Stream - Malformed AAC bitstream detected #39848 The proposed solution is not working for me: Disable audio for HLS or mpegts input #39906
I have tried the ONVIF integration as well as the generic and ffmpeg components. All results in the same errors. Both the sub (H264) and main (H265) streams have this issue.
This issue is also mentioned by other people on the forum: https://community.home-assistant.io/t/rtsp-camera-stream-not-working-reolink-rlc-810a/279976
What is version of Home Assistant Core has the issue?
2021.2.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
ONVIF, camera
Link to integration documentation on our website
https://www.home-assistant.io/integrations/onvif/
Example YAML snippet
Anything in the logs that might be useful for us?
Installation is running in Docker on a Ubuntu 18.04 LTS. IP cam is in another VLAN but is reachable and working with VLC.
Stream, ffmpeg and camera integrations are added to the configuration yaml.
i have tried to add the suggested '-bsf:a aac_adtstoasc' to the ONVIF options arguments and to the extra_arguments in the ffmpeg component with no luck.