-
Notifications
You must be signed in to change notification settings - Fork 78
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
Stream not working on any cameras #151
Comments
What kind of cameras are you using? |
I'm using a Video Doorbell, two Q's, and I think I just have regular Arlo Pro cameras for the outside. 6 cameras in total. I've done some more experimenting and it seems like sometimes it will show the last recorded motion event, but I haven't gotten it to stream yet. |
I think this needs fixing with the stream component. I'll see if somebody is willing to lend me an Arlo Q camera to test. |
Hi! Just adding that I've similars issues with Arlo Q and livestream:
|
Is anybody comfortable with debugging from Chrome? I want to see if the command to start streaming is different for Q cameras. Basically:
The debug window will be filling up. Click on the
Look for a packet in the In the In the For my cameras they look something like this:
and
|
Here's for a Arlo Q camera:
Seems like there's a little difference in the url, vzwow92 for you and vzwow52 for me. |
Thanks for the quick reply. Which OS was that from? And yes, there was no significant difference at all. I was hoping there was something then I could have added it to the code for Q cameras and see if it fixed the problem. Another option is a different user agent. This is a long shot but might work with the Arlo Q cameras. Add this to your config and restart HA. aarlo:
user_agent: linux |
The previous info was from macOS 10.15.3 (Chrome 80.0.3987.87). With your line, I ain't got the error, but the stream doesn't work either.
|
Now it gets fun - we need to check if the stream is actually readable by the
Luckily we can jerry-rig (jury-rig?) most of this. This patch will request Arlo start the stream but stop the URL being passed back to the diff --git a/custom_components/aarlo/pyaarlo/camera.py b/custom_components/aarlo/pyaarlo/camera.py
index 591f331..d8c123e 100644
--- a/custom_components/aarlo/pyaarlo/camera.py
+++ b/custom_components/aarlo/pyaarlo/camera.py
@@ -475,7 +475,7 @@ class ArloCamera(ArloChildDevice):
return None
url = reply['url'].replace("rtsp://", "rtsps://")
self._arlo.debug('url={}'.format(url))
- return url
+ return None
def get_video(self):
video = self.last_video Make sure debug is turned on. Set logger:
default: info
logs:
pyaarlo: debug Restart your home-assistant. Cut and paste the following shell script into your home-assistant configuration directory, call it #!/bin/bash
#
URL=$(grep url= home-assistant.log | tail -1 | cut -f 2- -d =)
if [[ -z "${URL}" ]]; then
echo "no url"
exit 1
fi
echo $URL
mkdir s 2>/dev/null
ffmpeg -i ${URL} \
-fflags flush_packets -max_delay 2 -flags -global_header \
-hls_time 2 -hls_list_size 3 -vcodec copy -y s/video.m3u8 Enter your home-assistant environment and make stream executable. The first time you run it there won't be a stream so it will do nothing. I'm using a docker so my commands goes like this: $ docker exec -it home-assistant bash
bash-5.0# chmod +x stream
bash-5.0# ./stream
no url For a bash-5.0# ./stream
rtsps://vzwow117-z1-prod.ar.arlo.com:443/vzmodulelive/XXXXXXXXXX_1582255723060?egressToken=fcf7187b_54b0_4f3a_9ea1_0a80943e00f0&userAgent=iOS&cameraId=XXXXXXXXX_F23_1582255723060
ffmpeg -fflags nobuffer -rtsp_transport tcp -i rtsps://vzwow117-z1-prod.ar.arlo.com:443/vzmodulelive/XXXXXXXXXX_1582255723060?egressToken=fcf7187b_54b0_4f3a_9ea1_0a80943e00f0&userAgent=iOS&cameraId=XXXXXXXXXX_1582255723060 -vsync 0 -copyts -vcodec copy -movflags frag_keyframe+empty_moov -an -hls_flags delete_segments+append_list -f segment -segment_list_flags live -segment_time 1 -segment_list_size 3 -segment_format mpegts -segment_list s/index.m3u8 -segment_list_type m3u8 -segment_list_entry_prefix /stream/ s/%d.ts
ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.3.0 (Alpine 8.3.0)
configuration: --prefix=/usr --enable-avresample --enable-avfilter --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --disable-stripping --disable-static --disable-librtmp --enable-vaapi --enable-vdpau --enable-libopus --disable-debug
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, rtsp, from 'rtsps://vzwow117-z1-prod.ar.arlo.com:443/vzmodulelive/XXXXXXX3_1582255723060?egressToken=fcf7187b_54b0_4f3a_9ea1_0a80943e00f0&userAgent=iOS&cameraId=XXXXXXXXXX_1582255723060':
Metadata:
title : XXXXXXXXXX_1582255723060
Duration: N/A, start: 0.320000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 16000 Hz, mono, fltp
Stream #0:1: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1920x1072, 15 fps, 15 tbr, 90k tbn, 30 tbc
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[hls @ 0x55de5a79ed00] Opening 's/video0.ts' for writing
Output #0, hls, to 's/video.m3u8':
Metadata:
title : XXXXXXXXXX_1582255723060
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1920x1072, q=2-31, 15 fps, 15 tbr, 90k tbn, 15 tbc
Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp, 69 kb/s
Metadata:
encoder : Lavc58.35.100 aac
[hls @ 0x55de5a79ed00] Non-monotonous DTS in output stream 0:0; previous: 50970, current: 21060; changing to 50971. This may result in incorrect timestamps in the output file.
[hls @ 0x55de5a79ed00] Non-monotonous DTS in output stream 0:0; previous: 50971, current: 27000; changing to 50972. This may result in incorrect timestamps in the output file.
[hls @ 0x55de5a79ed00] Non-monotonous DTS in output stream 0:0; previous: 50972, current: 33030; changing to 50973. This may result in incorrect timestamps in the output file.
[hls @ 0x55de5a79ed00] Non-monotonous DTS in output stream 0:0; previous: 50973, current: 38970; changing to 50974. This may result in incorrect timestamps in the output file.
[hls @ 0x55de5a79ed00] Non-monotonous DTS in output stream 0:0; previous: 50974, current: 45000; changing to 50975. This may result in incorrect timestamps in the output file.
[hls @ 0x55de5a79ed00] Non-monotonous DTS in output stream 0:0; previous: 50975, current: 50940; changing to 50976. This may result in incorrect timestamps in the output file.
[hls @ 0x55de5a79ed00] Opening 's/video1.ts' for writing
[hls @ 0x55de5a79ed00] Cannot use rename on non file protocol, this may lead to races and temporary partial files
[hls @ 0x55de5a79ed00] Opening 's/video2.ts' for writingrate=N/A speed=1.97x
[hls @ 0x55de5a79ed00] Opening 's/video3.ts' for writingrate=N/A speed=1.48x
[hls @ 0x55de5a79ed00] Opening 's/video4.ts' for writingrate=N/A speed=1.43x
frame= 145 fps= 19 q=-1.0 Lsize=N/A time=00:00:10.28 bitrate=N/A speed=1.35x
video:1035kB audio:67kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[aac @ 0x55de5a77fc00] Qavg: 65523.383
Exiting normally, received signal 2. |
This diff might be easier to try. It will turn on debugging to the Python av component. You have to make this change inside the homeassistant code. diff --git a/homeassistant/components/stream/__init__.py b/homeassistant/components/stream/__init__.py
index d88f90a83..308dc5b77 100644
--- a/homeassistant/components/stream/__init__.py
+++ b/homeassistant/components/stream/__init__.py
@@ -37,7 +37,9 @@ SERVICE_RECORD_SCHEMA = STREAM_SERVICE_SCHEMA.extend(
}
)
# Set log level to error for libav
-logging.getLogger("libav").setLevel(logging.ERROR)
+logging.getLogger("libav").setLevel(logging.DEBUG)
+logging.getLogger().setLevel(5)
+
@bind_hass Restart homeassistant, start a stream and you'll see something like this in the logging which might help us work out what is going wrong:
|
Only have a hassio setup, but taking the stream url and trying on my host with:
|
This is interesting: tchellomello/python-arlo#8 So when I make a request to Changing the protocol then to |
I already fix up the And in the previous post you're getting a |
When I used the In the end, the problem with my Q cameras came down to this: Changing that to not throw an error and to just ignore the packet gets me a stream in the UI. Also found some earlier discussion about this here: home-assistant/core#22840 (comment) Haven't contributed to HA so far so don't have a local setup yet but will see if we can get that change into there. |
That's great you got it going. I was leaning towards the problem being in the And many thanks for your work here. |
Does this patch look something similar to how you get it working? I just ignore the first 10 dts errors. --- /usr/src/homeassistant.orig/homeassistant/components/stream/worker.py
+++ /usr/src/homeassistant/homeassistant/components/stream/worker.py
@@ -66,6 +66,8 @@
first_pts = 0
# The decoder timestamp of the latest packet we processed
last_dts = None
+ # Allow some no dts packets in
+ no_dts = 0
while not quit_event.is_set():
try:
@@ -73,8 +75,13 @@
if packet.dts is None:
if first_packet:
continue
+ ++no_dts
+ if no_dts < 10:
+ continue
# If we get a "flushing" packet, the stream is done
- raise StopIteration("No dts in packet")
+ raise StopIteration("No dts in packet too often")
+ else:
+ no_dts = 0
except (av.AVError, StopIteration) as ex:
# End of stream, clear listeners and stop thread
for fmt, _ in outputs.items(): |
For the quick test I didn't have a counter, but this seems fine! |
Does the latest update fix the arlo q live stream if it does. ive updated and its doing the same thing no live stream. |
I can't fix it from inside the Aarlo component you need to patch the You can copy the patch in the previous+2 post into a file called |
Do i need to create that file? and then just copy the patch from the above comment from you into that file. |
For now, yes. I need to know where the file is and the config directory is the easiest to locate. I'll work on a nicer way of doing this. |
if it goes wrong anyway to revert the stream componment back to how it was? will a snap shot work or? |
This is a reverse of the diff, copy this to --- /usr/src/homeassistant/homeassistant/components/stream/worker.py
+++ /usr/src/homeassistant.orig/homeassistant/components/stream/worker.py
@@ -66,8 +66,6 @@
first_pts = 0
# The decoder timestamp of the latest packet we processed
last_dts = None
- # Allow some no dts packets in
- no_dts = 0
while not quit_event.is_set():
try:
@@ -75,13 +73,8 @@
if packet.dts is None:
if first_packet:
continue
- ++no_dts
- if no_dts < 10:
- continue
# If we get a "flushing" packet, the stream is done
+ raise StopIteration("No dts in packet")
- raise StopIteration("No dts in packet too often")
- else:
- no_dts = 0
except (av.AVError, StopIteration) as ex:
# End of stream, clear listeners and stop thread
for fmt, _ in outputs.items(): |
im using docker on ubuntu 18.04 ive not tried it yet i just wanted to know how to get back to original if it didnt work. does this patch fix it to allow live streaming for a q on the custom aarlo card i haven't miss read have i? do you think this will be easy to fix in the future or will this patch be required anyway? |
With a docker you can just throw the docker instance away and start again. The patch should allow Arlo Q cameras to stream. I don't have one so I'm relying on people with Q cameras to let me know if it works. It is a simple fix but looking at the comments in the stream threads in home-assistant.io it's been known about for a while. |
@twrecked I can give this a shot. Are you saying to literally copy that diff below (with the pluses and minuses) into that location? --- /usr/src/homeassistant.orig/homeassistant/components/stream/worker.py
+++ /usr/src/homeassistant/homeassistant/components/stream/worker.py
@@ -66,6 +66,8 @@
first_pts = 0
# The decoder timestamp of the latest packet we processed
last_dts = None
+ # Allow some no dts packets in
+ no_dts = 0
while not quit_event.is_set():
try:
@@ -73,8 +75,13 @@
if packet.dts is None:
if first_packet:
continue
+ ++no_dts
+ if no_dts < 10:
+ continue
# If we get a "flushing" packet, the stream is done
- raise StopIteration("No dts in packet")
+ raise StopIteration("No dts in packet too often")
+ else:
+ no_dts = 0
except (av.AVError, StopIteration) as ex:
# End of stream, clear listeners and stop thread
for fmt, _ in outputs.items(): |
Okay, so I gave it a go, and the results don't look good. On first restart, I get the log to show up (It seems it logs this as an error even though it's really an info log):
After second restart, trying to stream from the aarlo lovelace card makes this show up in the logs (same stuff from before):
I want to say this is probably because the patching code in the component is not finding the right place to apply the patch. I'm running homeassistant through docker on an Ubuntu VM, and I don't seem to have a |
The But, it should work on a docker, you'll have problems with virtualenv but docker has a fixed source location. Did you check from inside the docker? $ docker exec -it your-docker-instance-name bash
# cd /usr/src
# ls I'll work on generating a PR for the stream component. But it'll take me a couple of days to do it. |
I would love to help but have no idea where to start :( |
I have prepared this change: Skipping a single packet without dts is sufficient for my Arlo Qs to stream correctly (and somehow psychologically skipping 1 bad packet feels less kludgey than skipping a const 10!). @twrecked you appear to be working on this issue, and you know this area much better than I. Would you like me to submit this as a PR, or should I hold off (e.g. if you have a better fix in mind)? |
@dermotduffy If you could submit it that would be great. I don't have any of the cameras streaming doesn't work on so didn't have a way of testing before I submitted it. |
* Allow 1 packet without dts. See twrecked/hass-aarlo#151 . * Reset boolean once a packet with dts is found. * Fix no-else-continue lint error.
It now looks like Arlo has changed their streaming. I connected to their website today and the cameras are streaming in HLS directly from Arlo. This probably means we can bypass the Can somebody with Ultra cameras confirm this? You will need to open a debug console (CTRL + SHIFT + T in Chrome) and start a stream. Look for m4s packets. |
I have a fix but it needs trying. As I mentioned above, it looks like Arlo is moving away from
aarlo:
user_agent: linux
play_direct: true Now try streaming. One bonus, the audio now works. To undo, just remove the If somebody with ultra cameras could try this it would be great. |
Nice, works great with my Arlo Q cameras! |
Hurray -- it's a proper fix for streaming from Q cameras that doesn't rely on arbitrarily skipping packets without dts... Confirmed streaming working on Arlo Qs and Pro 2s. |
@dermotduffy Yeah, I just happened to notice the web interface was using mpeg-dash the other day. The problem is, the |
@twrecked, this doesn't seem to have an affect on the Arlo Pro 3 cameras. I can live stream just like I could before without audio. And anything that is recorded I can playback but will get no video, but I will get audio. |
@ssilence5 But you should get audio on the live stream. Can you check that on the web interface? We may need to add some parameters to the setup. |
@twrecked Playback doesn't work at all on the Arlo portal for most browsers. I have linked this to the fact that the format is in HEVC (Arlo Pro 3 is 2K). I did get it to work in either Edge or IE, can't remember which. Live streaming works fine in the Arlo portal with both Video and Audio. One other note, I must not have had my volume up on my computer, because Live Streaming in HASS has both Audio and Video. Playback is still audio only (however playback works fine on my iPhone using the Home Assistant app). I believe this still links back to most modern browsers don't support HEVC. |
@ssilence5 See this, somebody tweaked a setting and got their library to work. |
Sorry, but I don't understood something: In Configuration im add line: Also im added line
But this is don't work |
@Kras-s-savchiK what kind of cameras do you have? I can't really tell from you config what is wrong because the indentation is funny. Can you try re-posting with back ticks - see here - for formatting. |
Im use Arlo Pro 2 In Configuration im add line: user_agent: linux and right now I have this: aarlo:
username: ***
password: ***
refresh_devices_every: 2
stream_timeout: 240
user_agent: linux Also im added line play_direct: true to aarlo-glance cards. battery_id: sensor.entrance_camera_battery
entity: camera.aarlo_door
image_click: play
play_direct: true
name: Door
show:
- snapshot
- battery_level
- signal_strength
- captured_today
stream: null
top_date: false
top_status: false
top_title: false
type: 'custom:aarlo-glance' But this is don't work stream: null But video and audio don't work again Thanks for answering |
Thanks. The I have those cameras and they are working for me. Can you capture some debug? I want to make sure the stream is starting. What OS and browser are you using? logger:
default: info
logs:
custom_components.aarlo: debug
custom_components.aarlo.camera: debug
pyaarlo: debug Start your stream and look in |
Im using Safari (Mac and iPhone/iPad) and iOS App media_player:
- platform: aarlo
ffmpeg:
stream: Maybe, them broke to play video and sound? |
I find some issue - I just push on 3 point in right upper corner and do reload resources And I delete user_agent: linux and right now my cameras playing, but without sound. ( |
Can you check here and see if it lines up with your experience. I don't have a Mac so can't readily test that. |
I have v0.6.8 of this integration installed through HACS in a virtualenv and while all of the sensors and snapshots work fine when I use the lovelace card the stream shows up but doesn't actually move at all, while the log reports errors:
Occasionally, I also get a
2020-01-18 13:28:00 WARNING (ArloEventStream) [pyaarlo] general exception must be str, not NoneType
which doesn't seem to be related to any action I take.I've followed the streaming instructions in the bottom of the readme, here are the relevant parts of my config:
Let me know if I need to raise my logging level or anything.
The text was updated successfully, but these errors were encountered: