twrecked / hass-aarlo

Asynchronous Arlo Component for Home Assistant
GNU Lesser General Public License v3.0
388 stars 78 forks source link

Streaming works for live but not library #489

Open jayofdoom opened 3 years ago

jayofdoom commented 3 years ago

Hey,

I'm using this integration along with the custom lovelace cards. In the lovelace cards, I have the library button enabled. I can click the library button and navigate the library, but when I click the video it does not play -- nor do I see any messages in the log about "Started stream"/"Stopped stream" like I do for the live streaming videos.

Do you have any suggestions? Happy to help troubleshoot this if you have any ideas.

-Jay

twrecked commented 3 years ago

The live stream and library use 2 different protocols. Can you tell me:

the type of computer you are trying this on? what exactly happens? does the screen change to show the video playback buttons and then nothing happens?

jayofdoom commented 3 years ago

This is a gentoo linux machine running homeassistant, with an install via venv. I have seen the previous posts and ensured I have av installed in the virtualenv.

First of all, when the issue occurs, the snapshot(?) representing the library entry comes up, the video controls come up and the progress bar moves while no sound plays and the snapshot remains static on the screen.

Secondly, I've isolated the problem -- my Arlo wired video doorbell has videos which play correctly out of the library. My other cameras, all Arlo Pro 3 + Arlo Pro 3 Floodlight cameras, have libraries the exhibit the bugged behavior described above.

If you want to point me to docs on enabling debug logging, I'm happy to take a look at the problem and see if I can work it out -- I'm extremely familiar with python (and package/dependency management), although not home assistant development specifically.

jayofdoom commented 3 years ago

I enabled debug mode after consulting the readme, there's some interesting behavior:

Upon opening the dashboard page containing the custom aarlo widgets, I see this:

Aug 27 03:28:09 hostname hass[5150]: 2021-08-27 03:28:09 DEBUG (MainThread) [custom_components.aarlo.camera] library+99
Aug 27 03:28:09 hostname hass[5150]: 2021-08-27 03:28:09 DEBUG (MainThread) [custom_components.aarlo.camera] library+99
Aug 27 03:28:09 hostname hass[5150]: 2021-08-27 03:28:09 DEBUG (MainThread) [custom_components.aarlo.camera] library+99
Aug 27 03:28:09 hostname hass[5150]: 2021-08-27 03:28:09 DEBUG (MainThread) [custom_components.aarlo.camera] library+99
Aug 27 03:28:09 hostname hass[5150]: 2021-08-27 03:28:09 DEBUG (MainThread) [custom_components.aarlo.camera] library+99
Aug 27 03:28:09 hostname hass[5150]: 2021-08-27 03:28:09 DEBUG (MainThread) [custom_components.aarlo.camera] library+99
Aug 27 03:28:09 hostname hass[5150]: 2021-08-27 03:28:09 DEBUG (MainThread) [custom_components.aarlo.camera] library+99
Aug 27 03:28:09 hostname hass[5150]: 2021-08-27 03:28:09 DEBUG (MainThread) [custom_components.aarlo.camera] library+99
Aug 27 03:28:09 hostname hass[5150]: 2021-08-27 03:28:09 DEBUG (MainThread) [custom_components.aarlo.camera] library+99
Aug 27 03:28:09 hostname hass[5150]: 2021-08-27 03:28:09 DEBUG (MainThread) [custom_components.aarlo.camera] library+99

This is when I click into the widget and attempt to view a video from the library. I'll note the lack of any logs about starting activity for the side_door camera. These logs print after waiting several seconds with no motion in the video and hitting t he stop button.

Aug 27 03:28:25 hostname hass[5150]: 2021-08-27 03:28:25 DEBUG (MainThread) [custom_components.aarlo.camera] stop_activity for side_door
Aug 27 03:28:25 hostname hass[5150]: 2021-08-27 03:28:25 DEBUG (SyncWorker_4) [pyaarlo] removing streaming activity state
Aug 27 03:28:25 hostname hass[5150]: 2021-08-27 03:28:25 DEBUG (SyncWorker_4) [pyaarlo] _event::idle::reqs='set()',local='set()',remote='set()'
Aug 27 03:28:25 hostname hass[5150]: 2021-08-27 03:28:25 DEBUG (ArloEventStream) [pyaarlo] sending cameras/SERIALNUM to SERIALNUM
Aug 27 03:28:25 hostname hass[5150]: 2021-08-27 03:28:25 DEBUG (ArloBackgroundWorker) [pyaarlo] Side door CAMERA got one cameras/SERIALNUM
Aug 27 03:28:25 hostname hass[5150]: 2021-08-27 03:28:25 DEBUG (ArloBackgroundWorker) [pyaarlo] removing streaming activity state 
Aug 27 03:28:25 hostname hass[5150]: 2021-08-27 03:28:25 DEBUG (ArloBackgroundWorker) [pyaarlo] _event::idle::reqs='set()',local='set()',remote='set()'
Aug 27 03:28:25 hostname hass[5150]: 2021-08-27 03:28:25 DEBUG (ArloBackgroundWorker) [pyaarlo] set:ArloCamera/SERIALNUM/activityState=idle
Aug 27 03:28:25 hostname hass[5150]: 2021-08-27 03:28:25 DEBUG (ArloBackgroundWorker) [custom_components.aarlo.switch] callback:Side door Snapshot:activityState:idle
Aug 27 03:28:25 hostname hass[5150]: 2021-08-27 03:28:25 DEBUG (ArloBackgroundWorker) [custom_components.aarlo.camera] callback:Side door:activityState:idle
Aug 27 03:28:33 hostname hass[5150]: 2021-08-27 03:28:33 DEBUG (ArloBackgroundWorker) [pyaarlo] pinging hub1
Aug 27 03:28:33 hostname hass[5150]: 2021-08-27 03:28:33 DEBUG (ArloBackgroundWorker) [pyaarlo] set:ArloBase/SERIALNUM/connectionState=available
Aug 27 03:28:33 hostname hass[5150]: 2021-08-27 03:28:33 DEBUG (ArloBackgroundWorker) [custom_components.aarlo.binary_sensor] callback:Connected hub1:connectionState:available

Hope this helps, Jay

twrecked commented 3 years ago

I thought this sound familiar: https://github.com/twrecked/lovelace-hass-aarlo/issues/40

It's to do with the codec 4K cameras are using in the library. I mentioned updating the documents but completely forgot to do it...

But if you want to play around some more....

aarlo:
  ...
  verbose_debug: True
2021-08-26 22:08:33 DEBUG (ArloBackgroundWorker) [pyaarlo] request-url=https://myapi.arlo.com/hmsweb/users/library
          {'contentType': 'video/mp4',

A couple of line below that you will have the video URL, you can paste that directly into the browser or use wget to retrieve it.

           'presignedContentUrl': 'https://arlos3-prod-z1.arlo.com/.../recordings/1630028049406.mp4?AWSAccessKeyId=XXXXXXXXXXXX&Expires=1630116513&Signature=XXXXXXXXXXXX',

The Lovelace card bypasses Home Assistant when streaming video and passes that URL directly to a html 5 video element.

jayofdoom commented 3 years ago

Even with verbose_debug: True, I see no output whatsoever from the logs when I go to play a library video. It only prints output after it stops, and never prints anything like you're referring to. Even in the happy path with the doorbell camera, I don't get any output like you're indicating in the log.

jayofdoom commented 3 years ago

Going to ensure x265/HEVC codecs are installed on the hass server and client, see if that makes a difference per the linked threads.

jayofdoom commented 3 years ago

Yeah; I think this is a dupe of https://github.com/twrecked/hass-aarlo/issues/308 -- but I personally have not been able to find a combination of user_agent and play_direct settings that make it work.

However, even with user_agent: linux set, I end up with nothing working but sound in the videos. I'm leaving my config as-is (play_direct unset; user_agent unset) as that works with all my cameras for live streaming, even if library streaming is broken.

My platforms I tested on:

I can also confirm the workaround from one of the previous issues (which I can't find now) of turning on Auto Pan & Zoom does not appear to be functional in my case either -- I have devices in both on and off state and none of their libraries work.

If there's anything I can do to help resolve this issue let me know. Thanks so much for the work for making so much of this work without a proper API from arlo!

-Jay

twrecked commented 3 years ago

Thanks for the testing. User agent and play direct don't affect library recordings, they only control how we live stream.

Have you tried turning on Pan and Zoom and creating a new recording? It might not make a difference to old recordings.

One more thing to try. Can you play the recordings from the Arlo web interface? If you can then there might be a setting we can pass when asking for the library or the recording that gives us a supported version.

edit: You might not see debug when playing a library, the lovelace cards requests the video list then connects directly to Arlo.

jayofdoom commented 3 years ago

When attempting to play via Firefox in the web interface:

This video is not able to play in your browser.
Please download to view. 

This includes videos recorded with and without pan and zoom enabled, and some videos that did not have the "2K" tag. Front door (doorbell camera) videos work from the library just as in the integration.l

I guess the only option then would be doing some kind of transcoding?