homebridge-google-nest-sdm
homebridge-google-nest-sdm copied to clipboard
Only set certain FFmpeg args if video encoder is not `'copy'`
This PR handles conditionally setting the FFmpeg arguments related to video transcoding based on the value of vEncoder
.
I'm running Homebridge on an older Raspberry Pi 3 Model B+ (Rev 1.3), and would prefer to not transcode video, unless absolutely necessary. This change worked out nicely for me: before, any sort of video transcoding would spike the CPU usage to 100%. With this change (and setting vEncoder
to 'copy'
), CPU usage hovers around ~25%, and the video/audio streams from my doorbell without any errors.
I'm surprised this works... I remember trying it some time ago and most devices would refuse to display the stream. Can you view it on iPhone's and Apple Watches?
Video from my wired Nest doorbell (2nd generation) works on my iPhone 12, and my Apple TVs. I think it should work on Apple Watches, too, but I don’t have a working one right now to test it on.
I only looked into doing this because I noticed in the FFmpeg logs that it was transcoding from a H264 source back into H264, so it should work as long as the source is H264… and whatever other video formats that Home supports (if there are any others). I think keeping the default value as-is makes sense, but this is a nice option for people who can’t afford transcoding on-the-fly
This is intriguing. When I first made the plugin this was not the case, if the stream was not in the requested resolution the device would simply refuse to display it. Streams come from the SDM API at either 480p/720p/1080p depending on the quality settings in the Nest app.
If it's possible to just pass the stream straight through it may be the case that ffmpeg is not necessary at all... That would make life a lot easier for the plugin users.
My wife has an Apple Watch, I'll try this with it tonight.
I added one more commit but I could do it in a separate PR if that's easier: 5522cb2
I was doing a diff between what is happening here vs. the streamingDelegate
class in the homebridge-camera-ffmpeg
plugin, and the only noticeable difference was the -f rawvideo
flag. It seems to give me better a better audio/video sync, both when transcoding and not transcoding, but it might be a placebo effect 😆
Works on all devices, even if provided resolution is not what is requested. Glad Apple changed that.