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. Then, click the Advanced option and make sure the Video Codec is set to libx264.
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.
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!
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.
I’m having the same issue with the 10s thumbnails are working great, but the video stream never starts. I previously had ffmpeg installed via brew (I can type “ffmpeg” in the Terminal to access it, works fine). I also created a link to the brew install of ffmpeg in /usr/local/bin. I tested the URL generated by the SecuritySpy tool in VLC on another machine (changed the localhost to the IP of the machine) and VLC was able to display that stream from SecuritySpy with no issues. The log on the Status page of Homebridge will give the following log entries when tapping into and out of the camera in the Home app on my phone:
[1/14/2024, 12:18:30 PM] [Camera FFmpeg] [Front Porch] Starting video stream: 1280 x 720, 30 fps, 299 kbps
[1/14/2024, 12:18:50 PM] [Camera FFmpeg] [Front Porch] Stopped video stream.
But like I said, the stream never actually starts, I just get the spinning cycler. Eventually it will time out and give me the “No response” message, but doesn’t add anything else in the log on the Status page.
I saw you mention about turning on debug mode for the log, but I can’t find that setting in the Plugins advanced section?
In Homebridge, go to the Plugins page and click the “SETTINGS” link for the Homebridge Camera FFmpeg plugin. Expand the “Advanced” section (not the “Global Advanced” section) and scroll down a bit, and you should see the “FFmpeg Debug Logging” option. Turn this on and restart Homebridge and try again. Hopefully you’ll now get some more useful information in the log to explain what is going wrong.
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!
As long as you have a device on your network that can act as a “home hub”, then the video will work from anywhere. Here is information about this from Apple: Control your home remotely with iPhone
Glad to hear you find this blog to be so useful!
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.
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.
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)
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).
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!
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)
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!
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.
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!
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.
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.
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.
Hi all,
Thought I’d tackle this however I’m struggling from the get go. I have a mac mini (M1) running Ventura if that makes a difference.
1. I have no /usr/local/bin but can find /bin, is this the same?
2. The FFMPEG Unix Executable will not copy over (I see a do not enter type icon), does something need to bee enabled to allow this to go over?
Any pointers would be appreciated.
There should be a /usr/local/bin folder on all systems: try using the “Go to Folder…” option in the Finder to locate it. If it’s not there, try creating it (e.g. use the “Go to Folder” option to open the /usr/local folder, and then create a “bin” folder there). In terms of copying over the ffmpeg executable, this is just a case of dragging the file to the /usr/local/bin folder in the Finder. The /bin folder is not the correct place, and won’t allow you to copy files to it due to restricted permissions.
Perfect, thanks. All working.
Will installing home bridge bring motion detection notifications to my Apple TV?
Or is that a strictly HomeKit Secure Video/Scypted option?
You can do this in a bit of a roundabout way by using the “Homebridge Dummy” plugin to create a dummy switch along with the “Homebridge Dummy Lock” plugin to create a dummy lock. Create an Action in HomeHelper to turn on the dummy switch, which is triggered by a camera, and create an automation in Home to turn on the dummy lock when the dummy switch is triggered. Notifications from locks can be shown on the Apple TV. We’ll see if we can make this a bit easier in the future by supporting locks directly, but for now this is the only solution that I know of.
Hi – Like others I can get stills but not video image. In looking at the homebridge-camera-ffmpeg Github I saw some people were having issues due to which stream was being selected. (see https://github.com/Sunoo/homebridge-camera-ffmpeg/issues/711) Is there a way to set which stream will be viewed via that URL generator by chance?
In the URL Generator window, the best stream to select to enter into the “Video Source” box in the Homebridge Camera plugin is usually the “RTSP H.264” type. In our testing this works reliably, although some users have reported issues and it’s difficult to determine why because the logging in Homebridge isn’t very helpful. Alternatively, you could try the “HTTP MJPEG Stream” type when generating the URL, which we have also found to be reliable.
Thanks for quick reply!
I was able to get video working by limiting to 600×800 but was hoping to be able to stream higher resolutions.
Is there a 600×800 max resolution limit to all cameras added thru HomeKit?
I’m not aware of any such limit, but perhaps so. In our testing, HomeKit seems to request video at 1280×720, but the plugin should be able to receive the stream in any resolution, whereby it resizes it and forwards it to HomeKit. Perhaps this is failing if the source resolution is too high?
~ % /usr/local/bin/ffmpeg ; exit;
zsh: bad CPU type in executable: /usr/local/bin/ffmpeg
New M2 Mini, had no issues following the steps on my old Intel Mini.
Any help?
This is unfortunate, as it indicates that the official ffmpeg executable can’t run on the M2 architecture. And the future doesn’t look good for this, as stated by the ffmpeg developer. Try the “Apple Silicon” download from this page: https://www.osxexperts.net/ – you can either follow their instructions to sign it via Terminal commands, or follow our instructions above to initially right-click and select Open, and then agree to the permissions prompt. Please let me know if this version works for you.
rbis–enable-libsnappy–enable-libaom–enable-libvidstab–enable-libzimg–e nable-libsvtav1 –enable-version3–pkg-config-flags=–static–disable-ffplay-
-enable-postproc–enable-nonfree–enable-neon–enable-runtime-cpudetect–dis able-indev=qtkit–disable-indev=x11grab_xcb
libavutil
57. 35.100 / 57. 35.100
libavcodec
59. 42.103 / 59. 42.103
libavformat
59. 30.100 / 59. 30.100
libavdevice
59.
8.101 / 59.
8.101
libavfilter
8. 48.100 / 8. 48.100
libswscale
6.
8.104 /
6.
8.104
libswresample
4.
9.100 /
4.
9.100
libpostproc
56.
7.100 / 56.
7.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfi le}…
Use -h to get full help or, even better, run ‘man ffmpeg’
Saving session…
…copying shared history..
.. saving history…truncating history files..
… completed.
Deleting expired sessions…none found.
Happy days!
I just installed the latest version of SecuritySpy (5.3.3) running on an M1 mini and can’t seem to find the URL Generator in the Window menu (or anywhere else). Am I blind or did this move to some other place?
Hi Klaus, 5.3.3 is an old version that doesn’t have this function. Please obtain the latest version (currently 5.5.6) from the SecuritySpy Download Page.
Ah thanks, I must have messed up. I just downloaded the other day after I bought the license, but I did look into SecuritySpy in 2021. I must have accidentally reinstalled the version I had tried back then. I’ll update when I get home later today.
I seam to be having problems with this lately, its all been working fine for a long time but for the last 2 weeks all cameras are showing as no response. (everything fine in the security spy app)
I’ve even tried deleting the cameras & starting again, following the instructions to the T
The only thing I’m seeing in the logs is as below
[13/04/2023, 19:08:12] [Camera FFmpeg] [Front Drive] Failed to fetch snapshot.
[Front Drive] Snapshot request handler provided empty image buffer!
I’ve got 3 cameras through home bridge
when I enter the still image url in a normal browser I get the image but when I try with the video stream url I get told the address is invalid.
If I try the MJPEG stream I get the following in the log
[13/04/2023, 19:21:29] [Camera FFmpeg] [Side Gate] Starting video stream: 1280 x 720, 30 fps, 299 kbps
[13/04/2023, 19:21:29] [Camera FFmpeg] [Side Gate] FFmpeg exited with code: 1 and signal: null (Error)
[13/04/2023, 19:21:29] [Camera FFmpeg] [Side Gate] Stopped video stream.
Could anyone offer some help please?
Hello I have an arvertx system that’s managed by the nvr it came with 8 cameras I can’t seem to get the rtsp url to work any ideas? its the pro connect nvr and the hd848 cameras.
What is the URL that you are using and how did you obtain it? Once I know the RTSP URL I can advise how to set this up in SecuritySpy.
Thanks for the summary. Got far, to get still images loading in homekit (3 cameras). I cannot get the video to load though, even though the logs in homebridge are busy.
The only error I see is:
[Porch] [rtsp @ 0x7fb844e04380] [error] method SETUP failed: 461 Unsupported Transport
I tried using the “-rtsp_transport tcp” in the URL, but that did not work.
The log also has several of these:
[Porch] [Snapshot] [rtsp @ 0x7f9bcd204140] method SETUP failed: 461 Unsupported Transport
These two messages are shown in Red so I figured they mean something. Since I am getting this after the “snapshot” message (and the stills in HomeKit) I assume this is not a problem, but it might be related to the first one:
[Porch] Fetching snapshot took 1.501 seconds.
Any ideas are welcome.
Is anyone able to view recordings and scrub thru the homekit iOS app?
The method described above is for live video only. If you want to view recordings from your SecuritySpy system on your iPhone, you should use our SecuritySpy iOS app.
Thanks Ben,
I’ve tried a few NVRs recently and this comes up high on the list so far. Your detections on the software is A+! No more false alarms or very little to none! You done an excellent job!
I’ve been reading the responses here and has there been an update to getting Live Video Notifications on Apple TV yet or is that this only thru ONVIF Scrypted?
Great to hear you are liking SecuritySpy! Sorry but there are no native notifications on Apple TV yet (only iOS) – I can’t promise anything, but we’ll take a look at this in the near future. So many more users are using iPads and iPhones compared with Apple TVs, which is why we focus our development efforts for our mobile app more towards iOS.
Fair enough with Apple TV. Hopefully it’s not too difficult a task to look at down the track when and if you get a chance to focus on it. Overall, Security Spy is a very smooth product! I’m not sure if you’ve ever had the chance to look at Synology surveillance station but they have a multi-view player/scrub feature that would be a very useful and Eufy/Scrypted NVR have facial recognition which allows you to dismiss regular notifications of certain people on said camera – something you might consider for your software? Anyways, huge fan of your work so far =)
Has anyone set this up using the “HOOBS” Homebridge device?
The same plugin is available for HOOBS, so while we haven’t ourselves tested this, it should work in the same way: https://plugins.hoobs.org/plugin/homebridge-camera-ffmpeg
Ben;
I’ve installed the FFmpeg plugin, but the configuration seems much different than just needing the 3 parameters you mention (Name, Video Source, and Still Image Source). My Homebridge runs on a Synology NAS (IP X.X.X.100) and my SecuritySpy setup is on a Mac Mini (IP X.X.X.110) The HOOBS setup for FFmpeg refers to “MQTT”. Please see this screenshot.
https://www.dropbox.com/scl/fi/nahnvxllxtnvpuyi9tea3/HOOBS-FFMPEG.png?rlkey=qs1j8bxd9drcso80v6b2j8vsg&st=0uwutp3r&dl=0
Thanks
Victor
From your screenshot, the HOOBS Camera FFmpeg plugin seems very different from the Homebridge Camera FFmpeg plugin. It seems to need a MQTT server as a “broker”. Sorry, I am not familiar with this, and I don’t know what to suggest to get this working for you in HOOBS.