mrlt8 / docker-wyze-bridge

WebRTC/RTSP/RTMP/LL-HLS bridge for Wyze cams in a docker container
GNU Affero General Public License v3.0
2.62k stars 161 forks source link

Wyze Doorbell and homebridge-camera-ffmpeg #552

Closed noelhibbard closed 1 year ago

noelhibbard commented 2 years ago

So I've got a Wyze Doorbell which I can stream into VLC just fine but can't get it to work with homebridge-camera-ffmpeg.

If I omit the ROTATE_DOOR=true option it works fine in homebridge-camera-ffmpeg. I just looked at what is added to the ffmpeg command line if rotation is enabled and it's nothing that I would think would break homebridge-camera-ffmpeg.

Before I spin my wheels I though I would at least ask if anyone else has successfully gotten a Wyze Doorbell into HomeKit via homebridge-camera-ffmpeg.

cheme75 commented 2 years ago

I did early on before I got scrypted running. Don’t recall any issues with it. I had 2 v2 cams and the doorbell on it before I switched the cams to scrypted, all worked fine. One v2 is mounted sideways and @mrlt8 kindly added cam rotation ability so both doorbell and one v2 are rotated, I had no problems in camera ffmpeg, but Scrypted has a plugin for motion detection that seems to working fairly well so I’m staying with scrypted for now. Scrypted also provides hksv if you want to record to iCloud and use the apple AI capabilities.

noelhibbard commented 2 years ago

@cheme75, I've owned 3 Wyze Doorbells so far. The first two died within the first two weeks I a said I'd never buy another one. About a year later I got another one. I'm fairly sure I had it working with wyze-bridge/homebridge-camera-ffmpeg in the past but for the life of me I can't anymore. I've tried so many different things to like different versions of ffmpeg in wyze-bridge and/or homebridge-camera-ffmpeg and nothing I do works.

I've been holding off on Scrypted because I was wanting to keep everything in homebridge but I guess I'll give it a shot. I don't really need HKSV because I'm already running Frigate but I guess it can't hurt to use both and gain the tight integration with iOS.

Thanks for the response!

cheme75 commented 2 years ago

@cheme75, I've owned 3 Wyze Doorbells so far. The first two died within the first two weeks I a said I'd never buy another one. About a year later I got another one. I'm fairly sure I had it working with wyze-bridge/homebridge-camera-ffmpeg in the past but for the life of me I can't anymore. I've tried so many different things to like different versions of ffmpeg in wyze-bridge and/or homebridge-camera-ffmpeg and nothing I do works.

I've been holding off on Scrypted because I was wanting to keep everything in homebridge but I guess I'll give it a shot. I don't really need HKSV because I'm already running Frigate but I guess it can't hurt to use both and gain the tight integration with iOS.

Thanks for the response!

It’s been a while since I used camera-ffmpeg. Fwiw, I was on the doorbell beta and had 5-6 beta versions left over. Plus I have 2 new in box I’ve just been too lazy to post for sale since I don’t need them. I can still add the betas to the app and the bridge finds them. Wyze app only live streams. With bridge I get them into scrypted and if I tweak the motion plugin, I can get motion alerts in HomeKit, so I can get some functionality from otherwise very limited cams. First beta version was terrible. All have same cam but they changed WiFi modem and processor. Made me aware of just how low end Wyze goes to keep prices low.

I’m able to run both homebridge and scrypted on a 12 yr old mobile dual core pentium 1.3ghz netbook with 4gb ram running lubuntu 18.x.x. It’s stays stable most of the time. Meanwhile my 2nd gen i5 2.6 ghz, 8gb ram win 10 machine struggles to run the docker bridge - tried to strip down windows but it seems always something bogs it down.

noelhibbard commented 2 years ago

I solved this in homebridge-camera-ffmpeg by switching the codec to libx264. If I simply copy the stream it just shows the throbber in the Home App forever even though you can see in the Homebridge console that it's streaming just fine. So it's going to eat some more CPU but I'm okay with that as I'm not watching this camera in the Home App 24/7. At least now when someone come onto my porch it will show the feed on my Apple TV rather then only showing the snapshot.

"videoConfig": {
    "source": "-re -i <wyze-bridge URL>",
    "maxWidth": 1296,
    "maxHeight": 1728,
    "maxFPS": 20,
    "forceMax": true,
    "vcodec": "libx264",
    "audio": true,
    "debug": false
}

I am actually going from wyze-bridge > Frigate > homebridge-camera-ffmpeg . So Frigate is doing 24/7 recording and also doing object detection on a Google Coral TPU. Then I wrote a simple app that monitors the MQTT events coming out of Frigate and when there is a "person" on my front porch it then calls the homebridge-camera-ffmpeg webhooks to inform it of the event.

cheme75 commented 2 years ago

I solved this in homebridge-camera-ffmpeg by switching the codec to libx264. If I simply copy the stream it just shows the throbber in the Home App forever even though you can see in the Homebridge console that it's streaming just fine. So it's going to eat some more CPU but I'm okay with that as I'm not watching this camera in the Home App 24/7. At least now when someone come onto my porch it will show the feed on my Apple TV rather then only showing the snapshot.

"videoConfig": {
    "source": "-re -i <wyze-bridge URL>",
    "maxWidth": 1296,
    "maxHeight": 1728,
    "maxFPS": 20,
    "forceMax": true,
    "vcodec": "libx264",
    "audio": true,
    "debug": false
}

Yup, jogged my memory with that, forgot copy didn’t work.

mrlt8 commented 2 years ago

Can confirm something is broken. Normal stream works in homebridge, but re-encoded stream doesn't.

Re-encoded stream and SDP look ok in ffprobe, and plays in VLC.

noelhibbard commented 2 years ago

Can confirm something is broken. Normal stream works in homebridge, but re-encoded stream doesn't.

Re-encoded stream and SDP look ok in ffprobe, and plays in VLC.

Yeah and it kind of sucks to re-encode to rotate just to re-encode again so it will play in homebridge. Deciphering ffmpeg console output isn't all that easy either. It would be nice if Wyze rotated in hardware in the first place.

cheme75 commented 2 years ago

Can confirm something is broken. Normal stream works in homebridge, but re-encoded stream doesn't. Re-encoded stream and SDP look ok in ffprobe, and plays in VLC.

Yeah and it kind of sucks to re-encode to rotate just to re-encode again so it will play in homebridge. Deciphering ffmpeg console output isn't all that easy either. It would be nice if Wyze rotated in hardware in the first place.

Would it help to not rotate in the bridge and then rotate in ffmpeg?

noelhibbard commented 2 years ago

Would it help to not rotate in the bridge and then rotate in ffmpeg?

I considered that but I also feed this camera into Frigate so if I didn't rotate it up front I'd be rotating it in Frigate and in homebridge. I would rotate it in Frigate and then hand that off to homebridge but last time I tried rotating within Frigate I had some other strange issue (in Frigate) but I can't recall what it was. I will have to revisit that.

mrlt8 commented 2 years ago

I kind of remember some of the fflags were causing issues with bitstream filters, so we'll need to figure out what is causing homebridge to choke.

I'll try to do some more testing to match the regular stream.

mrlt8 commented 2 years ago

@noelhibbard I think I have a fix for this! I believe some of the bitstream data was getting lost with the tee muxer. I thought I had patched this in the past, but I think it got lost in one of the branches/commits.

Anyways, I've pushed the changes to the main branch, so you should be able to test it with the edge image.

edit: looks like h264_v4l2m2m is still broken in combination with Homebridge.

noelhibbard commented 2 years ago

@mrlt8, I can confirm this issue is fixed in the edge image. To be clear, I am now able to use ROTATE_DOOR=true and in homebridge-camera-ffmpeg I can now set vcodec to copy. Thanks for the quick fix!

mrlt8 commented 2 years ago

Awesome!

I'm still trying to get hardware acceleration working on the raspberry pi's which works and CPU usage drops from about 150% to about 70% for rotation, but I'm running into a similar issue with the video playing perfectly in VLC but refusing to load in Homebridge.