UniFi Video plugin for Homebridge, based on homebridge-camera-ffmpeg
This plugin connects your UniFi Video cameras to HomeKit via your UniFi Video NVR.
It automatically finds the RTSP-enabled cameras on the NVR. It then uses ffmpeg to convert the video streams from the NVR into the format HomeKit requires.
The NVR API is undocumented and unsupported. It is subject to change at any time. Use at your own risk.
sudo npm install -g ffmpeg
sudo npm install -g homebridge-camera-ffmpeg-ufv
On your homebridge system, edit config.json to add a platform block like this:
{
"platform": "camera-ffmpeg-ufv",
"name": "UniFi Video (ffmpeg)",
"nvrs": [
{
"apiHost": "nvr-ip-or-hostname.example.com",
"apiPort": 7443,
"apiProtocol": "https",
"apiKey": "<api key from NVR user settings>",
"motionSensors": true
}
]
}
Start or restart homebridge to update the configuration.
HomeKit requires you to add each camera individually. Use the code displayed on the console by homebridge when it starts up.
HTTPS is supported, but we ignore the error caused by NVR's built-in self-signed certificate. This is not secure, and we should handle it better once the NVR supports real certificates.
Raspberry Pi users require a different build of ffmpeg with omx enabled for best results.
This plugin recognizes only the first server configured for an NVR. The UniFi Video API can describe multiple servers per NVR, but it does not seem to identify the server that corresponds to a given camera. The UniFi Video NVR software does not officially support multiple servers. If you're using the unsupported configuration for this, let's talk.
The live stream is delayed by a few seconds while ffmpeg starts the stream client, starts transcoding, and sets up the encryption HomeKit requires. Can this be optimized? Probably.
It doesn't strictly use the highest-quality stream available; rather, it uses the first channel in the array returned by the API. So far, they appear to come back in descending order of quality, so the first one in the array should be the best stream.
Cameras are discovered only when Homebridge starts up. If you add or remove cameras, you will need to restart Homebridge.
This plugin uses the debug module. To see debugging output, run homebridge with a DEBUG env var set:
$ DEBUG=* homebridge # Show debugging output for all modules
$ DEBUG=camera-ffmpeg-ufv homebridge # Show debugging output for this module only
I'm calling it camera-ffmpeg-ufv. 'ffmpeg' is in the name because, while there may be many approaches to this, this one uses ffmpeg. 'ufv' is in the name because 'homebridge-camera-ffmpeg-unifi-video' starts getting lengthy, and besides, I don't want to use 'unifi' in the name and have anyone thinking UBNT is officially providing this plugin. This is not a Ubiquiti product.