potmat / homebridge-google-nest-sdm

A Homebridge plugin for Google Nest devices that uses the Google Smart Device Management API. Supports Cameras, Doorbells, Displays, and Thermostats. Includes support for HomeKit Secure Video.
ISC License
155 stars 17 forks source link

HKSV not working for some generation one cameras #29

Closed valiquette closed 2 years ago

valiquette commented 2 years ago

I have never been able to get a HKSV recording to show up, I keep seeing this odd message in the log between the plugin's logging. the line starting with {HDS :: is the one in question. any idea what that is?

[7/20/2022, 9:21:59 AM] [homebridge-google-nest-sdm] Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp Stream #0:1: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1600x1200 [SAR 1:1 DAR 4:3], 30 fps, 30 tbr, 90k tbn [NULL @ 0x3f3ac80] Unable to find a suitable output format for '' : Invalid argument

[7/20/2022, 9:21:59 AM] [homebridge-google-nest-sdm] Socket destroyed. [HDS ::ffff:192.168.188.186] Recording download stream 1 is still awaiting generator although stream was closed 10s ago! This is a programming mistake by the camera implementation which prevents freeing up resources. [7/20/2022, 9:22:05 AM] [homebridge-google-nest-sdm] HksvStreamer destroy command received, ending process.

potmat commented 2 years ago

@valiquette: The error that is likely causing the problem is actually this one

[NULL @ 0x3f3ac80] Unable to find a suitable output format for '' : Invalid argument

Can you tell me more about the camera? What kind is it (e.g. 1st gen doorbell etc..)

Edit: Can you also include more logging around where the error happens? I'd like to see the ffmpeg command that is getting executed.

valiquette commented 2 years ago

I have number of cameras hello, nest indoor nest outdoor and dropcam right know I have access limited to just the doorbell cam. The log captured a restart, enough motion to trigger an event then some streaming from the camera. I do not know if there are limits, when I tried to run this with 5 cameras, 1 user it seemed like this error drove some retires and I got flooded with 429 errors for exceeding the rate limits for camera API call.

valiquette commented 2 years ago

This doorbell is 1st gen I am running on Pi4 node js 18.6 (but tried 16.16)

potmat commented 2 years ago

@valiquette: I notice you're running it as a child bridge. Just out of curiosity, what if you didn't do that?

valiquette commented 2 years ago

I just tried that and no difference, in fact may have had a few more ffmpeg errors, I captured logs if you want them and went back to a child bridge state.

potmat commented 2 years ago

@valiquette: I am able to reproduce the error, I will look into it.

valiquette commented 2 years ago

ok, let me know if you want me to test a beta. Thanks

potmat commented 2 years ago

@valiquette just pushed v1.1.2, let me know

valiquette commented 2 years ago

still seeing the earlier error but maybe not every time, but now there is a new one

[7/20/2022, 5:05:30 PM] [homebridge-google-nest-sdm] [swscaler @ 0x4569f10] [swscaler @ 0x4626060] deprecated pixel format used, make sure you did set range correctly

[7/20/2022, 5:05:30 PM] [homebridge-google-nest-sdm] [swscaler @ 0x4569f10] [swscaler @ 0x4661600] deprecated pixel format used, make sure you did set range correctly

[7/20/2022, 5:05:30 PM] [homebridge-google-nest-sdm] [libx264 @ 0x41ffb70] using SAR=1/1

[7/20/2022, 5:05:30 PM] [homebridge-google-nest-sdm] [libx264 @ 0x41ffb70] using cpu capabilities: ARMv6 NEON

[7/20/2022, 5:05:30 PM] [homebridge-google-nest-sdm] [libx264 @ 0x41ffb70] profile High, level 4.0, 4:2:0, 8-bit

[7/20/2022, 5:05:30 PM] [homebridge-google-nest-sdm] [libx264 @ 0x41ffb70] 264 - core 163 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00

[7/20/2022, 5:05:30 PM] [homebridge-google-nest-sdm] mp4 box type ftyp and length 20 [7/20/2022, 5:05:30 PM] [homebridge-google-nest-sdm] mp4 box type moov and length 812 [HDS ::ffff:192.168.188.186] Delegate yielded fragment after stream 1 was already closed! [HDS ::ffff:192.168.188.186] Delegate finished recording stream 1 without sending anything out. Controller will CANCEL. [7/20/2022, 5:05:30 PM] [homebridge-google-nest-sdm] Output #0, mp4, to 'tcp://127.0.0.1:40941': Metadata: title : SDM encoder : Lavf59.16.100 Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1600x1200 [SAR 1:1 DAR 4:3], q=2-31, 2000 kb/s, 30 fps, 15360 tbn Metadata: encoder : Lavc59.18.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 0 vbv_delay: N/A

[7/20/2022, 5:05:30 PM] [homebridge-google-nest-sdm] frame= 1 fps=0.0 q=0.0 size= 1kB time=00:00:00.00 bitrate=N/A speed= 0x

valiquette commented 2 years ago

latest debug log, you may have to search for the HDS lines also I am not seeing 429 rate limit errors from the google API at the end of the log (token redacted) from the response. I hope this helps homebridge.log-3.txt .

potmat commented 2 years ago

Wow. There's a lot going on here. It seems to be a mixture of you actually viewing the camera and events being recorded.

This is the only error we care about:

Delegate finished recording stream 1 without sending anything out. Controller will CANCEL.

Why this is happening I'm not sure. Interestingly you also managed to trigger this one:

[7/20/2022, 5:18:55 PM] [homebridge-google-nest-sdm] Could not execute device command: {"response":{"config":{"url":"https://smartdevicemanagement.googleapis.com/v1/enterprises/f286808e-3c48-4666-883a-773262dbf605/devices/AVPHwEtaq2rbvWka1apIALQGMAxSP0r70NNOsVgNKerBzMyVD6A-S265DTItj_xNnOyR_uoBEHLBdL04jb1aIvMT8HI3Xw:executeCommand","method":"POST","userAgentDirectives":[{"product":"google-api-nodejs-client","version":"5.1.0","comment":"gzip"}],"data":{"command":"sdm.devices.commands.CameraLiveStream.StopRtspStream","params":{"streamExtensionToken":"CiUA2vuxr-aYCHcqKJC5UHPyAmB_1Fz3M2zEJ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eQ5vvXB9PGepMKt_g8xbvxclwv626xqX6sq_IwXImUZe7iqsAtRDFil8E"}},"headers":{"x-goog-api-client":"gdcl/5.1.0 gl-node/18.6.0 auth/7.14.1","Accept-Encoding":"gzip","User-Agent":"google-api-nodejs-client/5.1.0 (gzip)","Authorization":"Bearer reacted"}}","responseType":"json","retryConfig":{"currentRetryAttempt":0,"retry":3,"httpMethodsToRetry":["GET","HEAD","PUT","OPTIONS","DELETE"],"noResponseRetries":2,"statusCodesToRetry":[[100,199],[429,429],[500,599]]}},"data":{"error":{"code":500,"message":"Internal error encountered.","errors":[{"message":"Internal error encountered.","domain":"global","reason":"backendError"}],"status":"INTERNAL"}},"headers":{"alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","cache-control":"private","connection":"close","content-encoding":"gzip","content-type":"application/json; charset=UTF-8","date":"Wed, 20 Jul 2022 23:18:55 GMT","server":"ESF","transfer-encoding":"chunked","user-id":"AVPHwEtSwGcf8xph-uBTmMtHOVKfo1jrsMWq95MBQinz","vary":"Origin, X-Origin, Referer","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","x-xss-protection":"0"},"status":500,"statusText":"Internal Server Error","request":{"responseURL":"https://smartdevicemanagement.googleapis.com/v1/enterprises/f286808e-3c48-4666-883a-773262dbf605/devices/AVPHwEtaq2rbvWka1apIALQGMAxSP0r70NNOsVgNKerBzMyVD6A-S265DTItj_xNnOyR_uoBEHLBdL04jb1aIvMT8HI3Xw:executeCommand"}},"config":{"url":"https://smartdevicemanagement.googleapis.com/v1/enterprises/f286808e-3c48-4666-883a-773262dbf605/devices/AVPHwEtaq2rbvWka1apIALQGMAxSP0r70NNOsVgNKerBzMyVD6A-S265DTItj_xNnOyR_uoBEHLBdL04jb1aIvMT8HI3Xw:executeCommand","method":"POST","userAgentDirectives":[{"product":"google-api-nodejs-client","version":"5.1.0","comment":"gzip"}],"data":{"command":"sdm.devices.commands.CameraLiveStream.StopRtspStream","params":{"streamExtensionToken":"CiUA2vuxr-aYCHcqKJC5UHPyAmB_1Fz3M2zEJ3sEMuc5vsJnseuUEsEGAJjBH3lYpRpHbk2qjLz3F8fPEnwiJgXtjqt2XgNqh5G8mFDLiMCKpmXX-Q0ALrb55yazpKwmtYm34gmMbhL3BBEsClf-0oaQA8WHXs-OFwssl2QNJ3SFgBPm-WYN3f5bm_JRcQV8TSKlYoeRsZeu0B9R-0g0QmbViYhsUOpy_8VC6WuICyefv_yYqfLbGCXtQkzGWDJr7KuHiPtQ7vGgZ0phuJOZJsEQlYEZkQ2ZFQIkoImZMQk9MrHXWcP9cOyLj87bVqf5XyJjCD8NlxM7Ea1aSgeUdtBWk8JjfONkIFWK8yNVn-bRuZjIDl_I8YXZmyGshUMCgZy3v4MFfpPm7fJYK_p8UH_uSmM2COqAhdEXOMopvc10HvhupM8w33bbtA7cX2oCh4X-Uwk03zBLiDZi8KOm_UPxaPDndaZhokJR7cRS1n5v2doahR82uw1Uk-utz_m4TKWmUeiup-AiiSDil3OZ86Ke2rS020EXVqv-DnIBi3Hq6owKILuQpffCkNR66jXxt1M2TSk9o5sxorGhzkyNyQ8IryW1Yy1YENJyoTCzLOHRW4UqrSukDRSPfK46nyDiCKVvb3UAE8IquJF8V0FtK-aZM5SVj97zujEDbr-egKTuXRw5UaGe2WR5FDjfrJ9zdQ8ugNv_d04dVspa9rKbvgN8VLGeN-LlHC2xH62nVzpuBY3Ysfkc2B9kNBqJbzdBSe8Hvdwn2_7lZoW5sqAebCU6FpkPc_NFaqYMRcLGWimjX0bfHl8syH26_ANgBj8FPEKakpX4ct4GlL9_fEc50Y6biMDq2pUcoksiZ696xkKKgYtMoI1ibwYmaU2qKiLTzBf4jZfyw9xdUv9CfGU9f72Cyi2poJu5fyWusSkYHlHsMclFhyeN8Idhk_xuvpVA_5NzdiimbglqSX-gDr5z-45vVd-XaxNhL5YnkU7O9BTZBBgSsRYl9xMQxc8zI170lyCclWDbWMZKa3Qsk0XXNzkzE70PziCKDQNPUQjjwj7J8tQih_kizIguuBuBuArlNVjAT3Vjaq9A3EIqZ1n35AeQ5vvXB9PGepMKt_g8xbvxclwv626xqX6sq_IwXImUZe7iqsAtRDFil8E"}},"headers":{"x-goog-api-client":"gdcl/5.1.0 gl-node/18.6.0 auth/7.14.1","Accept-Encoding":"gzip","User-Agent":"google-api-nodejs-client/5.1.0 (gzip)","Authorization":"Bearer redacted"}}","responseType":"json","retryConfig":{"currentRetryAttempt":0,"retry":3,"httpMethodsToRetry":["GET","HEAD","PUT","OPTIONS","DELETE"],"noResponseRetries":2,"statusCodesToRetry":[[100,199],[429,429],[500,599]]}},"code":500,"errors":[{"message":"Internal error encountered.","domain":"global","reason":"backendError"}]} Front Door Doorbell

That's the SDM API itself failing. Amazing, never seen that before! Needless to say, there's not much I can do about that.

However, the plugin is "working" more or less, when you see things like:

[7/20/2022, 5:18:29 PM] [homebridge-google-nest-sdm] mp4 box type ftyp and length 20 [7/20/2022, 5:18:29 PM] [homebridge-google-nest-sdm] mp4 box type moov and length 812

That's the plugin actually sending video to your hub successfully. I'll have to see if I can reproduce any of this.

valiquette commented 2 years ago

I found a note online about hubs with active users that are not the owner of the home, and this was my case. I disable those hubs and log looks cleaner and would suggested it is mostly working as you noted. I do see undefined Front Door Doorbell - not sure if undefined is important to not here. and deprecated pixel format used, make sure you did set range correctly- not sure it this one is import either

The live video seems to work ok on a iPhone and my Mac, but not in an iPad Pro or Apple TV, on those device I get audio and frozen video. IMG_0006

valiquette commented 2 years ago

new log homebridge.log-2.txt

valiquette commented 2 years ago

I was able to get this to work on a MAC vs the Pi4. It did take a lot of restart and tries to get the first hksv

potmat commented 2 years ago

Hi @valiquette, that's great news! I'm not sure why the Pi4 wasn't working for you, perhaps it was simply overloaded? As I note in the readme, HKSV can consume 100% CPU for a single camera with HKSV enabled. At some point I'll look into using hardware transcoding, but I haven't been able to get it working so far.

You are correct that "undefined Front Door Doorbell " and "deprecated pixel format used, make sure you did set range correctly" can be safely ignored, they are warnings not errors.