Adding SecuritySpy Cameras To HomeKit Using Homebridge

SecuritySpy, our macOS CCTV software, has built-in HomeKit integration that allows it to control, and be controlled from, accessories like sensors, switches and lights, across your Apple Home automation system.

But, what about making live video from SecuritySpy’s cameras available to Home? This blog post explains how to do this.

Step 1: Install FFmpeg

FFmpeg is a free library used for video processing. The easiest way to install this is to download the latest compiled version from the FFmpeg static binaries for macOS page:

  • You can either download the very latest build (left column) or the last official release (right column)
  • Click the Download as ZIP link
  • Once downloaded, double-click on the zip file to expand it, which should give you an executable file called ffmpeg
  • In the Finder, select the Go to Folder option in the Go menu, enter /usr/local/bin, and press the Go button to open this folder
  • Drag the downloaded ffmpeg executable into the /usr/local/bin folder
  • Verify that ffmpeg has permission to run by right-clicking on it and selecting the Open option; agree to any permissions prompt, and it should open in Terminal and show some informational text

Step 2: Install Homebridge

Homebridge is a platform that allows the integration of a wide variety of devices, accessories and applications into your Home environment. Homebridge will act as an intermediary, taking video feeds from SecuritySpy and making them available to Home.

Follow these instructions to install Homebridge on the same Mac that is running SecuritySpy.

Step 3: Install the Homebridge Camera FFmpeg plugin

This plugin takes any RTSP stream, such as those provided by SecuritySpy, and creates virtual cameras from these that are then provided to Home.

  • Log on to the Homebridge web interface – on the same computer that runs Homebridge, this is available at http://localhost:8581
  • Click the Plugins tab at the top, search for Homebridge Camera, and this plugin should appear in your search results; click the INSTALL link to install it
  • You should now see this installed in the Plugins section in Homebridge, like this:

Step 4: Configure cameras in the Homebridge Camera plugin

Click on the plugin’s SETTINGS link, and a panel appears that allows you to add and configure cameras. The only three items you will need to set are: Name, Video Source, and Still Image Source – leave all other settings at their default values.

To generate the URLs to give to the plugin, use SecuritySpy’s URL Generator window, which is available from the Window menu:

  • Type: for the Video Source link, this should be set to RTSP H.264; for the Still Image Source link, this should be set to HTTP JPEG Still Image
  • Client location: assuming Homebridge is running on the same Mac as SecuritySpy, this should be set to This Mac
  • Camera: select which of SecuritySpy’s cameras you want to stream to Home
  • Authentication: select a web account that has access to this camera, and a secure authentication token will be added to the URL. This token provides access to the specified resource only, and it is impossible to derive the account’s username or password from it. If the account is subsequently deleted, or its username or password changed, the token will become invalid.
  • Encryption: leave this turned off (communication between SecuritySpy and Homebridge is within the same Mac, so this is not required)

Copy and paste the two generated links into the plugin’s setup panel, which should then look something like this:

Make sure to leave the audio option turned off (due to AAC licensing issues, this requires a special build of the FFmpeg library that isn’t readily available for download), and make sure to add the -i prefix before each URL as shown above.

Step 5: Add Homebridge to Home

The main page of the Homebridge web interface will show a QR code: scan this with the Camera or the Home app on your iOS device to add Homebridge to your Home system.

That’s it! Live video from Your camera(s) should now appear in the Home app across all your devices, like this:

The thumbnails will update every 10s – tap on one to view the full live stream.

16 thoughts on “Adding SecuritySpy Cameras To HomeKit Using Homebridge

  1. Chip

    I am so very grateful for you putting this together (and for security spy in general). I had read the instructions in blogs before but didn’t trust the instructions until I saw them all here. I have don’t everything listed above, and double checked, I only get still images updated everything 10s, when I try to see the actual video it never starts. Any ideas? Thanks!

    Reply
    1. Ben Software Post author

      The 10s update time for still images is up to Home – I don’t think this can be adjusted unfortunately. As for the live video, check that you have the “-i” prefix before the URL as entered into the plugin, as this is a common thing that can get left out. Another thing you can do is to turn on debug logging in the plugin (in the Advanced section), and then see what messages are displayed in the log on the main page of the Homebridge screen when you attempt to start the video – this may give you some clues as to what is going wrong. Remember to restart Homebridge when you make any settings changes in the plugin.

      Reply
  2. Troy

    Will the video only work if you are on the local network, or will they work from anywhere? I will have to try this out.
    I find the blogs to be as much help if not more than the documentation. Keep up the good work!

    Reply
  3. Randy

    Already a home bridge user, this was a great addition to my setup. While I am able to get this to work on Intel Mac Mini’s, I can’t get it to work on an M1 Mac Mini.

    The cameras set up fine, but I get an error when trying to get a snapshot or video feed. Codec issue or location maybe? Any guidance?

    Log below

    (Auth Redacted)
    [10/13/2022, 9:21:14 AM] [Camera FFmpeg] [01 Front] Snapshot requested: 640 x 360
    [10/13/2022, 9:21:14 AM] [Camera FFmpeg] [01 Front] Snapshot command: ffmpeg -i http://localhost:8000/image?cameraNum=1&auth=XXXXXXXX -frames:v 1 -f image2 – -hide_banner -loglevel error
    [10/13/2022, 9:21:14 AM] [Camera FFmpeg] [01 Front] FFmpeg process creation failed: spawn ffmpeg ENOENT
    [01 Front] Snapshot request handler provided empty image buffer!
    [10/13/2022, 9:21:14 AM] [Camera FFmpeg] [01 Front] Fetching snapshot took 0.01 seconds.

    Reply
    1. Ben Software Post author

      From the log messages you posted, it looks like Homebridge can’t find the ffmpeg executable. Are you sure you have installed this in the correct place? It should go into the folder at /usr/local/bin as described above.

      Reply
  4. DonD

    Thanks so much for posting this. I’m having trouble viewing my camera video on the Home app. The cameras appear under Favorite Cameras fine showing the 10-second updated stills but when I click on the still in Home app, all I get is a spinning wheel (no response from camera), no video. I’m using SS 5.5.1, MacOS 13.0, iOS 16.1, Dahua Camera HDBW4431R-ZS (H.264).

    Here is the log info, any clues as to what’s going on?

    [10/24/2022, 6:38:36 PM] [Camera FFmpeg] [Workshop SE] Fetching snapshot took 0.138 seconds.
    [10/24/2022, 6:38:36 PM] [Camera FFmpeg] [Workshop SE] Sending snapshot: 640 x 360
    [10/24/2022, 6:38:36 PM] [Camera FFmpeg] [Workshop SE] Resize command: /usr/local/lib/node_modules/homebridge-camera-ffmpeg/node_modules/ffmpeg-for-homebridge/ffmpeg -i pipe: -frames:v 1 -filter:v scale=’min(640,iw)’:’min(360,ih)’:force_original_aspect_ratio=decrease -f image2 –
    [10/24/2022, 6:38:40 PM] [Camera FFmpeg] [Workshop SE] Video stream requested: 1280 x 720, 30 fps, 299 kbps
    [10/24/2022, 6:38:40 PM] [Camera FFmpeg] [Workshop SE] Starting video stream: 1280 x 720, 30 fps, 299 kbps
    [10/24/2022, 6:38:40 PM] [Camera FFmpeg] [Workshop SE] Stream command: /usr/local/lib/node_modules/homebridge-camera-ffmpeg/node_modules/ffmpeg-for-homebridge/ffmpeg -i rtsp://localhost:8585/stream?cameraNum=5&auth=!0d82b65afd0bf86ab246c5c4fd57ad6d53097aad44b55e60 -an -sn -dn -codec:v libx264 -pix_fmt yuv420p -color_range mpeg -r 30 -f rawvideo -preset ultrafast -tune zerolatency -filter:v scale=’min(1280,iw)’:’min(720,ih)’:force_original_aspect_ratio=decrease,scale=trunc(iw/2)*2:trunc(ih/2)*2 -b:v 299k -payload_type 99 -ssrc 5542973 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params lh+nSHWZr5xCJ/j86+FCwULMbCTO1uKFEjdj2u5R srtp://192.168.0.171:61205?rtcpport=61205&pkt_size=1316 -loglevel level -progress pipe:1
    [10/24/2022, 6:38:43 PM] [Camera FFmpeg] [Workshop SE] Getting the first frames took 2.24 seconds.
    [10/24/2022, 6:39:31 PM] [Camera FFmpeg] [Workshop SE] Received request to reconfigure: 640 x 360, 30 fps, 132 kbps (Ignored)
    [10/24/2022, 6:39:46 PM] [Camera FFmpeg] [Workshop SE] Stopped video stream.
    [10/24/2022, 6:39:47 PM] [Camera FFmpeg] [Workshop SE] FFmpeg exited with code: 0 and signal: null (Expected)

    Reply
    1. Ben Software Post author

      I’m not sure why this is happening – the log you posted doesn’t reveal a specific problem. Does this happen in the Home app on both your Mac and your iPhone? It’s worth trying it on a few different devices to see if it works on some but not others (which points to a client problem) or if it’s the same thing on all devices (which points to a server problem).

      Reply
      1. DonD

        Thanks for the reply Ben. Yes this happens on both my Mac and iPhone. I’ve tried different cameras (Dahua but different models). My SS settings:
        Profile: ONVIF
        Format: RTSP (video and audio)
        Codec: H.264

        I’ve tried it with my VPN on and off, I’m using the same HomeBridge URL setting for both Video and Still Source. As I said before I can see the still image on my Home app but no live streaming. Seems that if I can see the still (refreshed every 20 sec) I should also be able to see the video.

        Any further ideas on what I can try? Thanks!

        Reply
      2. DonD

        Also here are my Dahua Camera settings:
        Encode Mode: H.264
        Smart Codec: Off
        Resolution: 2592×1520
        Frame rate (FPS): 15
        Bit Rate Type: VBR
        Quality: 6(Best)
        Max Bit Rate: 10240
        I Frame Interval: 30
        SVC: 1(off)

        Reply
  5. Colin WLU

    Just installed ffmpeg, Homebridge etc and the Homebridge Camera plugin.
    No luck so read through previous comments. -i needed to be added.
    However working my MacMini using Real VNC on my iPad the -i kept changing to upper case I.
    Once I’d conquered that issue it works fine.
    So thanks for the excellent blog that just needs a note added that -i needs adding!

    Reply
    1. Ben Software Post author

      Hi Colin, good to hear you worked this out. Our post describes the need for adding the -i prefix to the URL, both in the text (in bold!) and in the screenshot, so I hope that this is enough.

      Reply
      1. Colin WLU

        Apologies I didn’t see it. I’m waiting for new glasses so will use that as an excuse.
        However, hoping you can help with my latest post re the 10h and not seconds!

        Reply
  6. Colin WLU

    So after everything working last night, this morning its a no go.
    checked the plug-in, re saved it and re started Homebridge.
    Camera working again however image is old and in bottom left corner it says 10h instead of counting down from 10seconds.
    Any ideas please.

    Reply
  7. Peter Schneider

    To help others. In my case I was also having issues with the “-I” being turned to “-I” (made upper case. One way to fix this is to copy and paste the whole line into the field with the “-I” prefix included (not typed). Another is to go into the JSON editor of the plugin and make the change there.

    Also of note was that I had to have the 10 second snapshots or Homebridge would complain in the logs, and Home would not show anything.

    A great addition to the use of Homebridge and SecuritySpy.

    Reply
  8. Peter Schneider

    Ouch, I turned on two cameras and watched my processing loads spike! It might be a nice thing to have, but a bit of a luxury on my Intel Mac Mini with i5 6 Core processor from 2018. Guess I will need to consider an upgrade to a newer Mini at some point, but for now I can live without the extra toy.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *