Code Monkey home page Code Monkey logo

homebridge-unifi-protect-camera-motion's Introduction

Unifi-Protect-Camera-Motion verified-by-homebridge

Build Status npm donate

This Homebridge plugin allows you to add your Unifi Protect Cameras (and their Motion Sensors) to Homekit. It adds smart detection by using a machine learning model to detect specific classes of objects in the camera view.

How it Works

This plugin will automatically discover all the Unifi cameras from your Protect installation, and provide the following sensors for each one it finds:

  • Camera, for viewing live RTSP streams
  • Motion sensor, for sending push-notifications when motion or one of the desired objects have been detected
  • A Switch, for easily enabling and disabling motion detection (on by default and after a Homebridge restart)
  • A Switch, to trigger a motion event manually, forcing a rich notification
  • (if enabled) A switch, that acts as a doorbell trigger, to manually trigger a rich doorbell notification

Motion Events and object detection

The plugin uses the Unifi Protect API to get motion events on a per camera basis. When motion has been detected one of the two methods below will be used to generate a motion notification in Homekit:

  • The basic method: The "score" of the Unifi Protect motion event. (Which currently has a bug and is 0 as long as the motion is ongoing.)
  • The advanced method: Object detection by use of yolov5. (recommended) This logic/model runs on-device, and no data will be sent to any online/external/cloud source or service. It is based on the coco ssd project.

Installation

Before installing this plugin, please make sure all the prerequisites have been met first. Consult the readme and the wiki before proceeding.

In short, the main dependencies are:

General:

  • Python 3 and pip3 must be installed and on the path!

  • Raspberry Pi / Ubuntu / Debian Linux:

    • Install: sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
    • Install libgl: sudo apt install libgl1
  • Mac OS:

    • Install via Homebrew: brew install pkg-config cairo pango libpng jpeg giflib librsvg
  • Linux:

    • Install g++: sudo apt install g++
    • Install libgl: sudo apt install libgl1
  • Other OSes:

Next, to install this plugin simply type:

sudo npm install homebridge-unifi-protect-camera-motion -g --unsafe-perm=true

Next, open the config.json that contains your Homebridge configuration, and add a block like the following one to the platforms array:

{  
    "platform": "UnifiProtectMotion", 
    "name": "Unifi protect cameras & motion sensors", 
    "unifi": { 
        "controller": "https://protect-ip:controller-ui-port", 
        "controller_rtsp": "rtsp://protect-ip:controller-rtsp-port", 
        "username": "username", 
        "password": "password", 
        "excluded_cameras": [
            "id-of-camera-to-exclude-1",
            "id-of-camera-to-exclude-2"
        ],
        "motion_interval": 5000, 
        "motion_repeat_interval": 30000, 
        "motion_score": 0, 
        "enhanced_motion": true, 
        "enhanced_motion_score": 50, 
        "enhanced_classes": ["person"], 
        "enable_motion_trigger": true,
        "enable_doorbell_for": [
            "id-of-camera-to-act-as-doorbell-1",
            "id-of-camera-to-act-as-doorbell-1"
        ],
        "save_snapshot": true,
        "debug": false, 
        "debug_network_traffic": false,
    },
    "upload_gphotos": false,
    "googlePhotos": {
        "auth_clientId": "CLIENT-ID",
        "auth_clientSecret": "CLIENT-SECRET",
        "auth_redirectUrl": "http://localhost:8888/oauth2-callback"
    },
    "mqtt_enabled": false,
    "mqtt": {
        "broker": "mqtt://broker-ip",
        "username": "MQTT-BROKER-USERNAME",
        "password": "MQTT-BROKER-PASSWORD",
        "topicPrefix": "motion/cameras"
    }
}  

You can verify the correctness of your config file by using jsonlint. The config must be valid or Homebridge will fail to restart correctly. If you are using Homebridge Config X, it will do its best to alert you to any syntax errors it finds.

General configuration fields

Field Type Required Default value Description
platform string yes / UnifiProtectMotion
name string yes / Name of the plugin that shows up in the Homebridge logs
unifi object yes / Wrapper object containing the unifi configuration
upload_gphotos boolean no false Contains a boolean indicating whether or not to upload each detection to a google photos album. When using enhanced mode the image is annotated with the class/score that was detected.
mqtt_enabled boolean no false Set this to true to enable MQTT support. Additional configuration required!
videoProcessor string no ffmpeg Contains the path to an custom FFmpeg binary

Unifi configuration fields

Field Type Required Default value Description
controller string yes / Contains the URL to the CloudKey or UDM with UnifiOS, or as legacy the URL to the Unifi Protect web UI, including port (no / or /protect/ at the end!)
controller_rtsp string yes / Contains the base URL to be used for playing back the RTSP streams, as seen in the RTSP configuration (no / at the end)
username string yes / Contains the username that is used to login in the web UI
password string yes / Contains the password that is used to login in the web UI
excluded_cameras no string[] [] An array that contains the IDs of the cameras which should be excluded from the enumeration in Homekit, all available IDs are printed during startup
motion_interval number yes / Contains the interval in milliseconds used to check for motion, a good default is 5000 milliseconds
motion_repeat_interval number no / Contains the repeat interval in milliseconds during which new motion events will not be triggered if they belong to the same ongoing motion, a good default is 30000 to 60000 milliseconds. This will prevent a bunch of notifications for events which are longer than the motion_interval! Omit this field to disable this functionality
motion_score number yes / Contains the minimum score in % that a motion event has to have to be processed, a good default is 50%, set this to 0 when using enhanced motion!
enhanced_motion boolean yes / Enables or disables the enhanced motion & object detection detection with Tensorflow
enhanced_motion_score number sometimes / This field is required if the enhanced_motion field is set to true and contains the minimum score/certainty in % the enhanced detection should reach before allowing an motion event to be triggered
enhanced_classes string[] sometimes [] This field is required if the enhanced_motion field is set to true and contains an array of classes (in lowercase) of objects to dispatch motion events for. The array should not be empty when using the enhanced detection! Look in look in src/coco/classes.ts for all available classes
enable_motion_trigger boolean no false Contains a boolean that when set to true will enable an extra button for each camera to manually trigger a motion notification
enable_doorbell_for string[] no [] Contains the id of the cameras for which the doorbell functionality should be enabled, all available IDs are printed during startup
save_snapshot boolean no false Contains a boolean indicating whether or not to save each detection to a jpg file in the .homebridge directory. When using enhanced mode the image is annotated with the class/score that was detected.
debug boolean no false Contains a boolean indicating whether or not to enable debug logging for the plugin and FFmpeg
debug_network_traffic boolean no false Contains a boolean indication whether or not to enable logging of all network requests

Google Photos configuration

Field Type Required Default value Description
auth_clientId string sometimes / This field is required when the upload_gphotos is set to true. Fill in the Client ID you generated for OAuth2 authentication
auth_clientSecret string sometimes / This field is required when the upload_gphotos is set to true. Fill in the Client Secret you generated for OAuth2 authentication
auth_redirectUrl string sometimes / Fill in 'http://localhost:8888/oauth2-callback' as a default, if you change this value to something else, also change it when creating the OAuth2 credentials! The port should always be 8888!

To enable the upload to Google Photos functionality please read the relevant wiki article

MQTT configuration

Field Type Required Default value Description
broker string no / This field is required when the enabled field is set to true. Fill in your MQTT broker url, without the port
username string no / This field contains the username for the MQTT broker connection, if any
password string no / This field contains the password for the MQTT broker connection, if any
topicPrefix string no / This field contains the optional topic prefix. Each motion event will be dispatched under topicPrefix/cameraName

Camera configuration

  • Make sure each of your Unifi cameras has at least one RTSP stream enabled. However, I suggest enabling all available qualities for the best user experience as the plugin will choose the most appropriate one based on the request coming from Homekit.
    • To enable an RTSP stream: Login on the Protect web UI and go the settings of the camera and open the 'manage' tab
      Make sure all your cameras have the same port for the RTSP stream!
      For optimal results it is best to assign a static ip to your cameras
      Enable RTSP stream

How to add the cameras to your Homekit setup

As per 0.4.1 the enumerated cameras and accompanying switches/triggers will show up automatically, You don't need to add them in manually anymore! If you add your Homebridge instance to the Home app the cameras will automatically be there.

Upgrade notice

If you are upgrading from a pre 0.4.1 the cameras you previously had in the Home app will no longer work and will have to be removed! Tap on a camera preview to open the camera feed, click the settings icon and scroll all the way to the bottom, there select Remove camera from home.

How to enable rich notifications (with image preview)

  • Go to the settings of the camera view in the Home app
  • Each camera has an accompanying motion sensor
  • Enable notifications for the camera
  • Whenever motion has been detected you will get a notification from the home app with a snapshot from the camera

Tested with

  • Ubuntu VM with node 16
  • UDM Pro with Protect 2.0.x

    CloudKey Gen2 Plus
  • 2x Ubiquiti UniFi Video UVC-G3-AF - PoE Camera


    Camera UVC-G3-AF
  • 2x Ubiquiti Unifi Video UVC-G3-Flex - PoE Camera


    Camera UVC-G3-Flex

Limitations, known issues & TODOs

Limitations

  • Running this plugin on CPUs that do not support AVX (Celerons in NAS systems, ...) is not supported because there are no prebuilt Tensorflow binaries. Compiling Tensorflow from scratch is out of scope for this project!
    • Run it on a Raspberry Pi or machine with macOS / Windows / Linux (Debian based)
  • Unifi Protect has a snapshot saved for every event, and there is an API to get these (with Width & Height), but the actual saved image is pretty low res and is scaled up to 1080p. Using the Anonymous snapshot actually gets a full resolution snapshot which is better for object detection.
  • There is no way to know what motion zone (from Unifi) a motion has occurred in. This information is not present is the response from their API.
  • The enhanced object detection using CoCo is not perfect and might not catch all the thing you want it to. It should do fine in about 95% of cases though.

TODOs

  • Add more unit and integration tests (Ongoing)
  • Add support for MQTT (Ongoing)
  • Upgrade tfjs-node, now held back because newer versions (Upgrade to 2.x.x in future release) (Done)
  • Implement required changes to make this work with Unifi OS
  • Figure out how to get higher res streams on iPhone (only iPad seems to request 720p streams) (Done)
  • Extend documentation & wiki (Done)
  • Add support for two-way audio (Done)

Plugin development

  • Checkout the git repo
  • Run npm install in the project root folder
  • Create a dummy config.json file under resources/test-config/
  • use npm run watch to automatically watch for changes and restart Homebridge if needed, you can also add a remote debugger on port 4444 to debug the code.
  • use npm run homebridge to start a Homebridge instance that points to the local config that does not auto-reload when changes are saved.

Credits

A big thanks to the developers of Homebridge Camera FFmpeg and Homebridge-unifi-protect for their contributions and valuable insights in how to get things working!

Disclaimer

This plugin is provided free of charge and without any warranty of its functionality.
The creator cannot be held responsible for any damages, missed motion notifications that cause damage or harm.

homebridge-unifi-protect-camera-motion's People

Contributors

askovi avatar beele avatar jjj avatar madrobby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

homebridge-unifi-protect-camera-motion's Issues

Get Verified

I would not consider this a high priority but wanted to suggest making this a "Verified" plugin.

TensorFlow binary was not compiled to use: AVX2 FMA

Wondering if you could point me in the right direction. Followed your guide to the T incl switching to the :ubuntu docker release.
Currently using an Intel NUC but getting the following error:
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

Is there a way to re-compile TensorFlow to include AVX2 FMA?

problem saving image on class detection

[5/12/2020, 9:09:35 PM] [Unifi Protect] person detected (95%) by camera Front Doorbell !!!!
(node:14223) UnhandledPromiseRejectionWarning: Cannot save image to disk: ENOENT: no such file or directory, open '/root/.homebridge/snapshot-2020-05-13T01:09:35.839Z.jpg'
(node:14223) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:14223) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

also...would be cool if somehow the class was passed to the alert on homekit, but dont know how...or if there was an MQTT hook somehow.

{
"name": "Unifi Protect",
"unifi": {
"enhanced_classes": [
"person",
"car",
"dog",
"truck",
"cat"
],
"controller": "https://unifi:7443",
"controller_rtsp": "rtsp://unifi:7447",
"username": "adsfasdfasdffff",
"password": "dfadsfad",
"motion_interval": 5000,
"motion_repeat_interval": 30000,
"motion_score": 50,
"enhanced_motion": true,
"enhanced_motion_score": 50,
"save_snapshot": true,
"debug": false
},
"googlePhotos": {
"upload_gphotos": false,
"auth_redirectUrl": "http://localhost:8080/oauth2-callback"
},
"videoConfig": {
"audio": true,
"maxStreams": 4,
"preserveRatio": "W",
"maxFPS": 30,
"mapvideo": "0:1",
"mapaudio": "0:0",
"packetSize": 376
},
"platform": "UnifiProtectMotion"
}

Cameras add to Homebridge but don't show in Home

Are there any known issues with cameras adding successfully to Homebridge but then not showing up in Home? Nothing I do seems to work to add them, but other plugins seem to work as expected. I'm on 1.14.10-beta.4 on a UDM-Pro logging in with Unifi OS credentials.

-Jp

ERROR: FFmpeg exited with code 1

Hi beele,

I do have the same problem with a UVC G3 Pro as @mrhsiao.

[5/24/2020, 13:03:20] [Unifi Protect] Start streaming video from Achterdeur with 640:360@15fps (132kBit)
[5/24/2020, 13:03:28] [Unifi Protect] ERROR: FFmpeg exited with code 1

It is a fresh install with one other plugin installed: Ring.

Cheers.

Doorbell setup

@beele - I'm not personally using your plugin but for the good of the community and all I thought it would be nice to open an issue about the doorbell and share a little about what I'm doing. I'll watch the topic, feel free to ask what I've done.

I've got mine set up now with video, 1-way audio, motion, and doorbell button presses. The first 3 of those should work out of the box with your existing plugin. I'm running button presses very similar to how I'm running motion alerts. The JSON key lastMotion timestamp is used for motion, the JSON key LastRing has the same format but will show the last time the button was pressed. I have a linked service programmable switch to the camera service to send the doorbell button press. Rich button notifications work great, here's the live view notification after a fedex drop off yesterday:

IMG_5747

I'm looking over the JSON trying to see what else might be useful - type: "UVC G4 Doorbell". Also the aspect ration is 4:3, my G3 flex cameras are 16:9. Still no 2-way audio success yet, I'm still working on that with the developer for @NRCHKB - I'll update #39 if we get that going.

Full JSON (partly redacted):

{
  "isDeleting": false,
  "mac": "*****",
  "host": "*****",
  "connectionHost": "*****",
  "type": "UVC G4 Doorbell",
  "name": "UVC G4 Doorbell",
  "upSince": 1590241611080,
  "lastSeen": 1590783905442,
  "connectedSince": 1590241638032,
  "state": "CONNECTED",
  "hardwareRevision": "20",
  "firmwareVersion": "4.23.7",
  "firmwareBuild": "ae5c6d8.200507.1038",
  "isUpdating": false,
  "isAdopting": false,
  "isManaged": true,
  "isProvisioned": true,
  "isRebooting": false,
  "isSshEnabled": false,
  "canManage": false,
  "isAttemptingToConnect": false,
  "isHidden": false,
  "lastMotion": 1590783863818,
  "micVolume": 100,
  "isMicEnabled": true,
  "isRecording": true,
  "isMotionDetected": false,
  "phyRate": 200,
  "hdrMode": true,
  "isProbingForWifi": false,
  "apMac": "*****",
  "apRssi": 60,
  "elementInfo": "Hello",
  "chimeDuration": 300,
  "isDark": false,
  "lastRing": 1590701536006,
  "wiredConnectionState": {
    "phyRate": null
  },
  "channels": [
    {
      "id": 0,
      "videoId": "video1",
      "name": "High",
      "enabled": true,
      "isRtspEnabled": true,
      "rtspAlias": "*****",
      "width": 1600,
      "height": 1200,
      "fps": 30,
      "bitrate": 6000000,
      "minBitrate": 750000,
      "maxBitrate": 6000000,
      "minClientAdaptiveBitRate": 0,
      "minMotionAdaptiveBitRate": 750000,
      "fpsValues": [
        1,
        2,
        3,
        4,
        5,
        6,
        8,
        9,
        10,
        12,
        15,
        16,
        18,
        20,
        24,
        25,
        30
      ],
      "idrInterval": 5
    },
    {
      "id": 1,
      "videoId": "video3",
      "name": "Medium",
      "enabled": true,
      "isRtspEnabled": true,
      "rtspAlias": "*****",
      "width": 960,
      "height": 720,
      "fps": 15,
      "bitrate": 1200000,
      "minBitrate": 750000,
      "maxBitrate": 2000000,
      "minClientAdaptiveBitRate": 150000,
      "minMotionAdaptiveBitRate": 750000,
      "fpsValues": [
        1,
        2,
        3,
        4,
        5,
        6,
        8,
        9,
        10,
        12,
        15,
        16,
        18,
        20,
        24,
        25,
        30
      ],
      "idrInterval": 5
    },
    {
      "id": 2,
      "videoId": "video2",
      "name": "Low",
      "enabled": true,
      "isRtspEnabled": false,
      "rtspAlias": null,
      "width": 480,
      "height": 360,
      "fps": 15,
      "bitrate": 200000,
      "minBitrate": 32000,
      "maxBitrate": 1000000,
      "minClientAdaptiveBitRate": 0,
      "minMotionAdaptiveBitRate": 0,
      "fpsValues": [
        1,
        2,
        3,
        4,
        5,
        6,
        8,
        9,
        10,
        12,
        15,
        16,
        18,
        20,
        24,
        25,
        30
      ],
      "idrInterval": 5
    }
  ],
  "ispSettings": {
    "aeMode": "auto",
    "irLedMode": "auto",
    "irLedLevel": 255,
    "wdr": 1,
    "icrSensitivity": 0,
    "brightness": 50,
    "contrast": 50,
    "hue": 50,
    "saturation": 50,
    "sharpness": 50,
    "denoise": 50,
    "isFlippedVertical": false,
    "isFlippedHorizontal": false,
    "isAutoRotateEnabled": false,
    "isLdcEnabled": true,
    "is3dnrEnabled": true,
    "isExternalIrEnabled": false,
    "isAggressiveAntiFlickerEnabled": false,
    "isPauseMotionEnabled": false,
    "dZoomCenterX": 50,
    "dZoomCenterY": 50,
    "dZoomScale": 0,
    "dZoomStreamId": 4,
    "focusMode": "ztrig",
    "focusPosition": 0,
    "touchFocusX": 0,
    "touchFocusY": 0,
    "zoomPosition": 0
  },
  "talkbackSettings": {
    "typeFmt": "aac",
    "typeIn": "serverudp",
    "bindAddr": "0.0.0.0",
    "bindPort": 7004,
    "filterAddr": "",
    "filterPort": 0,
    "channels": 1,
    "samplingRate": 22050,
    "bitsPerSample": 16,
    "quality": 100
  },
  "osdSettings": {
    "isNameEnabled": false,
    "isDateEnabled": false,
    "isLogoEnabled": false,
    "isDebugEnabled": false
  },
  "ledSettings": {
    "isEnabled": true,
    "blinkRate": 0
  },
  "speakerSettings": {
    "isEnabled": false,
    "areSystemSoundsEnabled": false,
    "volume": 80
  },
  "recordingSettings": {
    "prePaddingSecs": 3,
    "postPaddingSecs": 3,
    "minMotionEventTrigger": 1000,
    "endMotionEventDelay": 3000,
    "suppressIlluminationSurge": false,
    "mode": "always",
    "geofencing": "off",
    "useNewMotionAlgorithm": true,
    "enablePirTimelapse": false
  },
  "recordingSchedule": null,
  "motionZones": [
    {
      "name": "Default",
      "color": "#AB46BC",
      "points": [
        [
          0,
          0.4265402843601896
        ],
        [
          0.09577779134114583,
          0.5781990702118354
        ],
        [
          0.37144441731770833,
          0.5570094786729857
        ],
        [
          0.6984444173177083,
          0.6138057595203272
        ],
        [
          0.6996666666666667,
          0.20260663507109006
        ],
        [
          1,
          0
        ],
        [
          1,
          1
        ],
        [
          0,
          1
        ]
      ],
      "sensitivity": 75
    }
  ],
  "privacyZones": [],
  "stats": {
    "rxBytes": 3849943834,
    "txBytes": 152165032072,
    "wifi": {
      "channel": 44,
      "frequency": 5220,
      "linkSpeedMbps": null,
      "signalQuality": 100,
      "signalStrength": -58
    },
    "battery": {
      "percentage": null,
      "isCharging": false,
      "sleepState": "awake"
    },
    "video": {
      "recordingStart": 1590102789906,
      "recordingEnd": 1590783934679,
      "recordingStartLQ": 1590102794930,
      "recordingEndLQ": 1590783934719,
      "timelapseStart": 1590102789919,
      "timelapseEnd": 1590783479690,
      "timelapseStartLQ": 1590102789919,
      "timelapseEndLQ": 1590782419641
    },
    "wifiQuality": 100,
    "wifiStrength": -58
  },
  "featureFlags": {
    "canAdjustIrLedLevel": false,
    "canMagicZoom": false,
    "canOpticalZoom": false,
    "canTouchFocus": false,
    "hasAccelerometer": false,
    "hasAec": true,
    "hasBattery": false,
    "hasBluetooth": true,
    "hasChime": true,
    "hasExternalIr": false,
    "hasIcrSensitivity": true,
    "hasLdc": true,
    "hasLedIr": true,
    "hasLedStatus": true,
    "hasLineIn": false,
    "hasMic": true,
    "hasPrivacyMask": true,
    "hasRtc": false,
    "hasSdCard": false,
    "hasSpeaker": true,
    "hasWifi": true,
    "hasHdr": true,
    "hasAutoICROnly": true,
    "hasMotionZones": true,
    "hasLcdScreen": true
  },
  "pirSettings": {
    "pirSensitivity": 100,
    "pirMotionClipLength": 15,
    "timelapseFrameInterval": 15,
    "timelapseTransferInterval": 600
  },
  "lcdMessage": {},
  "wifiConnectionState": {
    "channel": 44,
    "frequency": 5220,
    "phyRate": 200,
    "signalQuality": 100,
    "signalStrength": -58
  },
  "id": "5ec6fd10020d470387000407",
  "isConnected": true,
  "platform": "s5l",
  "hasSpeaker": true,
  "hasWifi": true,
  "audioBitrate": 64000,
  "modelKey": "camera"
}

HomeKit does not find the 4th camera

I was able to find 3 cameras very easily in my home app. One camera though just wasnt to be found. It works fine on a previous homebridge-ufp plugin so I know its able to be added. Its the driveway camera. As you can see home bridge finds it but HomeKit never sees it. HomeKit only sees front yard, back porch, and garage.

[4/18/2020, 4:34:47 AM] [Unifi protect cameras & motion sensors] Endpoint Style: Unifi Protect (Legacy)
[4/18/2020, 4:34:47 AM] [Unifi protect cameras & motion sensors] WARNING: No previous session found, a new session must be created!
[4/18/2020, 4:34:47 AM] [Unifi protect cameras & motion sensors] Authenticated, returning session
[4/18/2020, 4:34:47 AM] [Unifi protect cameras & motion sensors] Cameras retrieved, enumerating motion sensors
[4/18/2020, 4:34:47 AM] [Unifi protect cameras & motion sensors] Cameras: 4
[4/18/2020, 4:34:48 AM] [Unifi protect cameras & motion sensors] Motion checking setup done!
[4/18/2020, 4:34:48 AM] [Unifi protect cameras & motion sensors] Setup done
[4/18/2020, 4:34:48 AM] Back Porch is running on port 52101.
[4/18/2020, 4:34:48 AM] Please add [Back Porch ] manually in Home app. Setup Code: 111-82-887
[4/18/2020, 4:34:48 AM] Garage is running on port 52102.
[4/18/2020, 4:34:48 AM] Please add [Garage ] manually in Home app. Setup Code: 111-82-887
[4/18/2020, 4:34:48 AM] Front Yard is running on port 52103.
[4/18/2020, 4:34:48 AM] Please add [Front Yard] manually in Home app. Setup Code: 111-82-887
[4/18/2020, 4:34:48 AM] Driveway is running on port 52104.
[4/18/2020, 4:34:48 AM] Please add [Driveway] manually in Home app. Setup Code: 111-82-887

Support UniFi OS (UDM Pro on versions >1.6)

The latest version of the UDM Pro firmware proxies all requests to controllers, allowing SSO to all controllers hosted on it. It is no longer possible to authenticate directly to Protect.

Per UI-taka on the Ubiquiti discord:

you need to auth to the device first via /api/login, then the actual paths to protect are different, prefixed with /proxy/protect

From what I've seen, UniFi OS will be coming to the Cloud Key Gen 2 Plus, as well as the UniFi NVR, so this will be a hurdle that will have to be crossed.

Video Issues

Using a docker container with FFMPEG: oznu/homebridge

1 - enabling audio causes ffmpeg exit code 1 and nothing happens. Is there a way I can debug this?

2 - video generally doesnt seem to work: it sends a still every 15-30 seconds. I have tinkered with bitrate/fps/size to see if I can speed this up, but no luck.

homebridge is on an ubuntu full intel (no rpi, diskstation, etc...) on gigabit ethernet.

Issue installing plugin

@beele
I'm currently running homebridge on HOOBS.
I've tried to install the version 0.0.6 but got this error:
npm WARN tar ENOENT: no such file or directory, open '/usr/local/lib/node_modules/.staging/homebridge-unifi-protect-camera-motion-5fbbbe69/resources/models/coco/mobilenet_v2/group1-shard3of17'
npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! https://npm.community
[ ...........] \ extract:homebridge-unifi-protect-camera-motion: verb loc
npm ERR! A complete log of this run can be found in:
npm ERR! /home/hoobs/.npm/_logs/2019-12-21T14_27_57_544Z-debug.log
[ ...........] \ extract:homebridge-unifi-protect-camera-motion: verb loc
Command failed. Please review log for details.

@tensorflow/[email protected] install /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node
node scripts/install.js

CPU-linux-1.5.1.tar.gz

  • Downloading libtensorflow
    (node:6449) UnhandledPromiseRejectionWarning: Error: Unsupported system: cpu-linux-arm
    at getPlatformLibtensorflowUri (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node/scripts/install.js:95:11)
    at downloadLibtensorflow (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node/scripts/install.js:129:7)
    (node:6449) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:6449) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[email protected] install /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.1/canvas-v2.6.1-node-v64-linux-glibc-arm.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, glibc) (falling back to source compile with node-gyp)
Package pixman-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing pixman-1.pc' to the PKG_CONFIG_PATH environment variable No package 'pixman-1' found gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: gypfailed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16) gyp ERR! stack at ChildProcess.emit (events.js:198:13) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12) gyp ERR! System Linux 4.19.58-v7+ gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64" gyp ERR! cwd /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas gyp ERR! node -v v10.16.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1) node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/node-pre-gyp/lib/util/compile.js:83:29) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:198:13) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:982:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) node-pre-gyp ERR! System Linux 4.19.58-v7+ node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas node-pre-gyp ERR! node -v v10.16.0 node-pre-gyp ERR! node-pre-gyp -v v0.11.0 node-pre-gyp ERR! not ok Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] install:node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/hoobs/.npm/_logs/2019-12-21T14_29_12_159Z-debug.log

Unifi protect update breaks responsive detection

After updating my protect to the latest software it seems that the score of ongoing motion events is set to 0 until it's finished. This wasn't the case before and kinda breaks how motion detection works

After a protect motion event with a given score is found then it is passed on to the enhanced motion checker. Because this event with the valid score now comes much much later the actual object to detect can have moved out of frame before the detection runs (can be 1 and a half minute before the score 'settles')

I'll be looking into this to fix how this works.
For now a workaround can be to lower the motion_score param to 0

No snapshot / live feed - FFMPEG error 2

@beele continuing here. Thanks so much for your support.

Quick recap of issue:

  • Once cameras are added to HomeKit I am getting a "failed to get snapshot" and then when clicking through the camera FFmpeg crashes with an error 2.

I just took the following steps:

This is the log output:

Log Dump.txt

Refactor camera logic to a more modern implementation

When restarting Homebridge, the Homebridge log says "Please add" on each of the cameras, even if/when they've already been added. As a user, this makes it appear like the cameras were inadvertently removed and need to be re-added again.

[5/12/2020, 2:18:43 PM] [Unifi protect cameras & motion sensors] Motion checking setup done!
[5/12/2020, 2:18:46 PM] [Unifi protect cameras & motion sensors] Setup done
[5/12/2020, 2:18:46 PM] Camera (<snip>) is running on port 52100.
[5/12/2020, 2:18:46 PM] Please add [Camera (<snip>)] manually in Home app. Setup Code: <snip>
[5/12/2020, 2:18:46 PM] Camera (<snip>) is running on port 52101.
[5/12/2020, 2:18:46 PM] Please add [Camera (<snip>)] manually in Home app. Setup Code: <snip>
[5/12/2020, 2:18:46 PM] Camera (<snip>) is running on port 52102.
[5/12/2020, 2:18:46 PM] Please add [Camera (<snip>)] manually in Home app. Setup Code: <snip>
[5/12/2020, 2:18:46 PM] Camera (<snip>) is running on port 52103.
[5/12/2020, 2:18:46 PM] Please add [Camera (<snip>)] manually in Home app. Setup Code: <snip>

I'm not sure if there is an easy way to identify if specific cameras have already been added to HomeKit or not, but if it is in fact possible to do, I think some confirmation that each camera was found and does not need to be added would be a bit more reassuring.

Doesn't install on Pi

pi@raspberrypi:~ $ sudo npm install homebridge-unifi-protect-camera-motion -g --unsafe-perm=true
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)

@tensorflow/[email protected] install /usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node
node scripts/install.js

CPU-linux-1.2.11.tar.gz

  • Downloading libtensorflow
    [==============================] 7346594/bps 100% 0.0s
  • Building TensorFlow Node.js bindings

[email protected] install /usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.1/canvas-v2.6.1-node-v79-linux-glibc-arm.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v79 ABI, glibc) (falling back to source compile with node-gyp)
Package pixman-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing pixman-1.pc' to the PKG_CONFIG_PATH environment variable No package 'pixman-1' found gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: gypfailed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16) gyp ERR! stack at ChildProcess.emit (events.js:315:20) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) gyp ERR! System Linux 4.19.97-v7l+ gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release" "--napi_version=6" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v79"gyp ERR! cwd /usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas gyp ERR! node -v v13.12.0 gyp ERR! node-gyp -v v5.1.0 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v79' (1) node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/node-pre-gyp/lib/util/compile.js:83:29) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1026:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) node-pre-gyp ERR! System Linux 4.19.97-v7l+ node-pre-gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd /usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas node-pre-gyp ERR! node -v v13.12.0 node-pre-gyp ERR! node-pre-gyp -v v0.11.0 node-pre-gyp ERR! not ok Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v79' (1) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] install:node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-04-02T16_40_44_821Z-debug.log

No streaming

HI, great implementation but i can't see the streaming RTSP.
I have set the port of RTSP 7447 and reduce the max resolution to 640x360 but i only see the updated snapshot but not the streaming...
homebridge is installed on macOS, any idea?
thanks

HOOBS not finding any cameras

Hi,

I am trying to install the plugin, and have followed all steps and included the script on the config.json, however in the logs I see the following:

22/07/2020, 17:27:01 The requested platform "UnifiProtectMotion" was not registered by any plugin.
22/07/2020, 17:27:01 Your config.json is requesting the platform "UnifiProtectMotion" which has not been published by any installed plugins.

Any insights as to what can be happening?

Also, I am using a UDM-Pro with the UniFi Protect controller installed, and when I access https://192.168.1.1:7443 (HTTPS Port), I see "An unrecoverable error has occurred!", could it be related to that?

Thanks.

After installing, homebridge fails to start

Running homebridge as a service on ubuntu 18.04 on small form factor PC. Only other plugin is homebridge-config-ui-x. After install, get same core dump when starting homebridge. Tried with valid config and with no config defining homebridge-unifi-protect-motion-sensors. Install seems to go fine even time.

Jan 07 09:54:47 homebridge-01b systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
Jan 07 09:54:47 homebridge-01b systemd[1]: Started Homebridge.
Jan 07 09:54:48 homebridge-01b homebridge[12175]: [1/7/2020, 9:54:48 AM] Loaded config.json with 0 accessories and 1 platforms.
Jan 07 09:54:48 homebridge-01b homebridge[12175]: [1/7/2020, 9:54:48 AM] ---
Jan 07 09:54:49 homebridge-01b homebridge[12175]: [1/7/2020, 9:54:49 AM] ---
Jan 07 09:54:49 homebridge-01b homebridge[12175]: [1/7/2020, 9:54:49 AM] Loaded plugin: homebridge-config-ui-x
Jan 07 09:54:49 homebridge-01b homebridge[12175]: [1/7/2020, 9:54:49 AM] Registering platform 'homebridge-config-ui-x.config'
Jan 07 09:54:49 homebridge-01b homebridge[12175]: [1/7/2020, 9:54:49 AM] ---
Jan 07 09:54:52 homebridge-01b systemd[1]: homebridge.service: Main process exited, code=dumped, status=4/ILL
Jan 07 09:54:52 homebridge-01b systemd[1]: homebridge.service: Failed with result 'core-dump'.
Jan 07 09:54:55 homebridge-01b systemd[1]: homebridge.service: Service hold-off time over, scheduling restart.
Jan 07 09:54:55 homebridge-01b systemd[1]: homebridge.service: Scheduled restart job, restart counter is at 1.

Issue after update

Hi @beele, I've just made the update that you released today but got this error.
at API.platform (/home/hoobs/.hoobs/node_modules/@hoobs/homebridge/lib/api.js:115:19) at Server._loadPlatforms (/home/hoobs/.hoobs/node_modules/@hoobs/homebridge/lib/server.js:283:47) at Server.run (/home/hoobs/.hoobs/node_modules/@hoobs/homebridge/lib/server.js:74:14) at module.exports (/home/hoobs/.hoobs/node_modules/@hoobs/homebridge/lib/cli.js:90:12) at Object.<anonymous> (/home/hoobs/.hoobs/node_modules/@hoobs/homebridge/bin/homebridge:10:63) at Module._compile (internal/modules/cjs/loader.js:959:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10) at Module.load (internal/modules/cjs/loader.js:815:32) at Function.Module._load (internal/modules/cjs/loader.js:727:14) at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)

Work with Docker

Does this work with a Docker install of HomeBridge (using oznu/homebridge)? I'm getting the following error and I'm not sure if it's because of the docker install or not:

> @tensorflow/[email protected] install /homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node
> node scripts/install.js

CPU-linux-1.2.11.tar.gz
* Downloading libtensorflow
[==============================] 32460038/bps 100% 0.0s
* Building TensorFlow Node.js bindings

> [email protected] install /homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(404): https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.0/canvas-v2.6.0-node-v64-linux-musl-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, musl) (falling back to source compile with node-gyp) 
Package pixman-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `pixman-1.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pixman-1', required by 'virtual:world', not found
gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.15.0-65-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
gyp ERR! cwd /homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:982:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Linux 4.15.0-65-generic
node-pre-gyp ERR! command "/usr/local/bin/node" "/homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
node-pre-gyp ERR! node -v v10.16.3
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-10-18T20_47_48_258Z-debug.log

Command failed. Please review log for details.

G4 pro with ERROR: FFmpeg exited with code 1

Here is the log:

[Homebridge] [3/21/2020, 18:35:28] [Unifi protect cameras & motion sensors] Start streaming video from UVC G4 Pro 05F1 with 640x360@132kBit
[Homebridge] [3/21/2020, 18:35:28] [Unifi protect cameras & motion sensors] ERROR: FFmpeg exited with code 1

I did follow the ffmpeg install guide. and the platform is Raspberry Pi 4B with HOOBS

Thanks!

tensorflow install issue

5081 verbose cwd /home/pi
5082 verbose Linux 4.19.118-v7l+
5083 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "homebridge-unifi-protect-camera-motion" "-g" "--unsafe-perm=true"
5084 verbose node v12.18.1
5085 verbose npm v6.14.5
5086 error code ELIFECYCLE
5087 error errno 1
5088 error @tensorflow/[email protected] install: node scripts/install.js
5088 error Exit status 1
5089 error Failed at the @tensorflow/[email protected] install script.
5089 error This is probably not a problem with npm. There is likely additional logging output above.
5090 verbose exit [ 1, true ]
pi@homebridge:~$ npm i @tensorflow/[email protected]

@tensorflow/[email protected] install /home/pi/node_modules/@tensorflow/tfjs-node
node scripts/install.js

CPU-linux-1.2.11.tar.gz

  • Downloading libtensorflow
    events.js:292
    throw er; // Unhandled 'error' event
    ^

Error: unable to verify the first 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)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (_http_client.js:426:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
}
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @tensorflow/[email protected] install: node scripts/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @tensorflow/[email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Unable to install on Synology+Docker

Any leads on how to resolve this?

/homebridge # sudo npm install homebridge-unifi-protect-camera-motion -g --unsafe-perm=true
npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EAI_AGAIN: request to https://registry.npmjs.org/homebridge-unifi-protect-camera-motion failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
npm WARN registry Using stale data from https://registry.npmjs.org/ due to a request error during revalidation.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142

> [email protected] install /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/ffmpeg-for-homebridge
> node install.js

ffmpeg version 4.2.git-47773f7 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.0 (Alpine 9.2.0)
  configuration: --pkgconfigdir=/build/workspace/lib/pkgconfig --prefix=/build/workspace --pkg-config-flags=--static --extra-cflags=-I/build/workspace/include --extra-ldflags=-L/build/workspace/lib --extra-libs='-lpthread -lm' --enable-static --disable-debug --disable-shared --disable-ffplay --disable-doc --enable-openssl --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-libvpx --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libx264 --enable-runtime-cpudetect --enable-libfdk-aac --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-decoder=h264 --enable-network --enable-protocol=tcp --enable-demuxer=rtsp
  libavutil      56. 40.100 / 56. 40.100
  libavcodec     58. 68.102 / 58. 68.102
  libavformat    58. 38.100 / 58. 38.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 75.100 /  7. 75.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100

ffmpeg has been downloaded to /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/ffmpeg-for-homebridge/ffmpeg
Thank you for using https://github.com/homebridge/ffmpeg-for-homebridge


> @tensorflow/[email protected] install /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node
> node scripts/install.js

CPU-linux-1.2.11.tar.gz
* Downloading libtensorflow
[==============================] 8116154/bps 100% 0.0s
* Building TensorFlow Node.js bindings

> [email protected] install /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(404): https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.1/canvas-v2.6.1-node-v72-linux-musl-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI, musl) (falling back to source compile with node-gyp) 
Package pixman-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `pixman-1.pc'
to the PKG_CONFIG_PATH environment variable
Package 'pixman-1', required by 'virtual:world', not found
gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:311:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 4.4.59+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:311:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Linux 4.4.59+
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
node-pre-gyp ERR! node -v v12.16.1
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-04-28T02_43_06_049Z-debug.log

Unifi OS: Authenticated, returning session - Cannot get cameras

Describe the bug
Installed the plugin and finally got it to Authenticate. I'm using a UDMP with Unifi-OS.

Specifications
RPBi4
UDMP - UnifiOS

Logging
[Unifi protect cameras & motion sensors] Authenticated, returning session
[Unifi protect cameras & motion sensors] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: Invalid response, missing: cameras on data

Two way audio with the doorbell?

I just scored a G4 doorbell on the beta store.

The API should have everything needed for motion and button alerts. I'm pretty well set there.

When it comes I'm planning to get working on two way audio ... does anyone have any pointers or tips on this? I'm unsure whether HAP-nodejs and/or homebridge has completely figured out two way audio. Also unsure how the two way audio works on the doorbell. It'll certainly be a project to figure out.

Does anyone around here have a micro g3? I know those have two way audio features...

If you'd like, let's use this issue to discuss our findings. If this is out of scope for this project just let me know and I'll look for help elsewhere.

Tidy up log messages

Any chance you could remove all the extra's from the logs? Even when debug is not enabled there is a lot of info clogging up the logs. For example strings with !!!! at the start and end and the event ID's. Realistically this should only be shown if the debug is enabled.

I have this currently...
Screenshot 2020-03-31 at 150546

But this looks much cleaner...
Screenshot 2020-03-31 at 150559

HOOBS install recognizes cameras, but they don't appear in Homekit

[Homebridge] [2/7/2020, 11:49:26 AM] API launched
[Homebridge] [2/7/2020, 11:49:27 AM] [Unifi protect cameras & motion sensors] Authenticated, returning session
[Homebridge] [2/7/2020, 11:49:27 AM] [Unifi protect cameras & motion sensors] Cameras retrieved, enumerating motion sensors
[Homebridge] [2/7/2020, 11:49:27 AM] [Unifi protect cameras & motion sensors] Cameras: 5
[Homebridge] [2/7/2020, 11:49:27 AM] [Unifi protect cameras & motion sensors] Setup done
[Homebridge] [2/7/2020, 11:49:27 AM] [Living Room] is running on port 45549.
[Homebridge] [2/7/2020, 11:49:27 AM] [Office] is running on port 33419.
[Homebridge] [2/7/2020, 11:49:27 AM] [Stairs] is running on port 45781.
[Homebridge] [2/7/2020, 11:49:27 AM] [Bedroom] is running on port 41093.
[Homebridge] [2/7/2020, 11:49:27 AM] [Kitchen] is running on port 37691.```

Hoobs shows that cameras are found, however they don't appear anywhere, have tried rebooting, and readding the plugin. Unsure if this is a HOOBS issue, or protect.

UnhandledPromiseRejectionWarning: Error: Cannot load image!

Receiving the following error in my logs anytime motion is detected if enable anonymous snapshots is not enable. This Error should be handled more gracefully to advise the user what the issue is.

(node:3606) UnhandledPromiseRejectionWarning: Error: Cannot load image!
    at Function.<anonymous> (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/src/coco/loader.js:42:23)
    at Generator.throw (<anonymous>)
    at rejected (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/src/coco/loader.js:6:65)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
(node:3606) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 25)```

Failed Install on RPi Stretch Lite

I keep getting this error when trying to install on RPi 3b+ and node.js 11.15.0. I'm a noob so I'm not sure what needs to be done.

pi@raspberrypi2:~ $ sudo npm install homebridge-unifi-protect-camera-motion -g --unsafe-perm=true

@tensorflow/[email protected] install /usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node
node scripts/install.js

CPU-linux-1.3.2.tar.gz

  • Downloading libtensorflow
    [==============================] 11496/bps 100% 0.0s
  • Building TensorFlow Node.js bindings

[email protected] install /usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.0/canvas-v2.6.0-node-v67-linux-glibc-arm.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v67 ABI, glibc) (falling back to source compile with node-gyp)
Package pixman-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `pixman-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pixman-1' found
gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:193:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:255:12)
gyp ERR! System Linux 4.19.75-v7+
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v67"
gyp ERR! cwd /usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
gyp ERR! node -v v11.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v67' (1)
node-pre-gyp ERR! stack at ChildProcess. (/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:193:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:999:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:266:5)
node-pre-gyp ERR! System Linux 4.19.75-v7+
node-pre-gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
node-pre-gyp ERR! node -v v11.15.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v67' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-11-19T06_10_14_452Z-debug.log

Plugin incorrectly using Platform Name instead of Plugin Identifier

Although the plugin is working, I am receiving this error in my logs.

[5/7/2020, 08:44:20] One of your plugins incorrectly registered an external accessory using the platform name (Unifi-Protect-Camera-Motion) and not the plugin identifier. Please report this to the developer!

Install on

I am getting a failure when I try to install. I am using the official Raspberry Pi Image. Any suggestions?

`USER: pi
DIR: /usr/local/lib
CMD: sudo -E -n npm install homebridge-unifi-protect-camera-motion@latest

npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142

[email protected] install /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/ffmpeg-for-homebridge
node install.js

ffmpeg version 4.2.git-47773f7 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
configuration: --pkgconfigdir=/build/workspace/lib/pkgconfig --prefix=/build/workspace --pkg-config-flags=--static --extra-cflags=-I/build/workspace/include --extra-ldflags=-L/build/workspace/lib --extra-libs='-lpthread -lm' --enable-static --disable-debug --disable-shared --disable-ffplay --disable-doc --enable-openssl --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-libvpx --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libx264 --enable-runtime-cpudetect --enable-libfdk-aac --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-decoder=h264 --enable-network --enable-protocol=tcp --enable-demuxer=rtsp --enable-omx-rpi --enable-mmal
libavutil 56. 40.100 / 56. 40.100
libavcodec 58. 68.102 / 58. 68.102
libavformat 58. 38.100 / 58. 38.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 75.100 / 7. 75.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100

ffmpeg has been downloaded to /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/ffmpeg-for-homebridge/ffmpeg
Thank you for using https://github.com/homebridge/ffmpeg-for-homebridge

@tensorflow/[email protected] install /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node
node scripts/install.js

CPU-linux-1.2.11.tar.gz

  • Downloading libtensorflow
    [==============================] 3941405/bps 100% 0.0s
  • Building TensorFlow Node.js bindings

[email protected] install /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas
node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.1/canvas-v2.6.1-node-v72-linux-glibc-arm.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI, glibc) (falling back to source compile with node-gyp)
Package pixman-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing pixman-1.pc' to the PKG_CONFIG_PATH environment variable No package 'pixman-1' found gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: gypfailed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16) gyp ERR! stack at ChildProcess.emit (events.js:310:20) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) gyp ERR! System Linux 4.19.97-v7l+ gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72" gyp ERR! cwd /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas gyp ERR! node -v v12.16.2 gyp ERR! node-gyp -v v5.1.0 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1) node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/node-pre-gyp/lib/util/compile.js:83:29) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:310:20) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) node-pre-gyp ERR! System Linux 4.19.97-v7l+ node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas node-pre-gyp ERR! node -v v12.16.2 node-pre-gyp ERR! node-pre-gyp -v v0.11.0 node-pre-gyp ERR! not ok Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/canvas/build/Release --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] install:node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2020-05-20T16_11_23_071Z-debug.log

Command failed. Please review log for details.
`

(Asking for help, not a bug...) Compiling Tensorflow on a Synology NAS

So for months I used to use this plugin on my Raspberry Pi with my UniFi Protect setup and I used to love it, but when I abandoned the Pi for Homebridge use and migrated my entire Homebridge setup to my Synology 918+, I was unaware that this plugin would no longer be compatible.

As it was explained to me, the current prebuilt version of Tensorflow (needed for this plugin to work) is not compatible with the type of CPU in my NAS and needs to be compiled from scratch.

I found an alternative plugin that adds UniFi Protect cameras to HomeKit, and it works great for streaming the video and getting snapshots, however it does not support motion alerts

Now, I have tried to look for guides, reach out for help, and see if I can find any type of step-by-step guide that would help me achieve this, but for months, I've had no luck. I am not very command-line savvy and rely heavily on tutorials and guides to get my setup going and always try to learn as much as I can as I go along.

I know the easy thing to do would be simply go back to using the Pi for this plugin, but at this point this is no longer an option.

My ask is this.... if someone, anyone, has the time or generosity to guide me through compiling the Tensorflow / Canvas build needed for me to run this plugin in a Homebridge instance on my Synology NAS... I would be forever in your debt.

Shared library not found - plugin will not load

@beele trying to move to the new plugin, running in oznu/homebridge docker container on Synology (Intel). Install seems to work but looks like a dependency is missing post install for tensorflow. This occurs post install on restart.

[2/6/2020, 9:44:40 AM] ====================
[2/6/2020, 9:44:40 AM] ERROR LOADING PLUGIN homebridge-unifi-protect-camera-motion:
[2/6/2020, 9:44:40 AM] Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node/lib/napi-v4/../../deps/lib/libtensorflow.so.1)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1021:18)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node/dist/index.js:44:16)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
[2/6/2020, 9:44:40 AM] ====================

Node version is 12.14.1

config is empty, adding config for plugin results in additional errors due to the plugin failing to load.
let me know if you need any other details.

Platform name error after update.

I'm receiving an error due to the platform name...Initially I thought it's because that setting has changed and those with existing config need to update and use the UI Settings panel, but even upon changing it I still receive the error.

[5/13/2020, 12:05:56] Error loading platform requested in your config.json at position 5 [5/13/2020, 12:05:56] Error: The requested platform 'UnifiProtectMotion' was not registered by any plugin. at PluginManager.getPluginForPlatform (/usr/local/lib/node_modules/homebridge/src/pluginManager.ts:223:15) at /usr/local/lib/node_modules/homebridge/src/server.ts:386:37 at Array.forEach (<anonymous>) at Server.loadPlatforms (/usr/local/lib/node_modules/homebridge/src/server.ts:373:27) at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:152:29) at cli (/usr/local/lib/node_modules/homebridge/src/cli.ts:78:10) at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22) at Module._compile (internal/modules/cjs/loader.js:955:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10) at Module.load (internal/modules/cjs/loader.js:811:32) at Function.Module._load (internal/modules/cjs/loader.js:723:14) at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) at internal/main/run_main_module.js:17:11 [5/13/2020, 12:05:56] Got SIGTERM, shutting down Homebridge... homebridge.service: Main process exited, code=exited, status=143/n/a homebridge.service: Failed with result 'exit-code'.

Support for not using @tensorflow/tfjs-node (FreeBSD)

I've been running homebridge-camera-ffmpeg for a long time but I want to switch to your plugin to make use of motion events.

Since I'm running FreeBSD, ffmpeg-for-homebridge gives the error ffmpeg-for-homebridge: freebsd x64 is not supported, you will need to install/compile ffmpeg manually. And I have done this, since homebridge-camera-ffmpeg works fine with it.

homebridge-camera-ffmpeg allows for falling back to global ffmpeg, can your plugin do the same?
https://github.com/homebridge-plugins/homebridge-camera-ffmpeg/blob/master/CHANGELOG.md#v100-2020-05-11

Audio Support?

nice work @beele ! I was wondering if you had an estimate on when you think audio will be supported?

Snapshot Saved Too Late

All the snapshots being saved are maybe 15 seconds after the motion - it is detecting my car (not moving) in the driveway to 96%, which seems reasonable.

But something it triggering it - most likely a car passing on the road - and that is what I want to capture, not a 15 second later image of my parked car.

Any idea on how to tune this plugin to help?

Thanks!

Streaming quality at 640x360@132kBit and maxFPS seems stuck at 15

How can I increase this? I also set my maxFPS to 30fps (G3 Bullet is 30fps)

Also I notice my streaming quality is stuck at 640x360@132kBit when I look at homebridge logs. How can I increase this? I have the RTSP stream at High 1920x1080. I even tried Medium 1024x526.
[Unifi protect cameras & motion sensors] Start streaming video from Driveway with 640x360@132kBit

"videoConfig": {
"vcodec": "h264_omx",
"audio": "true",
"maxStreams": 2,
"maxWidth": 1024,
"maxHeight": 576,
"maxFPS": 30,
"mapvideo": "0:1",
"mapaudio": "0:0",
"maxBitrate": 8000,
"packetSize": 376,
"additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp"

The requested platform 'Unifi-Protect-Camera-Motion' was not registered by any plugin

Hi, I'm getting the following errors when starting homebridge after installing and updating my config.

0|homebridge | Error: The requested platform 'Unifi-Protect-Camera-Motion' was not registered by any plugin. 0|homebridge | at API.platform (/usr/local/lib/node_modules/homebridge/lib/api.js:134:13) 0|homebridge | at Server._loadPlatforms (/usr/local/lib/node_modules/homebridge/lib/server.js:327:45) 0|homebridge | at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:90:36) 0|homebridge | at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:59:10) 0|homebridge | at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22) 0|homebridge | at Module._compile (internal/modules/cjs/loader.js:799:30) 0|homebridge | at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10) 0|homebridge | at Module.load (internal/modules/cjs/loader.js:666:32) 0|homebridge | at tryModuleLoad (internal/modules/cjs/loader.js:606:12) 0|homebridge | at Function.Module._load (internal/modules/cjs/loader.js:598:3) 0|homebridge | at Function._load (/usr/local/lib/node_modules/pm2/node_modules/@pm2/io/build/main/metrics/httpMetrics.js:172:43) 0|homebridge | at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:27:21) 0|homebridge | at Module._compile (internal/modules/cjs/loader.js:799:30) 0|homebridge | at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10) 0|homebridge | at Module.load (internal/modules/cjs/loader.js:666:32) 0|homebridge | at tryModuleLoad (internal/modules/cjs/loader.js:606:12) 0|homebridge | at Function.Module._load (internal/modules/cjs/loader.js:598:3) 0|homebridge | at Function.Module.runMain (internal/modules/cjs/loader.js:862:12) 0|homebridge | at internal/main/run_main_module.js:21:11

0|homebridge | [10/19/2019, 7:20:42 PM] ERROR LOADING PLUGIN homebridge-unifi-protect-camera-motion: 0|homebridge | [10/19/2019, 7:20:42 PM] Error: Cannot find module '/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node/lib/napi-v4/tfjs_binding.node' 0|homebridge | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15) 0|homebridge | at Function.Module._load (internal/modules/cjs/loader.js:575:25) 0|homebridge | at Function._load (/usr/local/lib/node_modules/pm2/node_modules/@pm2/io/build/main/metrics/httpMetrics.js:172:43) 0|homebridge | at Module.require (internal/modules/cjs/loader.js:705:19) 0|homebridge | at require (internal/modules/cjs/helpers.js:14:16) 0|homebridge | at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/@tensorflow/tfjs-node/dist/index.js:44:16) 0|homebridge | at Module._compile (internal/modules/cjs/loader.js:799:30) 0|homebridge | at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10) 0|homebridge | at Module.load (internal/modules/cjs/loader.js:666:32) 0|homebridge | at tryModuleLoad (internal/modules/cjs/loader.js:606:12) 0|homebridge | at Function.Module._load (internal/modules/cjs/loader.js:598:3) 0|homebridge | at Function._load (/usr/local/lib/node_modules/pm2/node_modules/@pm2/io/build/main/metrics/httpMetrics.js:172:43) 0|homebridge | at Module.require (internal/modules/cjs/loader.js:705:19) 0|homebridge | at require (internal/modules/cjs/helpers.js:14:16) 0|homebridge | at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/src/coco/coco.js:12:12) 0|homebridge | at Module._compile (internal/modules/cjs/loader.js:799:30) 0|homebridge | at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10) 0|homebridge | at Module.load (internal/modules/cjs/loader.js:666:32) 0|homebridge | at tryModuleLoad (internal/modules/cjs/loader.js:606:12) 0|homebridge | at Function.Module._load (internal/modules/cjs/loader.js:598:3) 0|homebridge | at Function._load (/usr/local/lib/node_modules/pm2/node_modules/@pm2/io/build/main/metrics/httpMetrics.js:172:43) 0|homebridge | at Module.require (internal/modules/cjs/loader.js:705:19)

{ "bridge": { "name": "Homebridge", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-154" }, "description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.", "platforms": [ { "platform": "ZP" }, { "platform": "Unifi-Protect-Camera-Motion", "name": "Unifi protect cameras & motion sensors", "unifi": { "controller": "https://192.168.0.39:7443", "controller_rtsp": "rtsp://192.168.0.39:7447/7Zvq8XERIQY4yfit", "username": "email", "password": "password", "motion_interval": 5000, "motion_score": 50, "enhanced_motion": true, "enhanced_motion_score": 50, "debug": false }, "videoConfig": { "vcodec": "h264_omx", "audio": false, "maxStreams": 2, "maxWidth": 1024, "maxHeight": 576, "maxFPS": 15, "mapvideo": "0:1", "mapaudio": "0:0" } } ], "accessories": [ ] }

I am running homebridge on iocage on my FreeNAS server

Camera's not streaming

Thanks for the help getting the plugin installed for me with Docker. Now I can't seem to get the cameras to stream, they keep erring with FFMpeg error 1

Here's my current config:

{
            "platform": "Unifi-Protect-Camera-Motion",
            "name": "Unifi protect cameras & motion sensors",
            "unifi": {
                "controller": "https://cloudkey-g2-ip:7443",
                "controller_rtsp": "rtsp://cloudkey-g2-ip:7447",
                "username": "homebridgeuser",
                "password": "homebridgeuserpassword",
                "motion_interval": 5000,
                "motion_repeat_interval": 30000,
                "motion_score": 50,
                "enhanced_motion": true,
                "enhanced_motion_score": 50,
                "enhanced_classes": [
                    "person",
                    "car",
                    "truck"
                ],
                "debug": false
            },
            "videoConfig": {
                "vcodec": "h264",
                "audio": true,
                "maxStreams": 4,
                "maxWidth": 1280,
                "maxHeight": 780,
                "maxFPS": 30,
                "mapvideo": "0:1",
                "mapaudio": "0:0"
            }
        },

I was a bit confused however with the videoConfig. All you mention really is to refer to the ffmpeg docs, which I used to use that plugin and had it previously working. Do I need to put in the array with config for each camera like I had before?

This was my previous config for that:

{
            "platform": "Camera-ffmpeg",
            "cameras": [
                {
                    "name": "Entryway",
                    "videoConfig": {
                        "source": "-re -rtsp_transport http -i rtsp://cloudkey-g2-ip:7447/camera-identifier-code-here",
                        "stillImageSource": "-i http://camera-ip/snap.jpeg",
                        "additionalCommandline": "-preset slow -profile:v high -level 4.2 -x264-params intra-refresh=1:bframes=0",
                        "mapvideo": "0:1",
                        "mapaudio": "0:0",
                        "maxStreams": 4,
                        "maxWidth": 1920,
                        "maxHeight": 1080,
                        "maxFPS": 30
                    }
                },
                {
                    "name": "Driveway",
                    "videoConfig": {
                        "source": "-re -rtsp_transport http -i rtsp://cloudkey-g2-ip:7447/camera-identifier-code-here",
                        "stillImageSource": "-i http://camera-ip/snap.jpeg",
                        "additionalCommandline": "-preset slow -profile:v high -level 4.2 -x264-params intra-refresh=1:bframes=0",
                        "mapvideo": "0:1",
                        "mapaudio": "0:0",
                        "maxStreams": 4,
                        "maxWidth": 1920,
                        "maxHeight": 1080,
                        "maxFPS": 30
                    }
                },
                {
                    "name": "Garage",
                    "videoConfig": {
                        "source": "-re -rtsp_transport http -i rtsp://cloudkey-g2-ip:7447/camera-identifier-code-here",
                        "stillImageSource": "-i http://camera-ip/snap.jpeg",
                        "additionalCommandline": "-preset slow -profile:v high -level 4.2 -x264-params intra-refresh=1:bframes=0",
                        "mapvideo": "0:1",
                        "mapaudio": "0:0",
                        "maxStreams": 4,
                        "maxWidth": 1920,
                        "maxHeight": 1080,
                        "maxFPS": 30
                    }
                },
                {
                    "name": "Side Gate",
                    "videoConfig": {
                        "source": "-re -rtsp_transport http -i rtsp://cloudkey-g2-ip:7447/camera-identifier-code-here",
                        "stillImageSource": "-i http://camera-ip/snap.jpeg",
                        "additionalCommandline": "-preset slow -profile:v high -level 4.2 -x264-params intra-refresh=1:bframes=0",
                        "mapvideo": "0:1",
                        "mapaudio": "0:0",
                        "maxStreams": 4,
                        "maxWidth": 1920,
                        "maxHeight": 1080,
                        "maxFPS": 30
                    }
                }
            ]
        },

Any ideas would be greatly appreciated! Thanks

ERROR: FFmpeg exited with code 1

I see there is a "closed" issue on this but I am unable to get this to work . This is a fresh install. Within the home app I get "no response" from the cameras. In the log file I get "ERROR: FFmpeg exited with code 1". Have tried the couple configs in the closed issue with no success.

This is connecting to the newest Unifi NVR. G3 Bullet and G3 Flex Cameras. homebridge-camera-ffmpeg and homebridge-unifi-protect2 both work for me.

Config file:

{
"bridge": {
"name": "Homebridge BED1",
"username": "0E:60:72:0F:BE:D1",
"port": 51653,
"pin": "664-83-642"
},
"accessories": [],
"platforms": [
{
"name": "Config",
"port": 8581,
"platform": "config"
},
{
"name": "Unifi protect cameras & motion sensors",
"unifi": {
"enhanced_classes": [],
"controller": "https://192.168.1.172",
"controller_rtsp": "https://192.168.1.172:7447",
"username": "xxx",
"password": "xxx",
"motion_interval": 5000,
"motion_repeat_interval": 30000,
"motion_score": 50,
"enhanced_motion": true,
"enhanced_motion_score": 50,
"save_snapshot": false,
"debug": false
},
"googlePhotos": {
"upload_gphotos": false,
"auth_redirectUrl": "http://localhost:8080/oauth2-callback"
},
"videoConfig": {
"maxStreams": 2,
"maxWidth": 1024,
"maxHeight": 576,
"maxFPS": 15,
"maxBitrate": 3000,
"vcodec": "libx264",
"packetSize": 376,
"audio": false,
"additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp"
},
"platform": "UnifiProtectMotion"
}
]
}

Unifi OS issues (not authenticating/camera listing/motion events/...)

After 2000 ms its failing with "[3/24/2020, 7:48:41 PM] [Unifi protect cameras & motion sensors] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: Authentication failed: {}".

This is with correct controller IP/RTC its specified as well as correct credentials (taking the same IP:port yield a login screen and a successful login with credentials in .config file.

edit: running this on osx, dedicated machine off a fresh install

Software installed, cameras are adopted into homekit, but video feed is 1 frame every 8 seconds

Figured we had strayed too far off the topic of "it wont install" to warrant a new issue thread. Thanks again for your continued help :)



[2/13/2020, 1:57:25 PM] [Unifi protect cameras & motion sensors] Start streaming video from Stairs with 640x360@132kBit
ffmpeg -rtsp_transport tcp -re -i rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW -map 0:1 -vcodec h264 -pix_fmt yuv420p -r 20 -f rawvideo -protocol_whitelist https,crypto,srtp,rtp,udp,tcp -b:v 132k -bufsize 132k -maxrate 132k -payload_type 99 -ssrc 9050101 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params 5VKb15bTdvrcz40gBtuPMVEMk7iPMeflXordbI/G srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376 -loglevel debug
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared

  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Splitting the commandline.
Reading option '-rtsp_transport' ...
 matched as AVOption 'rtsp_transport' with argument 'tcp'.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-i' ... matched as input url with argument 'rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:1'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'h264'.

Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '20'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rawvideo'.
Reading option '-protocol_whitelist' ...
 matched as AVOption 'protocol_whitelist' with argument 'https,crypto,srtp,rtp,udp,tcp'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '132k'.
Reading option '-bufsize' ...
 matched as AVOption 'bufsize' with argument '132k'.
Reading option '-maxrate' ...
 matched as AVOption 'maxrate' with argument '132k'.
Reading option '-payload_type' ...
 matched as AVOption 'payload_type' with argument '99'.
Reading option '-ssrc' ...
 matched as AVOption 'ssrc' with argument '9050101'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rtp'.
Reading option '-srtp_out_suite' ...
 matched as AVOption 'srtp_out_suite' with argument 'AES_CM_128_HMAC_SHA1_80'.
Reading option '-srtp_out_params' ...
 matched as AVOption 'srtp_out_params' with argument '5VKb15bTdvrcz40gBtuPMVEMk7iPMeflXordbI/G'.
Reading option 'srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376' ... matched as output url.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.

Parsing a group of options: input url rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW.
Applying option re (read input at native frame rate) with argument 1.
Successfully parsed a group of options.
Opening an input file: rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW.
[tcp @ 0x565444acbde0] No default whitelist set

Motion events #: 0
Known accessories #: 5
[rtsp @ 0x565444ac9c80] SDP:
v=0
o=- 2713 0 IN IP4 10.11.12.10
s=FCECDAD845D1_1
u=www.evostream.com
[email protected]
c=IN IP4 10.11.12.10
t=0 0
a=recvonly
a=control:*
a=range:npt=now-
m=audio 0 RTP/AVP 96
a=recvonly
a=rtpmap:96 mpeg4-generic/44100/1
a=control:trackID=1
a=fmtp:96 streamtype=5; profile-level-id=15; mode=AAC-hbr; config=1208; SizeLength=13; IndexLength=3; IndexDeltaLength=3;
m=video 0 RTP/AVP 97
a=recvonly
a=control:trackID=2
a=rtpmap:97 H264/90000
a=fmtp:97 profile-level-id=4d401f; packetization-mode=1; sprop-parameter-sets=Z01AH5pkAgAk/4C3AQEBQAAA+gAAHUwl,aO48gA==


[rtsp @ 0x565444ac9c80] audio codec set to: aac
[rtsp @ 0x565444ac9c80] audio samplerate set to: 44100
[rtsp @ 0x565444ac9c80] audio channels set to: 1
[rtsp @ 0x565444ac9c80] video codec set to: h264
[rtsp @ 0x565444ac9c80] RTP Profile IDC: 4d Profile IOP: 40 Level: 1f
[rtsp @ 0x565444ac9c80] RTP Packetization Mode: 1
[rtsp @ 0x565444ac9c80] Extradata set to 0x565444aa7250 (size: 36)

[rtsp @ 0x565444ac9c80] setting jitter buffer size to 0

    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] hello state=0

[h264 @ 0x565444ad09e0] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x565444ad09e0] nal_unit_type: 8, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x565444ad09e0] nal_unit_type: 8, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 7, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 8, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 1, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] Reinit context to 1024x576, pix_fmt: yuvj420p

[h264 @ 0x565444ad09e0] Frame num gap 13 11

[h264 @ 0x565444ad09e0] nal_unit_type: 1, nal_ref_idc: 3

    Last message repeated 1 times
[h264 @ 0x565444ad09e0] nal_unit_type: 7, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 8, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 5, nal_ref_idc: 3

[h264 @ 0x565444ad09e0] nal_unit_type: 1, nal_ref_idc: 3

    Last message repeated 5 times
[rtsp @ 0x565444ac9c80] All info found
[rtsp @ 0x565444ac9c80] rfps: 14.666667 0.016418
[rtsp @ 0x565444ac9c80] rfps: 14.750000 0.009235
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] 
rfps: 14.833333 0.004104
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 14.916667 0.001026
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 15.000000 0.000000
[rtsp @ 0x565444ac9c80] rfps: 15.083333 0.001027
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 15.166667 0.004106
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 15.250000 0.009238
[rtsp @ 0x565444ac9c80] rfps: 15.333333 0.016422
[rtsp @ 0x565444ac9c80] rfps: 29.666667 0.016416
[rtsp @ 0x565444ac9c80] rfps: 29.750000 0.009233
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 29.833333 0.004103
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 29.916667 0.001025
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 30.000000 0.000000
[rtsp @ 0x565444ac9c80] rfps: 45.000000 0.000000
[rtsp @ 0x565444ac9c80] rfps: 60.000000 0.000000
[rtsp @ 0x565444ac9c80] rfps: 120.000000 0.000001
[rtsp @ 0x565444ac9c80] rfps: 240.000000 0.000002
[rtsp @ 0x565444ac9c80] rfps: 29.970030 0.000132
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 59.940060 0.000530
    Last message repeated 1 times
[rtsp @ 0x565444ac9c80] rfps: 14.985015 0.000033

    Last message repeated 1 times
Input #0, rtsp, from 'rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW':
  Metadata:
    title           : FCECDAD845D1_1
  Duration: N/A, start: 0.000000, bitrate: N/A

    Stream #0:0, 88, 1/44100: Audio: aac (LC), 44100 Hz, mono, fltp
    Stream #0:1, 31, 1/90000: Video: h264 (Main), 1 reference frame, yuvj420p(pc, bt709, progressive, left), 1024x576 [SAR 1:1 DAR 16:9], 0/1, 15 fps, 15 tbr, 90k tbn, 30 tbc
Successfully opened the file.
Parsing a group of options: output url srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376.
Applying option map (set input stream mapping) with argument 0:1.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument h264.
Applying option pix_fmt (set pixel format) with argument yuv420p.
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 20.
Applying option f (force format) with argument rawvideo.
Applying option b:v (video bitrate (please use -b:v)) with argument 132k.
Applying option f (force format) with argument rtp.
Successfully parsed a group of options.
Opening an output file: srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376.

Matched encoder 'libx264' for codec 'h264'.

Successfully opened the file.

detected 4 logical cores
[h264 @ 0x565444b07fe0] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 0x565444b07fe0] nal_unit_type: 8, nal_ref_idc: 3

Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 346 times
[h264 @ 0x565444b07fe0] nal_unit_type: 7, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 225 times
[h264 @ 0x565444b07fe0] nal_unit_type: 8, nal_ref_idc: 3
cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 257 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 174 times
[h264 @ 0x565444b07fe0] Reinit context to 1024x576, pix_fmt: yuvj420p
cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 236 times
[h264 @ 0x565444b07fe0] Frame num gap 13 11
cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 1206026 times
cur_dts is invalid (this is harmless if it occurs once at the start per stream)bits/s speed=N/A    

    Last message repeated 241903 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 4 times
[h264 @ 0x565444bfef80] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 4 times
[h264 @ 0x565444b24be0] nal_unit_type: 7, nal_ref_idc: 3

[h264 @ 0x565444b24be0] 
nal_unit_type: 8, nal_ref_idc: 3

[h264 @ 0x565444b24be0] nal_unit_type: 5, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

[h264 @ 0x565444b20840] 
nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 2 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3
cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 6 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

[h264 @ 0x565444bfef80] nal_unit_type: 1, nal_ref_idc: 3

[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'video_size' to value '1024x576'
[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'pix_fmt' to value '12'
[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'time_base' to value '1/90000'

[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:1 @ 0x565444cedfe0] Setting 'frame_rate' to value '15/1'
[graph 0 input from stream 0:1 @ 0x565444cedfe0] w:1024 h:576 pixfmt:yuvj420p tb:1/90000 fr:15/1 sar:1/1 sws_param:flags=2
[format @ 0x565444cf45e0] compat: called with args=[yuv420p]
[format @ 0x565444cf45e0] Setting 'pix_fmts' to value 'yuv420p'
[auto_scaler_0 @ 0x565444cef880] Setting 'flags' to value 'bicubic'
[auto_scaler_0 @ 0x565444cef880] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x565444cf45e0] 
auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 0x565444c9a2a0] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed

[swscaler @ 0x565444b92100] deprecated pixel format used, make sure you did set range correctly

[auto_scaler_0 @ 0x565444cef880] w:1024 h:576 fmt:yuvj420p sar:1/1 -> w:1024 h:576 fmt:yuv420p sar:1/1 flags:0x4

[libx264 @ 0x565444b07b20] using mv_range_thread = 40
[libx264 @ 0x565444b07b20] using SAR=1/1

[libx264 @ 0x565444b07b20] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2

[libx264 @ 0x565444b07b20] profile High, level 3.1

Output #0, rtp, to 'srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376':
  Metadata:
    title           : FCECDAD845D1_1
    encoder         : Lavf57.83.100
    Stream #0:0, 0, 1/90000: Video: h264 (libx264), 1 reference frame, yuv420p(left), 1024x576 [SAR 1:1 DAR 16:9], 0/1, q=-1--1, 132 kb/s, 20 fps, 90k tbn, 20 tbc
    Metadata:

      encoder         : Lavc57.107.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 132000/0/132000 buffer size: 132000 vbv_delay: -1
*** 4 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 4 times
[h264 @ 0x565444b24be0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

[h264 @ 0x565444b20840] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 14 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 12 times
[h264 @ 0x565444bfef80] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444b24be0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444b20840] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 12 times
cur_dts is invalid (this is harmless if it occurs once at the start per stream)op=0 speed=   0x    

    Last message repeated 2 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 13 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444bfef80] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 14 times
[h264 @ 0x565444b24be0] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 12 times
[h264 @ 0x565444b20840] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

Motion events #: 0
Known accessories #: 5
[2/13/2020, 1:57:31 PM] [Unifi protect cameras & motion sensors] Snapshot from Stairs at 480x270
ffmpeg -i http://10.11.12.169/snap.jpeg -t 1 -s 480x270 -f image2 -
    Last message repeated 16 times
[h264 @ 0x565444bfef80] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 8 times
cur_dts is invalid (this is harmless if it occurs once at the start per stream)op=0 speed=   0x    

    Last message repeated 3 times
[h264 @ 0x565444b24be0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 18 times
[h264 @ 0x565444b20840] nal_unit_type: 1, nal_ref_idc: 3

*** 1 dup!

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 16 times
[h264 @ 0x565444b07fe0] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 12 times
[h264 @ 0x565444c26c00] nal_unit_type: 1, nal_ref_idc: 3

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

    Last message repeated 5 times
[libx264 @ 0x565444b07b20] frame=   0 QP=29.86 NAL=3 Slice:I Poc:0   I:2304 P:0    SKIP:0    size=12928 bytes

[rtp @ 0x565444b05460] Sending NAL 7 of len 26 M=0
[rtp @ 0x565444b05460] Sending NAL 8 of len 5 M=0
[rtp @ 0x565444b05460] Sending NAL 6 of len 755 M=0
[rtp @ 0x565444b05460] NAL size 755 > 350
[rtp @ 0x565444b05460] Sending NAL 5 of len 12128 M=1
[rtp @ 0x565444b05460] NAL size 12128 > 350

[libx264 @ 0x565444b07b20] frame=   1 QP=26.74 NAL=2 Slice:P Poc:8   I:9    P:121  SKIP:2174 size=198 bytes
[rtp @ 0x565444b05460] 
Sending NAL 1 of len 194 M=1

[libx264 @ 0x565444b07b20] frame=   2 QP=43.00 NAL=2 Slice:B Poc:4   I:0    P:3    SKIP:2301 size=29 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 25 M=1

[libx264 @ 0x565444b07b20] frame=   3 QP=45.00 NAL=0 Slice:B Poc:2   I:0    P:0    SKIP:2304 size=26 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 22 M=1
[libx264 @ 0x565444b07b20] frame=   4 QP=45.00 NAL=0 Slice:B Poc:6   I:0    P:0    SKIP:2304 size=26 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 22 M=1

[libx264 @ 0x565444b07b20] frame=   5 QP=24.59 NAL=2 Slice:P Poc:16  I:11   P:90   SKIP:2203 size=223 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 219 M=1

[libx264 @ 0x565444b07b20] frame=   6 QP=42.00 NAL=2 Slice:B Poc:12  I:0    P:3    SKIP:2301 size=32 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 28 M=1
[libx264 @ 0x565444b07b20] 
frame=   7 QP=47.00 NAL=0 Slice:B Poc:10  I:0    P:2    SKIP:2302 size=29 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 25 M=1

[libx264 @ 0x565444b07b20] frame=   8 QP=44.00 NAL=0 Slice:B Poc:14  I:0    P:0    SKIP:2304 size=26 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 22 M=1

[libx264 @ 0x565444b07b20] frame=   9 QP=31.79 NAL=2 Slice:P Poc:24  I:7    P:127  SKIP:2170 size=433 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 429 M=1
[rtp @ 0x565444b05460] NAL size 429 > 350

[libx264 @ 0x565444b07b20] frame=  10 QP=40.00 NAL=2 Slice:B Poc:20  I:0    P:34   SKIP:2270 size=52 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 48 M=1

[libx264 @ 0x565444b07b20] frame=  11 QP=45.00 NAL=0 Slice:B Poc:18  I:0    P:14   SKIP:2290 size=41 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 37 M=1

[libx264 @ 0x565444b07b20] frame=  12 QP=42.00 NAL=0 Slice:B Poc:22  I:0    P:0    SKIP:2304 size=26 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 22 M=1

[libx264 @ 0x565444b07b20] frame=  13 QP=27.84 NAL=2 Slice:P Poc:32  I:17   P:181  SKIP:2106 size=674 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 670 M=1
[rtp @ 0x565444b05460] NAL size 670 > 350

[libx264 @ 0x565444b07b20] frame=  14 QP=38.00 NAL=2 Slice:B Poc:28  I:0    P:41   SKIP:2263 size=53 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 49 M=1

[libx264 @ 0x565444b07b20] frame=  15 QP=43.00 NAL=0 Slice:B Poc:26  I:0    P:1    SKIP:2303 size=29 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 25 M=1

[libx264 @ 0x565444b07b20] frame=  16 QP=40.00 NAL=0 Slice:B Poc:30  I:0    P:2    SKIP:2302 size=28 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 24 M=1

[libx264 @ 0x565444b07b20] frame=  17 QP=28.02 NAL=2 Slice:P Poc:40  I:37   P:256  SKIP:2011 size=1045 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 1041 M=1
[rtp @ 0x565444b05460] NAL size 1041 > 350

[libx264 @ 0x565444b07b20] frame=  18 QP=36.00 NAL=2 Slice:B Poc:36  I:0    P:111  SKIP:2193 size=102 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 98 M=1

[libx264 @ 0x565444b07b20] frame=  19 QP=41.00 NAL=0 Slice:B Poc:34  I:0    P:44   SKIP:2260 size=63 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 59 M=1

[libx264 @ 0x565444b07b20] frame=  20 QP=38.00 NAL=0 Slice:B Poc:38  I:0    P:1    SKIP:2303 size=27 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 23 M=1

[libx264 @ 0x565444b07b20] frame=  21 QP=27.43 NAL=2 Slice:P Poc:48  I:25   P:250  SKIP:2029 size=1250 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 1246 M=1
[rtp @ 0x565444b05460] NAL size 1246 > 350

[libx264 @ 0x565444b07b20] frame=  22 QP=34.00 NAL=2 Slice:B Poc:44  I:0    P:166  SKIP:2138 size=133 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 129 M=1

[libx264 @ 0x565444b07b20] frame=  23 QP=39.00 NAL=0 Slice:B Poc:42  I:0    P:46   SKIP:2258 size=64 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 60 M=1

[libx264 @ 0x565444b07b20] frame=  24 QP=36.00 NAL=0 Slice:B Poc:46  I:0    P:6    SKIP:2298 size=30 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 26 M=1

[libx264 @ 0x565444b07b20] frame=  25 QP=26.44 NAL=2 Slice:P Poc:56  I:21   P:231  SKIP:2052 size=1224 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 1220 M=1
[rtp @ 0x565444b05460] NAL size 1220 > 350

[libx264 @ 0x565444b07b20] frame=  26 QP=35.00 NAL=2 Slice:B Poc:52  I:0    P:181  SKIP:2123 size=150 bytes

[rtp @ 0x565444b05460] Sending NAL 1 of len 146 M=1

[libx264 @ 0x565444b07b20] frame=  27 QP=37.00 NAL=0 Slice:B Poc:50  I:0    P:128  SKIP:2176 size=117 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 113 M=1

[libx264 @ 0x565444b07b20] frame=  28 QP=34.00 NAL=0 Slice:B Poc:54  I:0    P:15   SKIP:2289 size=41 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 37 M=1

[libx264 @ 0x565444b07b20] frame=  29 QP=26.29 NAL=2 Slice:P Poc:58  I:22   P:207  SKIP:2075 size=1098 bytes
[rtp @ 0x565444b05460] Sending NAL 1 of len 1094 M=1
[rtp @ 0x565444b05460] NAL size 1094 > 350

frame=   30 fps= 16 q=-1.0 Lsize=      21kB time=00:00:01.35 bitrate= 125.5kbits/s dup=10 drop=0 speed=0.707x    
video:20kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.857157%
Input file #0 (rtsp://10.11.12.10:7447/HPfiMqVTmLFAnORW):
  Input stream #0:0 (audio): 76 packets read (13524 bytes); 
  Input stream #0:1 (video): 27 packets read (49353 bytes); 21 frames decoded; 
  Total: 103 packets (62877 bytes) demuxed
Output file #0 (srtp://10.11.12.180:50407?rtcpport=50407&localrtcpport=50407&pkt_size=376):
  Output stream #0:0 (video): 30 frames encoded; 30 packets muxed (20197 bytes); 

  Total: 30 packets (20197 bytes) muxed

21 frames successfully decoded, 0 decoding errors

[AVIOContext @ 0x565444b27be0] Statistics: 0 seeks, 82 writeouts

[libx264 @ 0x565444b07b20] frame I:1     Avg QP:29.86  size: 12928
[libx264 @ 0x565444b07b20] frame P:8     Avg QP:27.39  size:   768
[libx264 @ 0x565444b07b20] frame B:21    Avg QP:40.19  size:    54
[libx264 @ 0x565444b07b20] consecutive B-frames:  6.7%  0.0%  0.0% 93.3%
[libx264 @ 0x565444b07b20] mb I  I16..4: 44.1% 46.0%  9.9%

[libx264 @ 0x565444b07b20] mb P  I16..4:  0.5%  0.3%  0.0%  P16..4:  6.3%  0.9%  0.7%  0.0%  0.0%    skip:91.3%
[libx264 @ 0x565444b07b20] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  1.6%  0.0%  0.0%  direct: 0.0%  skip:98.4%  L0: 2.9% L1:97.1% BI: 0.0%
[libx264 @ 0x565444b07b20] 8x8 transform intra:45.7% inter:47.0%
[libx264 @ 0x565444b07b20] coded y,uvDC,uvAC intra: 26.0% 28.6% 0.7% inter: 0.4% 0.5% 0.0%
[libx264 @ 0x565444b07b20] i16 v,h,dc,p: 40% 27% 11% 23%
[libx264 @ 0x565444b07b20] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 18% 32%  4%  2%  3%  5%  2%  7%
[libx264 @ 0x565444b07b20] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 21% 25%  5%  5%  7%  3%  2%  5%
[libx264 @ 0x565444b07b20] i8c dc,h,v,p: 73% 13% 14%  1%
[libx264 @ 0x565444b07b20] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x565444b07b20] ref P L0: 88.5%  7.4%  3.2%  0.9%
[libx264 @ 0x565444b07b20] ref B L0: 91.3%  8.7%
[libx264 @ 0x565444b07b20] ref B L1: 84.3% 15.7%
[libx264 @ 0x565444b07b20] kb/s:107.72

Exiting normally, received signal 15.

[2/13/2020, 1:57:32 PM] [Unifi protect cameras & motion sensors] Stopped streaming


I've been troubleshooting for a few hours now and have gotten to the point where the software doesn't exit with FFMPEG errors, but on the iPhone or iPad (tried with iPhone X, 11, and iPad Pro 11" as well as iPad 7th generation) the video stream only changes frames every 8 seconds. Almost as if it's grabbing the anonymous snaps or something lol. I attached logs from opening the stream then killing it as soon as it showed live, because otherwise the logs don't go back far enough. At the beginning you can see the error in:

cur_dts is invalid (this is harmless if it occurs once at the start per stream)

however this occurs thousands of times at the beginning it seems. I'm not sure where to look for errors here as im not well versed in ffmpeg, and my googling doesn't really do much since im not sure what to look for.

the config I have for the plugin is as follows:


{
            "platform": "Unifi-Protect-Camera-Motion",
            "name": "Unifi protect cameras & motion sensors",
            "unifi": {
                "controller": "https://10.11.12.10:7443",
                "controller_rtsp": "rtsp://10.11.12.10:7447",
                "username": "homebridge",
                "password": "homebridge",
                "motion_interval": 5000,
                "motion_repeat_interval": 30000,
                "motion_score": 50,
                "enhanced_motion": false,
                "enhanced_motion_score": 50,
                "enhanced_classes": [
                    "Person - or any other COCO classes, look in src/coco/classes.ts"
                ],
                "debug": true,
                "save_snapshot": true
            },
            "driveUpload": false,
            "videoConfig": {
                "vcodec": "h264",
                "audio": true,
                "acodec": "libopus",
                "maxStreams": 2,
                "maxWidth": 1024,
                "maxHeight": 576,
                "maxFPS": 30,
                "mapvideo": "0:1",
                "mapaudio": "0:0",
                "maxBitrate": 6000,
                "packetSize": 376,
                "debug": true,
                "additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp,tcp"
            },
            "plugin_map": {
                "plugin_name": "homebridge-unifi-protect-camera-motion"
            }
        }

Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: Authentication failed: {}

Hi everyone,

I am getting the following error.

[Unifi protect cameras & motion sensors] Initializing UnifiProtectMotion platform...
[Unifi protect cameras & motion sensors] Endpoint Style: Unifi Protect (Legacy)
[Unifi protect cameras & motion sensors] WARNING: No previous session foung, a new session must be created!
[Unifi protect cameras & motion sensors] Cannot get cameras: Error: ERROR: Could not enumerate motion sensors: Error: Authentication failed: {}

No cameras are disappearing in Apple Home.
The raspberry was set up new today.
My Config:

{
"name": "Unifi protect cameras & motion sensors",
"unifi": {
"enhanced_classes": [
"person"
],
"controller": "https://192.168.1.1:7443/",
"controller_rtsp": "rtsp://192.168.1.1:7447",
"username": "test",
"password": "testtest",
"motion_interval": 5000,
"motion_repeat_interval": 30000,
"motion_score": 50,
"enhanced_motion": true,
"enhanced_motion_score": 50,
"save_snapshot": true,
"debug": false
},
"videoConfig": {
"maxStreams": 2,
"maxWidth": 1024,
"maxHeight": 576,
"maxFPS": 15,
"vcodec": "h264_omx",
"mapvideo": "0:1",
"mapaudio": "0:0",
"audio": true
},
"platform": "UnifiProtectMotion"
}

Hope, someone could help me!
Thanks!

Can't install on a Synology NAS

I understand your compile of tensorflow.js may not be compatible with certain CPU's and that a compile from source is needed, but I've had no luck with getting this to work in Docker on my Synology 918+.

As I saw on a previous thread that it is out of the scope of this project, I was hoping to get a hand with this. I had your plugin working on my RPi for months and recently migrated Homebridge over to my NAS and this is really killing me.

Any help is appreciated

After the latest update it can't work anymore

The requested platform "UnifiProtectMotion" was not registered by any plugin.
Your config.json is requesting the platform "UnifiProtectMotion" which has not been published by any installed plugins.

Stream not starting

Describe the bug
The 3 cameras are successfully detected and even snapshots work, but when I open the stream for any of the cameras in the Home app it just loads forever.

Specifications
Homebridge runs on RP4B
NVR is CK Gen2 Plus
Client is iOS 14 Beta

Logging
See next comment

To Reproduce
Steps to reproduce the behavior:

  1. Go to Home app
  2. Click on any UniFi Protect camer
  3. See loading screen forever

Expected behavior
See the video stream

Config

{
            "name": "UniFi Protect",
            "unifi": {
                "enhanced_classes": [
                    "person",
                    "dog",
                    "bear"
                ],
                "controller": "https://10.0.1.3:7443",
                "controller_rtsp": "rtsp://10.0.1.3:7447",
                "username": "...",
                "password": "...",
                "motion_interval": 5000,
                "motion_repeat_interval": 30000,
                "motion_score": 50,
                "enhanced_motion": true,
                "enhanced_motion_score": 50,
                "save_snapshot": true,
                "debug": false
            },
            "videoConfig": {
                "maxStreams": 3,
                "maxWidth": 1920,
                "maxHeight": 1024,
                "maxFPS": 25,
                "maxBitrate": 6000,
                "vcodec": "h264_omx",
                "packetSize": 376,
                "audio": false,
                "additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp"
            },
            "platform": "UnifiProtectMotion"
        }

Streaming freeze in HomeKit app

Got everything working and setup. Snapshots are working fine. Streaming however results in a spinner showing in the middle of the video on the HomeKit app and no active video, just the last snapshot. On the homebridge end you see streaming successfully starting and stopping. In debug mode, you see it running at speed around 1x (sometimes 1.01x) for the precise time the video feed is open.

What am I missing? Config below. I've tried messing about with maxbitrate and max width/height.

        {
            "name": "Unifi protect cameras & motion sensors",
            "unifi": {
                "enhanced_classes": [
                    "person",
                    "car",
                    "truck"
                ],
                "controller": "https://172.16.1.3:7443",
                "controller_rtsp": "rtsp://172.16.1.3:7447",
                "username": "XXXXXXXX",
                "password": "XXXXXXXXX",
                "motion_interval": 5000,
                "motion_repeat_interval": 30000,
                "motion_score": 50,
                "enhanced_motion": true,
                "enhanced_motion_score": 50,
                "save_snapshot": false,
                "debug": false
            },
            "googlePhotos": {
                "upload_gphotos": false,
                "auth_redirectUrl": "http://localhost:8080/oauth2-callback"
            },
            "videoConfig": {
                "maxStreams": 2,
                "maxWidth": 1024,
                "maxHeight": 576,
                "maxFPS": 15,
                "maxBitrate": 30000,
                "vcodec": "libx264",
                "packetSize": 376,
                "audio": false,
                "additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp"
            },
            "platform": "UnifiProtectMotion"
        }

Publish Motion to MQTT

Just wondered if you've thought about adding MQTT support to publish motion activity. This would make it possible to interact with the camera motion for other plugins that use MQTT (e.g. mine) ;)

There is Unifi Protect MQTT this which I have installed on my Cloudkey but would prefer to not install something on the Cloudkey and seeing as you get the messages anyway it would just be a case of publishing them to a configured MQTT broker.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.