Brandawg93 / homebridge-nest-cam

View your Nest cams in HomeKit using Homebridge.
https://www.npmjs.com/package/homebridge-nest-cam
GNU General Public License v3.0
212 stars 27 forks source link

[Bug]: Streaming video does not show on the iOS Home app #456

Closed abains closed 2 years ago

abains commented 2 years ago

Describe the bug

In Homebridge the camera view is shown on the dashboard and updates 10 seconds. It is a snapshot. However when I click on the camera, it just shows the loading spinner and does not show the streaming view from the camera. Below are log statements when i click on the camera:

[12/13/2021, 1:53:09 PM] [homebridge-nest-cam] [NexusStreamer] Connected [12/13/2021, 1:53:18 PM] [homebridge-nest-cam] [NexusStreamer] Disconnected [12/13/2021, 1:53:19 PM] [homebridge-nest-cam] [NexusStreamer] Connected [12/13/2021, 1:53:27 PM] [homebridge-nest-cam] [NexusStreamer] Disconnected

Debug Output

[12/13/2021, 1:53:09 PM] [homebridge-nest-cam] [NexusStreamer] Connected [12/13/2021, 1:53:18 PM] [homebridge-nest-cam] [NexusStreamer] Disconnected [12/13/2021, 1:53:19 PM] [homebridge-nest-cam] [NexusStreamer] Connected [12/13/2021, 1:53:27 PM] [homebridge-nest-cam] [NexusStreamer] Disconnected

Steps to reproduce

  1. Setup the Homebridge-nest-cam
  2. View the Home app dashboard
  3. Click on the camera that is showing the nest cam
  4. Spinner shown and video does not stream.

Device Type

Synology server as a docker container

iOS Version

15.1

Camera Types

Doorbell

Bug Persistence

Consistently

Last Working Version

I dont recall.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 3 days

frees321 commented 2 years ago

I am getting a similar issue. The thumbnails of my cameras are stale and not updating, however, when I click on it, I get a working live feed. My log looks similar to the one described above. It hasn't always been doing this, it just started happening.

Brandawg93 commented 2 years ago

This is usually network related. Most of the time, either someone is running a VPN, or the apple hub (Apple TV or iPad) isn't working correctly.

abains commented 2 years ago

I do not have a VPN configured. I also selected the Ethernet in the homebridge settings and still have the issue. Similar to @frees321 it worked sometime ago and stopped working. Is there any more debug info I can post? If so, how do I get it?

wild-a commented 2 years ago

It could be an internet issue. The camera could be at the edge of the wifi range. Try setting the video quality to Low on Homebridge.

abains commented 2 years ago

The nest camera works fine with the Nest app so does not appear to be a Wi-Fi coverage issue.

abains commented 2 years ago

I turned on debugging on the Homebridge container via the UI and found the following in the output log: [NexusStreamer] Playback Error: Transcode not available

What could be the reason for this error?

Code snippet: /**

wild-a commented 2 years ago

I turned on debugging on the Homebridge container via the UI and found the following in the output log: [NexusStreamer] Playback Error: Transcode not available

What could be the reason for this error?

Code snippet: /**

  • Handle if the stream ended in error
  • @param {Pbf} payload The playback end data */ private handlePlaybackEnd(payload: Pbf): void { const packet = PlaybackEnd.read(payload); switch (packet.reason) { case PlaybackEnd.Reason.ERROR_PROFILE_NOT_AVAILABLE: this.log?.debug('[NexusStreamer] Playback Error: Profile not available'); break; case PlaybackEnd.Reason.ERROR_TIME_NOT_AVAILABLE: this.log?.error('[NexusStreamer] Playback Error: Time not available'); break; case PlaybackEnd.Reason.ERROR_TRANSCODE_NOT_AVAILABLE: this.log?.debug('[NexusStreamer] Playback Error: Transcode not available'); break; default: break; } }

Can you post your settings?

abains commented 2 years ago

{ "refreshToken": "...", "options": { "ffmpegCodec": "libx264", "streamQuality": 3, "alertCheckRate": 10, "alertCooldownRate": 180, "alertTypes": [ "Motion", "Sound", "Person", "Package Delivered", "Package Retrieved", "Face", "Zone" ], "importantOnly": true, "motionDetection": false, "streamingSwitch": true, "chimeSwitch": false, "announcementsSwitch": false, "doorbellAlerts": false, "doorbellSwitch": false, "audioSwitch": true }, "platform": "Nest-cam" },

ds2288 commented 2 years ago

I'll second that something is up here. My cameras have no issues in the Nest app or the Google app, but via Homebridge they are so flaky. No other device has an issue, so it's not connectivity. Sometimes it works, and more than often i get the "No response" when opening the stream. I am also seeing issues in the log with NexusStreamer

Brandawg93 commented 2 years ago

It's also dependent on the cpu power of the machine running homebridge. The nest app decodes the mp4 fragments directly, whereas the homebridge server has to use ffmpeg as a middleman to properly stream. There is a lot of overhead involved with it unfortunately.

ds2288 commented 2 years ago

I'm happy to install ffmpeg on my linux device and point the addon to the path, if I knew what the path was to enable hardware decoding. I'm using an ARM device running headless Ubuntu. The CPU has hardware decoding of up to 4k video so I'd say it has enough grunt.

Brandawg93 commented 2 years ago

There is probably a hardware encoder that you would need to enable. Similar the the raspberry pi's h264_omx codec.

abains commented 2 years ago

Some more info from the log re the commands issues for ffmpeg:

VIDEO command: ffmpeg -f,h264,-use_wallclock_as_timestamps,1,-r,15,-i,pipe:,-c:v,libx264,-preset,ultrafast,-tune,zerolatency,-bf,0,-b:v,1196k,-bufsize,1196k,-maxrate,2392k,-pix_fmt,yuv420p,-an,-payload_type,99,-ssrc,7530089,-f,rtp,-srtp_out_suite,AES_CM_128_HMAC_SHA1_80,-srtp_out_params,yzkH5gs90Q1ID5rgJ7M7CLSnVpi/TTmfsJKK2tBE,srtp://192.168.1.xx:52800?rtcpport=52800&localrtcpport=40836&pkt_size=1378 AUDIO command: ffmpeg -c:a,libfdk_aac,-i,pipe:,-c:a,libfdk_aac,-profile:a,aac_eld,-ac,1,-vn,-ar,16k,-b:a,24k,-flags,+global_header,-payload_type,110,-ssrc,11013760,-f,rtp,-srtp_out_suite,AES_CM_128_HMAC_SHA1_80,-srtp_out_params,vRW+oRBTDS64Miev2snrshWVoXnaIYM9H2hM4TtP,srtp://192.168.1.xx:59170?rtcpport=59170&localrtcpport=50722&pkt_size=188 RETURN AUDIO command: ffmpeg -hide_banner,-protocol_whitelist,pipe,udp,rtp,file,crypto,-f,sdp,-c:a,libfdk_aac,-i,pipe:0,-map,0:0,-c:a,libspeex,-frames_per_packet,4,-ac,1,-vn,-ar,16k,-f,data,pipe:1

ERROR: [NexusStreamer] Playback Error: Transcode not available

ds2288 commented 2 years ago

Managed to get some stability by using the copy codec and setting the path to ffmpeg. Now get an error that my version of ffmpeg doesn’t include some AAC codec, but whatever. The vision shows up. This was on a fresh install of Debian and installing ffmpeg from stock repo.

Brandawg93 commented 2 years ago

@abains Is that error code consistent every time you stream?

abains commented 2 years ago

@Brandawg93 yes that error code is consistent with every time I try to stream. I tried to update ffmpeg to a newer (dev) version, no luck. FYI I am running the home bridge docker container on a Synology DS415+.

Brandawg93 commented 2 years ago

Transcode not available is actually an error from the Nest server. The plugin requests h264 packets from the cloud, and typically, Nest will continue to redirect until it finds a server capable of giving you h264. For some reason, that isn't happening here...I'm investigating, but it's difficult to debug since I can't reproduce. Rest assured it is not your ffmpeg that is the issue.

vlsalsa commented 2 years ago

Similar issue here, though both on desktop Mac and iPhone when I open the stream I get nothing.... and Homebridge prints the following.

Tried with libx264, Stream quality low. Also tried copy codec... but there was no difference. The standard install of ffmpeg --- the /path/to/ffmpeg in the settings is blank as I am not using a custom build.

The preview image in the Home App refreshes every 10 seconds.

[1/13/2022, 3:39:18 PM] [Nest-cam] [NexusStreamer] Connected [1/13/2022, 3:39:18 PM] [Nest-cam] [NexusStreamer] Redirecting... [1/13/2022, 3:39:18 PM] [Nest-cam] [NexusStreamer] Disconnected [1/13/2022, 3:39:19 PM] [Nest-cam] [NexusStreamer] Connected [1/13/2022, 3:39:21 PM] [Nest-cam] [NexusStreamer] Disconnected [1/13/2022, 3:39:27 PM] [Homebridge UI] [homebridge-nest-cam] Incoming Request: /auth [1/13/2022, 3:39:27 PM] [Homebridge UI] [homebridge-nest-cam] Incoming Request: /cameras [1/13/2022, 3:39:28 PM] [Homebridge UI] [homebridge-nest-cam] Incoming Request: /zones [1/13/2022, 3:39:29 PM] [Homebridge UI] [homebridge-nest-cam] Incoming Request: /structures [1/13/2022, 3:39:29 PM] [Homebridge UI] [homebridge-nest-cam] Incoming Request: /owner [1/13/2022, 3:39:52 PM] [Homebridge UI] [homebridge-nest-cam] Terminating child process... [1/13/2022, 3:39:52 PM] [Homebridge UI] [homebridge-nest-cam] Child process ended

ds2288 commented 2 years ago

Bought an rpi4b for other uses and now decided to try that device. Using h264_omx I get error VIDEO: Conversion failed! Using libx264, it’s just hit and miss if the camera loads or not. Don’t understand how you could use hardware decoding if it’s failing. Using the homebridge rpi image that’s supposed to be all setup.

Edit - using h264_v4l2m2m seems to work well on an RPi4B running the Homebridge raspbian image. No errors so I assume it’s accessing hardware decoding. I found online that h264_omx is the older interface.

Edit - still hit and miss. Lots of “No Response”. No errors in the log, just heaps of Connecting, Redirecting, Disconnecting. Work about 1 in every 3-4 attempts. Not yet a replacement for the Nest app. I feel like there something not right in the request to the Nest servers for the stream, or the handling of it…..but way above my head.

DJFraz commented 2 years ago

I'm having the same issue on all iteration of Home (MacOS, iPhone, iPad) - Preview loads for snapshots but when I open the stream, it doesn't load. Running homebridge on Ubuntu VM. homebridge-nest-cam v7.5.0

[1/15/2022, 9:06:24 PM] [Nest-cam] [NexusStreamer] Redirecting...
[1/15/2022, 9:06:24 PM] [Nest-cam] [NexusStreamer] Disconnected
[1/15/2022, 9:06:25 PM] [Nest-cam] [NexusStreamer] Connected
[1/15/2022, 9:06:27 PM] [Nest-cam] [NexusStreamer] Disconnected
farcaller commented 2 years ago

Same issue here even though the events are in a slightly different order:

[2/2/2022, 7:05:11 PM] [Nest-cam] [NexusStreamer] Connected
[2/2/2022, 7:05:12 PM] [Nest-cam] [NexusStreamer] Redirecting...
[2/2/2022, 7:05:12 PM] [Nest-cam] [NexusStreamer] Disconnected
[2/2/2022, 7:05:12 PM] [Nest-cam] [NexusStreamer] Connected
[2/2/2022, 7:05:24 PM] [Nest-cam] [NexusStreamer] Disconnected
ds2288 commented 2 years ago

Totally cool if this is something that can’t be fixed, or you don’t have time, but it’d be good to know if the plugin is due to be developed, as otherwise I’ll just invest in a Starling hub. Right now this is unusable.

Brandawg93 commented 2 years ago

Unfortunately it isn't something I can reproduce. I use a raspberry pi as well and I get a stream every time. It could be network related or it could be something else.

You're welcome to try Starling, but it's just homebridge on a custom board. I suppose it will have the same issues.

adrianloffredo commented 2 years ago

New to homebridge. Just installed it last week on a very old pi I had lying around and had the issue ever since installing.

My error seems a little more verbose than the others.

Please note I had to downgrade to node v14.18.2 since v16 seems to cause problems for my pi and won't let me install plugins.

Not sure if the node version has something to do with it.

In any case I get an unhandled promise error. Also not sure if it's completely unrelated but just thought I would throw it out there.

[03/02/2022, 20:25:54] [Nest-cam] [NexusStreamer] Connected
[03/02/2022, 20:25:54] [Nest-cam] [NexusStreamer] Redirecting...
[03/02/2022, 20:25:54] [Nest-cam] [NexusStreamer] Disconnected
[03/02/2022, 20:25:54] [Nest-cam] [NexusStreamer] Connected
(node:8245) UnhandledPromiseRejectionWarning: Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:156:25)
    at writeGeneric (internal/stream_base_commons.js:147:3)
    at Socket._writeGeneric (net.js:798:11)
    at Socket._write (net.js:810:8)
    at writeOrBuffer (internal/streams/writable.js:358:12)
    at Socket.Writable.write (internal/streams/writable.js:303:10)
    at NexusStreamer.processPlaybackPacket (/usr/local/lib/node_modules/homebridge-nest-cam/src/nest/streamer.ts:437:16)
    at NexusStreamer.handlePlaybackPacket (/usr/local/lib/node_modules/homebridge-nest-cam/src/nest/streamer.ts:423:12)
    at NexusStreamer.handleNexusPacket (/usr/local/lib/node_modules/homebridge-nest-cam/src/nest/streamer.ts:516:14)
    at NexusStreamer.handleNexusData (/usr/local/lib/node_modules/homebridge-nest-cam/src/nest/streamer.ts:573:12)
(node:8245) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2213)
[03/02/2022, 20:26:01] [Nest-cam] [NexusStreamer] Disconnected
[03/02/2022, 20:26:03] [Nest-cam] [NexusStreamer] Disconnected
ds2288 commented 2 years ago

Interestingly I’ve made progress on my situation. Knowing you get a stream all the time definitely made me look into my network. I run openwrt on another rpi4b as my router, and after a bit of digging realised I didn’t have an mDNS config. Installed Avahi-daemon, set it up and changed Homebridge mDNS to Avahi. Now I get a stream almost always without error. Thanks for making me realise it was me!! :)

Edit: Got excited for nothing. Back to being hit and miss. Probably a 40-50% stroke rate with successfully opening a stream. My next job is to get the cameras on the same network as the HomePod and homebridge, but I can’t see this as being an issue, they’ve always worked on a VLAN via the Nest app.

adrianloffredo commented 2 years ago

So based on ds2288's update. I checked my network settings and mDNS looks to be setup correctly.

I also managed to get node v16 running instead of node v14 but had to enable a flag to bypass the issue I was having as per this issue: https://github.com/homebridge/homebridge/issues/3005

The interesting thing is that now I get the same error but it then crashes the server

[03/02/2022, 23:09:46] [Nest-cam] [NexusStreamer] Connected
[03/02/2022, 23:09:46] [Nest-cam] [NexusStreamer] Redirecting...
[03/02/2022, 23:09:46] [Nest-cam] [NexusStreamer] Disconnected
[03/02/2022, 23:09:47] [Nest-cam] [NexusStreamer] Connected
[03/02/2022, 23:09:52] Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:164:15)
    at writeGeneric (node:internal/stream_base_commons:155:3)
    at Socket._writeGeneric (node:net:795:11)
    at Socket._write (node:net:807:8)
    at writeOrBuffer (node:internal/streams/writable:389:12)
    at _write (node:internal/streams/writable:330:10)
    at Socket.Writable.write (node:internal/streams/writable:334:10)
    at NexusStreamer.processPlaybackPacket (/usr/local/lib/node_modules/homebridge-nest-cam/src/nest/streamer.ts:437:16)
    at NexusStreamer.handlePlaybackPacket (/usr/local/lib/node_modules/homebridge-nest-cam/src/nest/streamer.ts:423:12)
    at NexusStreamer.handleNexusPacket (/usr/local/lib/node_modules/homebridge-nest-cam/src/nest/streamer.ts:516:14)
[03/02/2022, 23:09:53] Got SIGTERM, shutting down Homebridge...

Also for some reason I got a feed to work once. When I tried again the server crashes once more.

I also noticed someone opened this issue #462 which is pretty much what I am seeing. So not sure if these are in fact linked.

update

I got it to work with the copy codec on low quality. It looks terrible but works consistently 😁

I figure my old pi is not up to the challenge. If anyone else has this same issue maybe give that a try and see what happens.

joshuajohnlee commented 2 years ago

I also changed my Homebridge mDNS to Avahi and it seems to now be streaming successfully again - it's no longer immediately connecting and disconnecting.

vlsalsa commented 2 years ago

So I have a raspberry pi, same issue as above.

I have tried;

  1. updating node.js to 16.13.2
  2. Updating NPM to 8.1.2
  3. Switching home hub to a newer AppleTV, Hardwired CAT6
  4. Updating homebridge
  5. Changing Router DNS from default to Cloudflare
  6. Confirmed I can get Avahi and ssh into raspberry pi with .local address

And still no luck :(

vlsalsa commented 2 years ago

Edit: Changed to Avahi in settings in the config file, and still no luck. Tried the other 3 as well and also no luck.>

How did you go about changing it to Avahi?

ds2288 commented 2 years ago

So have literally ripped my entire network to shreds trying to get this to work consistently. I’m at about a 90% success rate with connections. My observations:

The Nest app is still faultless, works 100% of the time and the quality of the stream is far better, but I guess we are nerds, so we want everything to work in one app. IMHO Nest cams in HomeKit are a bit of a gimmick, nice to have them there but you can’t look at history, so it’s nigh on useless.

Anyway - just my observations. Basically keep it simple. I’m convinced I can get it all done again on VLAN’s to get better security on my network as I had before, I dare say the DNS issue was causing all the problems. Unfortunately I worked that out after I’d changed everything around. I’m not sure I can be bothered changing it back now!!!

abains commented 2 years ago

@Brandawg93 today I upgraded my Homebridge container on Synology and it works! Not sure what fixed it but it might have been something in the config for Homebridge on Syno. I will keep an eye on it. Below is a snippet of the log:

[2/23/2022, 3:58:02 PM] [Nest-cam] [NexusStreamer] Connected [2/23/2022, 3:58:02 PM] [Nest-cam] [NexusStreamer] Redirecting... [2/23/2022, 3:58:02 PM] [Nest-cam] [NexusStreamer] Disconnected [2/23/2022, 3:58:03 PM] [Nest-cam] [NexusStreamer] Connected [2/23/2022, 3:58:19 PM] [Nest-cam] [NexusStreamer] Disconnected [2/23/2022, 3:58:20 PM] [Nest-cam] [NexusStreamer] Connected [2/23/2022, 3:58:20 PM] [Nest-cam] [NexusStreamer] Redirecting... [2/23/2022, 3:58:20 PM] [Nest-cam] [NexusStreamer] Disconnected [2/23/2022, 3:58:20 PM] [Nest-cam] [NexusStreamer] Connected [2/23/2022, 3:58:29 PM] [Nest-cam] [NexusStreamer] Disconnected

The last disconnect was when I exited the view on the hope app.

ds2288 commented 2 years ago

Sorted my issue on Rpi4b running the Homebridge version of Raspbian. It was ffmpeg. Installed ffmpeg from apt and pointed the plugin to /usr/bin/ffmpeg. Now 100% success rate. Only thing is sound doesn't work, I have to learn how to build ffmpeg with the required flag.

Brandawg93 commented 2 years ago

It seems that several people have been able to resolve this issue on their own. I'm going to close this for now, but feel free to continue discussion.

rfiorentino1 commented 2 years ago

The problem is, people have been able to solve this, by working around whatever the core issue is with this specific plugin. I also have ring cameras, which also stream through the ffmpeg library through home bridge, and they've always worked flawlessly, without issue. I'm not sure if you can borrow code from that plugin etc, but the nest plugin is the only one that I've never been able to pull live streams from. I will try some of the above, but wanted to just put here for reference. :)

rfiorentino1 commented 2 years ago

I finally figured it out, for my set up, and have consistent streaming now. For me, I can't use the libx264 codec, even though my homebridge is running on a 8 core Mac Pro, which should have plenty of power to handle it. I either have to use copy, or h264_video toolbox to get a consistent stream in the home app. Interestingly, libx264 is enabled in my ffmpeg configuration when I check using "ffmpeg -h encoder=h264" so I'm not sure what the reason would be as to why the plug-in can't stream using that. Anyone have any ideas as to how to troubleshoot this? I'm more curious than anything, because I've gotten it to work, but interesting that no errors occur in the logs when using Libx264, the logs just specify that that is the chosen encoder. this may or may not be a fix for issues #469 and #473, assuming, like mme, that there are no firewalls or VPN connections or complicated networks setups in the way. That's what had me so baffled, was that I knew there was nothing major going on with my network, which ended up being true because it seems to be a codec-specific issue. Maybe at some point this plug-in can include its own version of ffmpeg with the required encoders etc to avoid these types of things, but I have no idea how easy or difficult that would be to implement. Just wanted to at least post an update/my solution here in case it helps someone else reading this :-) as always, thank you so much for the continued development and maintenance of this plug-in, it's much appreciated.