Samfox2 / homebridge-videodoorbell

Video-Doorbell plugin based on homebridge-camera-ffmpeg for Homebridge.
Apache License 2.0
96 stars 17 forks source link

Intermmitent Rich Notification #81

Closed kennyluk closed 3 years ago

kennyluk commented 3 years ago

There seems to be some kind of race condition with generating the JPG for rich notification.

If there is more than one device subscribed to get notification (for example, a Mac, an iPhone and an Apple Watch), then the plugin will issue multiple ffmpeg queries to generate a thumbnail for each device.

If the device is slow to response, then the 2nd or 3rd thumbnail will usually fail to generate the thumbnail in time and no rich notification will result.

My ugly hack at the moment is to cache the most recent JPG myself locally and set stillImageSource to the local file.

Samfox2 commented 3 years ago

Yes caching would be nice but different devices could ask for different resolutions. I try to test if scaling is faster than opening separate streams.

kennyluk commented 3 years ago

Makes sense, thanks for taking the time to write back. I just happen to own very old hardware that has very high latency in responding and this bit me for a couple of hours.

I still cannot get the rich notification to show up on my Apple Watch. I think it showed up once or twice. I already reduced the size of the image but still doesn't work. Any ideas?

Samfox2 commented 3 years ago

As my own watch/ipad/iphone respond almost immediately to a bell event (with picture and without caching) it seems like a problem of your overall setup. Maybe your wireless signal is to week? Camera responds too slow? Does the picture appear if you point your snapshot url to a file (without calling ffmpeg at all)?

kennyluk commented 3 years ago

I agree it is something on my setup. It currently is setup with:

"stillImageSource": "-i /home/XXXXX/a.jpg"

pointing to a static file on the filesystem. For a motion event, does respond correctly to the motion event by generating thumbnails (2 1280x720 and 1 480 x 270) and sending it as rich notification to the Mac and the iPhone, but the Apple Watch only gets a text based notification.

I don't usually use a bell event, but if I turn it on and press the virtual doorbell, I do receive a rich notification on the Apple Watch that starts out as a "grey" block and then will turn into a live video if I wait a sec or so as ffmpeg starts streaming.

I noticed the resolution of the file scaled to be sent to the Apple Watch is very specific (480x270)? Is there any kind of specific file size, resolution, or encoding the Apple Watch is expecting?

This is all very odd.

Samfox2 commented 3 years ago

Those are all supported resolutions (w, h, fps for video): [320, 180, 30] [320, 240, 15] [320, 240, 30] [480, 270, 30] [480, 360, 30] [640, 360, 30] [640, 480, 30] [1280, 720, 30] [1280, 960, 30] [1920, 1080, 30] [1600, 1200, 30]

Think watch is using one of the first ones depending on availible bandwidth. For testing you could generate a few pics with different resolutions and use the native pic depending on what homekit is asking for. If this is not working, ... ??? ...

kennyluk commented 3 years ago

Just want to report that I have made no progress on this. The rich notification is still not showing up on the Apple Watch. I have putting this aside for now, but will revisit another time. Thanks for taking the time to help out.