Skip to content

CameraRTPStreamManagement

crxporter edited this page Dec 13, 2020 · 7 revisions

Characteristics

Characteristic Optional/
Required
Accepted
Values
Description
SelectedRTPStreamConfiguration Required
SetupEndpoints Required
SupportedAudioStreamConfiguration Required
StreamingStatus Required
SupportedVideoStreamConfiguration Required
SupportedRTPConfiguration Required
Name Optional String

Notes on Cameras

Cameras are a complicated situation. If you are running the Docker way then FFMPEG will be preinstalled for you with several of the options preset (may not have all hardware accelerations built). Alternately you can download and compile your own version of FFMPEG with the build flags you need for your cameras.

For those writing examples, please include how you have installed FFMPEG!

It is recommended to add only one camera per bridge. The camera should be the "parent" service with "motion" and "doorbell" (if used) as linked services.

Examples

* Raspberry Pi Zero W

Example written by CRXPorter. Date 21 November, 2020. Plugin version 1.2.0, Node-RED version 1.2.5.

Hardware:
-Raspberry Pi Zero W
-Raspberry Pi Camera Module V2\

Software setup:

Step zero: I assume you are able to set up a pi zero with SSH and wifi. I am using Raspberry Pi OS Lite

Step one: use raspi-config to enable the camera interface on the pi

Step two: install FFMPEG for HomeBridge using the script found here

Step three: install and start Node-RED with the script found here

Step four: install node-red-contrib-homekit-bridged from palette manager

Step five: import this flow. It should be a single homekit node

[{"id":"36df1f80.39e34","type":"homekit-service","z":"c9e35eda.bb75f8","isParent":true,"bridge":"f18ad79f.5081e8","parentService":"","name":"Pi zero camera","serviceName":"CameraControl","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"-re -r 6 -s 1280x720 -f video4linux2 -i /dev/video0","cameraConfigStillImageSource":"-s 1280x720 -f video4linux2 -i /dev/video0","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":"1280","cameraConfigMaxHeight":"720","cameraConfigMaxFPS":"6","cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"h264_omx","cameraConfigAudioCodec":"h264_omx","cameraConfigAudio":false,"cameraConfigPacketSize":"564","cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":3,"x":430,"y":260,"wires":[[],[],[]]},{"id":"f18ad79f.5081e8","type":"homekit-bridge","bridgeName":"Camera","pinCode":"111-11-111","port":"","allowInsecureRequest":false,"manufacturer":"Raspberry Pi","model":"Pi zero w","serialNo":"00001","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true}]

(Note to self: need to add this to the examples for next release)

Step six: add it to your home app and enjoy!

Notes:
Additional tuning could be done to optimize resolution and speed. The new Raspberry Pi High Quality camera should work with the same setup. This setup should work on a Pi 3 or 4 with very little modification. Adding a microphone, motion detector, doorbell button, or other things should be relatively simple. Visit us on discord if you'd like to discuss!

* Unifi Protect

Example written by CRXPorter.
Cameras tested:

  • Unifi G3 Flex
  • Unifi G3 Bullet
  • Unifi G4 Doorbell

Motion detection and doorbell presses are available for advanced users, ask @crxporter on discord. A new Unifi node is pending from CRXPorter - hopefully coming late 2020.

FFMPEG was installed on a pi 4. Nodered was installed with the official nodered on pi install script.

FFMPEG Install

Install build tools

sudo apt install git pkg-config autoconf automake libtool libx264-dev

ALSA runtime library

sudo apt install libasound2-dev

Download and build fdk-aac

cd ~
git clone https://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
sudo ./autogen.sh
sudo ./configure --prefix=/usr/local --enable-shared --enable-static
sudo make -j4
sudo make install
sudo ldconfig

Download and build ffmpeg

cd ~
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
sudo ./configure --prefix=/usr/local --arch=armel --target-os=linux --enable-omx-rpi --enable-nonfree --enable-gpl --enable-libfdk-aac --enable-mmal --enable-libx264 --enable-decoder=h264 --enable-network --enable-protocol=tcp --enable-demuxer=rtsp
sudo make -j4
sudo make install

Clean up

cd ~
rm -rf FFmpeg
rm -rf fdk-aac

Cameras Setup

The camera node setup is quite simple for Unifi. Be sure to enable unauthenticated still images on your cameras. My fields are filled out as shown:

Video Processor: ffmpeg
Source: -re -rtsp_transport tcp -i rtsp://10.0.0.1:7447/randomstring
Still image source: -i http://10.0.1.4/snap.jpeg
Max Streams: 3
Max Width: 960
Max Height: 720
Max FPS: 10
Max Bitrate: 3072
Video Codec: h264_omx
Audio Codec: libfdk_aac
Audio: yes
Packet Sixe: 564
Map Video: 0:1
Map Audio: 0:0
Video Filter: scale=960:720
Additional Command Line: -preset slow -profile:v high -level 4.2 -x264-params intra-refresh=1:bframes=0

This is a work in progress. Written October 9, 2020. Please find me (crxporter) on our discord server if you're having problems or would like more information.

* Reolink

(reolink here by @itsj4y)

Replace XXX with your camera's password. Do not use Video Filter with copy codec. There may be more ideal settings but these should get you up and running.

Video Processor: ffmpeg
Source: -re -rtsp_transport tcp -i rtsp://admin:[email protected]:544//h264Preview_01_sub
Still image source: -i http://10.0.1.125/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=XXX
Max Streams: 2
Max Width: 1280
Max Height: 720
Max FPS: 10
Max Bitrate: 3000
Video Codec: copy
Audio Codec: libfdk_aac
Audio: no
Packet Size: 1316
Map Video: 0:0
Map Audio: 0:1
Additional Command Line: -tune zerolatency
Clone this wiki locally