colinbendell / homebridge-blink-for-home

Blink For Home Camera Homebridge plugin
MIT License
88 stars 27 forks source link

optimize live view playback #11

Open colinbendell opened 3 years ago

vdrover commented 3 years ago

Live view working well it seems for v3.5.13.

rcoletti116 commented 3 years ago

Live view is not working for me. Here are the logs (with Debug enabled).

[11/1/2020, 19:11:39] [Blink] handleStreamRequest [11/1/2020, 19:11:39] [Blink] { sessionID: '2a5c4fda-ab61-48df-ab67-3370fe18fb55', type: 'start', video: { profile: 2, level: 2, packetizationMode: 0, cvoId: undefined, width: 1280, height: 720, fps: 30, pt: 99, ssrc: 1326552295, max_bit_rate: 299, rtcp_interval: 0.5, mtu: 1378 }, audio: { codec: 'OPUS', channel: 1, bit_rate: 0, sample_rate: 24, packet_time: 20, pt: 110, ssrc: 1297153708, max_bit_rate: 24, rtcp_interval: 5, comfort_pt: 13, comfortNoiseEnabled: false } } [11/1/2020, 19:11:39] [Blink] FFMPEG: received first frame client connected from 127.0.0.1:43046 conencting to: 52.90.181.199 (node:18872) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version. Error: self signed certificate at TLSSocket.onConnectSecure (_tls_wrap.js:1501:34) at TLSSocket.emit (events.js:315:20) at TLSSocket._finishInit (_tls_wrap.js:936:8) at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:710:12) { code: 'DEPTH_ZERO_SELF_SIGNED_CERT' } [11/1/2020, 19:11:39] [Blink] [Video] ffmpeg exited with code: 1 and signal: null (error)

colinbendell commented 3 years ago

It looks like you have a proxy or something in the middle? It is getting a self signed certificate. Also looks like the sni servername is being tampered with by the api responses.

On Sun, Nov 1, 2020 at 7:12 PM rcoletti116 notifications@github.com wrote:

Live view is not working for me. Here are the logs (with Debug enabled).

[11/1/2020, 19:11:39] [Blink] handleStreamRequest [11/1/2020, 19:11:39] [Blink] { sessionID: '2a5c4fda-ab61-48df-ab67-3370fe18fb55', type: 'start', video: { profile: 2, level: 2, packetizationMode: 0, cvoId: undefined, width: 1280, height: 720, fps: 30, pt: 99, ssrc: 1326552295, max_bit_rate: 299, rtcp_interval: 0.5, mtu: 1378 }, audio: { codec: 'OPUS', channel: 1, bit_rate: 0, sample_rate: 24, packet_time: 20, pt: 110, ssrc: 1297153708, max_bit_rate: 24, rtcp_interval: 5, comfort_pt: 13, comfortNoiseEnabled: false } } [11/1/2020, 19:11:39] [Blink] FFMPEG: received first frame client connected from 127.0.0.1:43046 conencting to: 52.90.181.199 (node:18872) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version. Error: self signed certificate at TLSSocket.onConnectSecure (_tls_wrap.js:1501:34) at TLSSocket.emit (events.js:315:20) at TLSSocket._finishInit (_tls_wrap.js:936:8) at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:710:12) { code: 'DEPTH_ZERO_SELF_SIGNED_CERT' } [11/1/2020, 19:11:39] [Blink] [Video] ffmpeg exited with code: 1 and signal: null (error)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/colinbendell/homebridge-blink-for-home/issues/11#issuecomment-720175540, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMMERK4V66IYJDJAWN6ONDSNX2QTANCNFSM4TGXYGHQ .

rcoletti116 commented 3 years ago

So, I think this has to do with the Official Raspberry Pi image. It has Nginx and a self-signed cert. I didn't realize before. Now, I don't have the SSL in use but may need to figure out how to disable it.

rcoletti116 commented 3 years ago

Based on only a few minutes of testing, I'm unable to disable the use of the proxy on the official pi image. You can disable it, but it turns itself right back on. I'm assuming your instance has no cert at all. Is that right?

colinbendell commented 3 years ago

The weird part here is that the issue comes in when we are trying to make a TLS connection upstream to blink's RTSP server. Here is the TLS proxy that we need to relay ffmpeg through: https://github.com/colinbendell/homebridge-blink-for-home/blob/main/src/proxy.js#L29 which is setup from the call to get the live view stream from the API: https://github.com/colinbendell/homebridge-blink-for-home/blob/main/src/blink-camera-deligate.js#L170 and https://github.com/colinbendell/homebridge-blink-for-home/blob/main/src/blink.js#L269

The error above though, shows the servername being set to 52.90.181.199 and the TLS connection complaining because that's an invalid use of SNI. This would imply the liveview api got a .server url with that IP and the complaint is that it is a self serve cert.

There is another explanation, which might actually be more plausible, and that has to do with the blink hardware you are using. Can you tell me what blink cameras you are using? Could you enable the 'diagnostic on startup' flag and send me (twitter/email) the output from the logs? I suspect that perhaps the newer cameras might be relaying through a local ICE/STUN server, and we are interfacing directly with the local camera. In this case I need to do more testing and design (I've only got the original gen1 cameras)

rcoletti116 commented 3 years ago

Got it, just pulled the logs and sent to you on Discord. My cameras are XT2 and the new Indoor/Outdoor.

aje89 commented 3 years ago

I have the exact problem. I have a Blink Mini in use.

swadhwani51 commented 3 years ago

Live view doesnt seem to be working for me with the XT2 cameras. I get this when trying to bring up live view (logs) /2020, 9:54:10 PM] [Blink] [Video] Failed to start video stream: spawn ffmpeg ENOENT listening on 0.0.0.0:34275 [11/4/2020, 9:54:15 PM] [Blink] [Video] Failed to start video stream: spawn ffmpeg ENOENT listening on 0.0.0.0:36433 [11/4/2020, 9:54:22 PM] [Blink] [Video] Failed to start video stream: spawn ffmpeg ENOENT [11/4/2020, 9:54:50 PM] [Blink] Blink Dewberry Lane Armed (Target) for Blink Dewberry Lane is: 2 [11/4/2020, 9:54:52 PM] [Blink] Blink Dewberry Lane Armed (Target) for Blink Dewberry Lane is: 3 [11/4/2020, 9:55:07 PM] [Blink] Enabled for Blink Patio Right is: true [11/4/2020, 9:55:07 PM] [Blink] Enabled for Blink Patio Right is: true listening on 0.0.0.0:45509 [11/4/2020, 9:55:14 PM] [Blink] [Video] Failed to start video stream: spawn ffmpeg ENOENT [11/4/2020, 9:55:22 PM] [Blink] [Video] Failed to start video stream: spawn ffmpeg ENOENT [11/4/2020, 9:55:23 PM] [Blink] Temperature for Blink Driveway is: 25 [11/4/2020, 9:55:29 PM] [Blink] [Video] Failed to start video stream: spawn ffmpeg ENOENT [11/4/2020, 9:55:34 PM] [Blink] [Video] Failed to start video stream: spawn ffmpeg ENOENT listening on 0.0.0.0:36023 [11/4/2020, 9:56:42 PM] [Blink] [Video] Failed to start video stream: spawn ffmpeg ENOENT [11/4/2020, 9:56:59 PM] [Blink] [Video] Failed to start video stream: spawn ffmpeg ENOENT [11/4/2020, 9:59:06 PM] [Blink] Temperature for Blink Patio Right is: 27.8

gmpugh commented 3 years ago

Getting the exact same issues as @swadhwani51 on XT2's

W3llenreiter commented 3 years ago

Same issue here with stock Raspberry Pi 4 Homebrige image and new Blink Mini cam.

Extract from Homebridge protocol when trying to open live view in Home App:

listening on 0.0.0.0:46555 client connected from 127.0.0.1:45358 conencting to: 52.59.224.249 Error: self signed certificate at TLSSocket.onConnectSecure (_tls_wrap.js:1501:34) at TLSSocket.emit (events.js:315:20) at TLSSocket._finishInit (_tls_wrap.js:936:8) at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:710:12) { code: 'DEPTH_ZERO_SELF_SIGNED_CERT' } [11/5/2020, 20:10:09] [Blink] [Video] ffmpeg exited with code: 1 and signal: null (error)

sentocv commented 3 years ago

Same issue here!

sentocv commented 3 years ago

Ok. I just ordered the newer camera hardware to experiment. I suspect that the protocol is different and I just need to debug it

Will you answer here when you have the Live view resolved?

Thanks Colinbendell, you are amazing! :)