Reply
Member
Posts: 139
Registered: ‎04-18-2018
Kudos: 28
Solutions: 1

Re: Native Apple HomeKit integration

You installed Homebridge AND a plugin.  Sounds like you installed the unifi-video plugin.  I believe you're using Protect?  That plugin is not for you.

 

I use homebridge-camera-ffmpeg-omx plugin.  I'm having some problems livestreaming with the homebridge-camera-ffmpeg plugin.

 

If this was useful, please like this post. Please also mark this post solved if it solved your problem.

My UniFi equipment: Cloud Key, Cloud Key 2+, Gateway (USG), PoE Switch (US-8-150W), Access Point (UAP-AC-Pro), UniFi G3 Flex
Established Member
Posts: 1,696
Registered: ‎09-01-2016
Kudos: 601
Solutions: 55

Re: Native Apple HomeKit integration

@BrianErdelyi - I installed the plug-in that you mentioned but still getting these error. 

 

I'm not sure if I have the config.json correctly. I added the camera rtsp url under source. Any idea?

 

root@homebridge:~# homebridge
/usr/lib/node_modules/homebridge/lib/server.js:219
  var username = config.bridge.username;
                               ^

TypeError: Cannot read property 'username' of undefined
    at Server._loadConfig (/usr/lib/node_modules/homebridge/lib/server.js:219:32)
    at new Server (/usr/lib/node_modules/homebridge/lib/server.js:56:38)
    at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:30:16)
    at Object.<anonymous> (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
Established Member
Posts: 1,696
Registered: ‎09-01-2016
Kudos: 601
Solutions: 55

Re: Native Apple HomeKit integration

Anyone running Homebridge in a RPi connected to Protect can share their config.json file? I'm trying to have mine setup but I'm having hard time.

Member
Posts: 139
Registered: ‎04-18-2018
Kudos: 28
Solutions: 1

Re: Native Apple HomeKit integration

Here’s my config:

 

{

   "bridge":{

      "name":"Homebridge",

      "username":"11:22:33:44:55:66",

      "port":51826,

      "pin":"123-45-678"

   },

   "platforms":[

      {

         "platform":"Camera-ffmpeg-omx",

         "cameras":[

            {

               "name":"UniFi G3 Flex",

               "videoConfig":{

                  "source":"-rtsp_transport http -re -i rtsp://192.168.2.26:7447/pqSBSzLFBznJlUHn",

                  "vcodec":"h264_omx",

                  "audio": true,

                  "maxStreams":2,

                  "maxWidth":640,

                  "maxHeight":480,

                  "maxFPS":15,

                  "debug": true

               }

            }

         ]

      }

   ]

}

If this was useful, please like this post. Please also mark this post solved if it solved your problem.

My UniFi equipment: Cloud Key, Cloud Key 2+, Gateway (USG), PoE Switch (US-8-150W), Access Point (UAP-AC-Pro), UniFi G3 Flex
Established Member
Posts: 1,696
Registered: ‎09-01-2016
Kudos: 601
Solutions: 55

Re: Native Apple HomeKit integration

I think this is my problem. I have missing these values. From where I get them? BTW: Thanks in advance for the help / share. 

 

{

   "bridge":{

      "name":"Homebridge",

      "username":"11:22:33:44:55:66",

      "port":51826,

      "pin":"123-45-678"

 

Member
Posts: 139
Registered: ‎04-18-2018
Kudos: 28
Solutions: 1

Re: Native Apple HomeKit integration

Also notice I’m using the homebridge-camera-ffmpeg-omx plugin.

 

 

If this was useful, please like this post. Please also mark this post solved if it solved your problem.

My UniFi equipment: Cloud Key, Cloud Key 2+, Gateway (USG), PoE Switch (US-8-150W), Access Point (UAP-AC-Pro), UniFi G3 Flex
Member
Posts: 139
Registered: ‎04-18-2018
Kudos: 28
Solutions: 1

Re: Native Apple HomeKit integration

Those values are configurable.  You can set them to whatever you want.

If this was useful, please like this post. Please also mark this post solved if it solved your problem.

My UniFi equipment: Cloud Key, Cloud Key 2+, Gateway (USG), PoE Switch (US-8-150W), Access Point (UAP-AC-Pro), UniFi G3 Flex
Member
Posts: 139
Registered: ‎04-18-2018
Kudos: 28
Solutions: 1

Re: Native Apple HomeKit integration

Here’s is how I setup my RPi using Raspbian Stretch Lite.

 

Update package database

sudo apt-get update

 

Upgrade installed packages

sudo apt-get -y upgrade

 

Install Node.js repository

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

 

Install Node.js 

sudo apt-get install -y nodejs

 

Install avahi

sudo apt-get install -y libavahi-compat-libdnssd-dev

 

Install ffmpeg

sudo apt-get install -y ffmpeg

 

Install homebridge

sudo npm install -g --unsafe-perm homebridge

 

Install Homebridge camera plugin

sudo npm install -g homebridge-camera-ffmpeg

 

Configure Homebridge

Homebridge (need to launch and close Homebridge once before editing config file)

sudo nano /home/pi/.homebridge/config.json

If this was useful, please like this post. Please also mark this post solved if it solved your problem.

My UniFi equipment: Cloud Key, Cloud Key 2+, Gateway (USG), PoE Switch (US-8-150W), Access Point (UAP-AC-Pro), UniFi G3 Flex
Established Member
Posts: 1,696
Registered: ‎09-01-2016
Kudos: 601
Solutions: 55

Re: Native Apple HomeKit integration

@BrianErdelyi - You config.json example works for me. I'm up and running. Few questions; On the main screen of the Home App the App seems to update the image every 12 or so seconds, is this configurable? When I select the camera it keeps Loading and then I get "No response". Is your setup working fine? You can see the live stream?

Member
Posts: 139
Registered: ‎04-18-2018
Kudos: 28
Solutions: 1

Re: Native Apple HomeKit integration

First, what device are you using to view the camera?  I use my iPhone.

 

it is normal that the thumbnail refreshes ever 10s.  When you open the camera it will take about 10s then you’ll see “live”.

 

Same config but if I use the homebridge-camera-ffmpeg plugin I get an error when I try live streaming.

If this was useful, please like this post. Please also mark this post solved if it solved your problem.

My UniFi equipment: Cloud Key, Cloud Key 2+, Gateway (USG), PoE Switch (US-8-150W), Access Point (UAP-AC-Pro), UniFi G3 Flex
Established Member
Posts: 1,696
Registered: ‎09-01-2016
Kudos: 601
Solutions: 55

Re: Native Apple HomeKit integration


@BrianErdelyi wrote:

First, what device are you using to view the camera?  I use my iPhone.

 

it is normal that the thumbnail refreshes ever 10s.  When you open the camera it will take about 10s then you’ll see “live”.

 

Same config but if I use the homebridge-camera-ffmpeg plugin I get an error when I try live streaming.


I'm using an iPhone X.

 

The thumbnail refresh every 10s without ploblems. But when I open the camera I get this error;

 

IMG_2226.png

Member
Posts: 139
Registered: ‎04-18-2018
Kudos: 28
Solutions: 1

Re: Native Apple HomeKit integration

How did you install FFmpeg? The old plugin doesn’t provide much output Man Sad

Alternatively, try using the non On my way! Plugin and see what the output says.
If this was useful, please like this post. Please also mark this post solved if it solved your problem.

My UniFi equipment: Cloud Key, Cloud Key 2+, Gateway (USG), PoE Switch (US-8-150W), Access Point (UAP-AC-Pro), UniFi G3 Flex
Member
Posts: 139
Registered: ‎04-18-2018
Kudos: 28
Solutions: 1

Re: Native Apple HomeKit integration

@fpb Can you remove the line where audio is set to true?
If this was useful, please like this post. Please also mark this post solved if it solved your problem.

My UniFi equipment: Cloud Key, Cloud Key 2+, Gateway (USG), PoE Switch (US-8-150W), Access Point (UAP-AC-Pro), UniFi G3 Flex
Established Member
Posts: 1,696
Registered: ‎09-01-2016
Kudos: 601
Solutions: 55

Re: Native Apple HomeKit integration


@BrianErdelyi wrote:
@fpbCan you remove the line where audio is set to true?

Just tried but the live video doesnt work.

 

I also tried with homebridge-camera-ffmpeg-omx and homebridge-camera-ffmpeg with the same result. The snapshots works ok. 

 

With the homebridge-camera-ffmpeg plugin on the debug results I see these errors;

 

Codec AVOption profile () specified for output file #1 (srtp://192.168.1.233:60250?rtcpport=60250&localrtcpport=60250&pkt_size=1316) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.

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

Output #0, rtp, to 'srtp://192.168.1.233:65339?rtcpport=65339&localrtcpport=65339&pkt_size=1316':
  Metadata:
    title           : 802AA84ED26C_0
    encoder         : Lavf57.56.101

    Stream #0:0: Audio: pcm_mulaw, 11025 Hz, mono, s16, 88 kb/s
    Metadata:
      encoder         : Lavc57.64.101 pcm_mulaw

[mpeg4 @ 0x19ae800] Either both buffer size and max rate or neither must be specified
Stream mapping:
  Stream #0:0 -> #0:0 (aac (native) -> pcm_mulaw (native))
  Stream #0:1 -> #1:0 (h264 (native) -> mpeg4 (native))
Error while opening encoder for output stream #1:0 - maybe incorrect parameters such as bit_rate, rate, width or height

but I'm playing with the settings without luck yet.

Member
Posts: 139
Registered: ‎04-18-2018
Kudos: 28
Solutions: 1

Re: Native Apple HomeKit integration

I can only get video with the omx plugin. I’d still like to know how you installed ffmpeg since this is the reason for most issues.

I had a bit of a breakthrough with the non-omx plugin. It appears that Protect may have two separate streams. I’ll try and swap the commands.
If this was useful, please like this post. Please also mark this post solved if it solved your problem.

My UniFi equipment: Cloud Key, Cloud Key 2+, Gateway (USG), PoE Switch (US-8-150W), Access Point (UAP-AC-Pro), UniFi G3 Flex
Established Member
Posts: 1,696
Registered: ‎09-01-2016
Kudos: 601
Solutions: 55

Re: Native Apple HomeKit integration

I did a clean install again and used your steps. with the only difference that later I noticed that the instructions points to the non omx plugin and then I unistalled the non-omx and installed the omx. 

Established Member
Posts: 1,696
Registered: ‎09-01-2016
Kudos: 601
Solutions: 55

Re: Native Apple HomeKit integration


@BrianErdelyi wrote:
I can only get video with the omx plugin. I’d still like to know how you installed ffmpeg since this is the reason for most issues.

I had a bit of a breakthrough with the non-omx plugin. It appears that Protect may have two separate streams. I’ll try and swap the commands.

The plug-in web point to another source to download the ffmpeg, but I can't access it. Did you used that one originally?

 

homebridge-camera-ffmpeg-omx

ffmpeg plugin for Homebridge. Optimized for Rapsberry Pi via GPU encoding.

Installation

  1. Install ffmpeg on your Raspberry Pi.

    a. Download this package: sudo wget goo.gl/gMGA81 -O ffmpeg.deb

    b. Install this package: sudo dpkg -i ffmpeg.deb

    c. Ensure that the user you are running homebridge as has access to /dev/vchiq. ie sudo usermod -aG video login where login is the user you are running homebridge as.

  2. Install this plugin using: npm install -g homebridge-camera-ffmpeg-omx

  3. Edit config.json and add the camera.

  4. Run Homebridge

  5. Add extra camera accessories in Home app. The setup code is the same as homebridge.

Member
Posts: 139
Registered: ‎04-18-2018
Kudos: 28
Solutions: 1

Re: Native Apple HomeKit integration

I don’t like the omx docs.  I follow all steps for the non omx plugin.  It works fine.

If this was useful, please like this post. Please also mark this post solved if it solved your problem.

My UniFi equipment: Cloud Key, Cloud Key 2+, Gateway (USG), PoE Switch (US-8-150W), Access Point (UAP-AC-Pro), UniFi G3 Flex
Established Member
Posts: 1,696
Registered: ‎09-01-2016
Kudos: 601
Solutions: 55

Re: Native Apple HomeKit integration

@jclarkenz - out of curiosity what plugin are you using for the Protect / homebridge integration? The question is because I tried two different plugins and I can't get live video on the Home App.

Member
Posts: 139
Registered: ‎04-18-2018
Kudos: 28
Solutions: 1

Re: Native Apple HomeKit integration

FYI, I have finally resolved a problem with the homebridge-camera-ffmpeg plugin and Protect.

 

Protect seems to include the audio in the first stream and video in the second stream.  I had to modify the homebridge-camera-ffmpeg plugin to have it expect video in the second stream.  I have also disabled audio in my homebridge configuration.  My next testing will be to see if it works with audio enabled.

 

See the following thread for details.  https://github.com/KhaosT/homebridge-camera-ffmpeg/issues/222#issuecomment-441333661

 

 

If this was useful, please like this post. Please also mark this post solved if it solved your problem.

My UniFi equipment: Cloud Key, Cloud Key 2+, Gateway (USG), PoE Switch (US-8-150W), Access Point (UAP-AC-Pro), UniFi G3 Flex
Reply