Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFMPEG streaming issues #62

Closed
beele opened this issue Aug 2, 2020 · 63 comments
Closed

FFMPEG streaming issues #62

beele opened this issue Aug 2, 2020 · 63 comments
Assignees
Labels
ffmpeg Issue with ffmpeg, not the plugin itself

Comments

@beele
Copy link
Owner

beele commented Aug 2, 2020

Describe the bug
This is a global ticket for all FFMPEG issues like streams not starting etc.

Specifications
Respond to this ticket if you are having issues with streams not working.
Include:

  • hardware specs where homebridge is running on (cpu/ram/video card)
  • software specs where homebridge is running on (cpu arch/os/node versions/homebridge version/plugin version)

Logging
Enable the debug option of the plugin and attach the FULL log of homebridge to the ticket.
Be sure to omit any sensitive data like usernames/password/tokens/urls

NOTE:
All other tickets regarding FFMPEG streaming issues will be closed!

@beele beele self-assigned this Aug 2, 2020
@beele beele added the ffmpeg Issue with ffmpeg, not the plugin itself label Aug 2, 2020
@beele
Copy link
Owner Author

beele commented Aug 2, 2020

My config that is working with 0.4.1 on my RBPI 4 with latest homebridge/config-ui-x and node 12.x

{
            "platform": "UnifiProtectMotion",
            "name": "Unifi protect cameras & motion sensors",
            "unifi": {
                "controller": "https://IP_OF_CLOUDKEY_GEN_2:PROTECT_UI_PORT",
                "controller_rtsp": "rtsp://IP_OF_CLOUDKEY_GEN_2:RTSP_PORT",
                "username": "USERNAME",
                "password": "PASSWORD",
                "motion_interval": 5000,
                "motion_repeat_interval": 30000,
                "motion_score": 0,
                "enhanced_motion": true,
                "enhanced_motion_score": 55,
                "enhanced_classes": [
                    "person"
                ],
                "save_snapshot": false,
                "enable_motion_trigger": true,
                "enable_doorbell_for": [],
                "debug": false,
                "debug_network_traffic": false
            },
            "googlePhotos": {
                "upload_gphotos": false,
                "auth_clientId": "CLIENT_ID",
                "auth_clientSecret": "CLIENT_SECRET",
                "auth_redirectUrl": "http://localhost:8080/oauth2-callback"
            },
            "videoConfig": {
                "vcodec": "h264_omx",
                "audio": true,
                "maxStreams": 2,
                "maxWidth": 1920,
                "maxHeight": 1080,
                "maxFPS": 15,
                "mapvideo": "0:1",
                "mapaudio": "0:0",
                "maxBitrate": "3000",
                "packetSize": 188,
                "additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp"
            }
        }

If not running on a RBPI replace the h264_omx with h264

@madrobby
Copy link
Contributor

madrobby commented Aug 2, 2020

Hi, I can't start streams (ffmpeg exit code 1), but snapshots are working fine.

UniFi setup:

  • UniFi Dream Machine Pro 1.8.0-rc11
  • UniFi Protect 1.14.11 / 1.23.2

Hardware setup:

  • Mac mini (Late 2012) 2.3 GHz Quad-Core Intel Core i7, 4 GB 1600 MHz DDR3
  • Intel HD Graphics 4000
  • macOS Catalina 10.15.6

Software setup:

  • Homebridge version 1.1.1
  • ffmpeg version 4.3.1 (via homebrew)
  • node v12.18.1

Homebridge logs with debugging on in plugin

[8/2/2020, 9:06:08 AM] [HB Supervisor] Restarting Homebridge...
[8/2/2020, 9:06:08 AM] [HB Supervisor] Starting Homebridge with extra flags: -I
[8/2/2020, 9:06:08 AM] [HB Supervisor] Started Homebridge v1.1.1 with PID: 52624
[8/2/2020, 9:06:10 AM] Loaded config.json with 1 accessories and 4 platforms.
[8/2/2020, 9:06:10 AM] ---
[8/2/2020, 9:06:11 AM] Loaded plugin: [email protected]
[8/2/2020, 9:06:11 AM] Registering platform 'homebridge-config-ui-x.config'
[8/2/2020, 9:06:11 AM] ---
[8/2/2020, 9:06:11 AM] Loaded plugin: [email protected]
[8/2/2020, 9:06:11 AM] Registering accessory 'homebridge-nexia-thermostat.NexiaThermostat'
[8/2/2020, 9:06:11 AM] ---
[8/2/2020, 9:06:12 AM] Loaded plugin: [email protected]
[8/2/2020, 9:06:12 AM] Registering platform 'homebridge-simplisafe3.SimpliSafe 3'
[8/2/2020, 9:06:12 AM] ---
2020-08-02 09:06:19.240489: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x10383eb00 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-08-02 09:06:19.240541: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
[8/2/2020, 9:06:21 AM] Loaded plugin: [email protected]
[8/2/2020, 9:06:21 AM] Registering platform 'homebridge-unifi-protect-camera-motion.UnifiProtectMotion'
[8/2/2020, 9:06:21 AM] ---
[8/2/2020, 9:06:22 AM] Loaded plugin: [email protected]
[8/2/2020, 9:06:25 AM] Registering platform 'homebridge-weather-plus.WeatherPlus'
[8/2/2020, 9:06:25 AM] ---
[8/2/2020, 9:06:25 AM] Loading 4 platforms...
[8/2/2020, 9:06:25 AM] [Config] Initializing config platform...
[8/2/2020, 9:06:25 AM] [Config] Running in Service Mode
[8/2/2020, 9:06:25 AM] [Home Alarm] Initializing homebridge-simplisafe3.SimpliSafe 3 platform...
[8/2/2020, 9:06:25 AM] [Unifi Protect] Initializing UnifiProtectMotion platform...
[8/2/2020, 9:06:25 AM] [WeatherPlus] Initializing WeatherPlus platform...
[8/2/2020, 9:06:25 AM] [WeatherPlus] Adding station with weather service Weather Underground named 'Now'
[8/2/2020, 9:06:25 AM] Initializing platform accessory 'Now'...
[8/2/2020, 9:06:25 AM] Loading 1 accessories...
[8/2/2020, 9:06:25 AM] [House Thermostat] Initializing NexiaThermostat accessory...
[8/2/2020, 9:06:25 AM] [Unifi Protect] Configuring accessory House Main Door
[8/2/2020, 9:06:25 AM] [Unifi Protect] Configuring accessory Sky Cam
[8/2/2020, 9:06:25 AM] [Unifi Protect] Configuring accessory Office Front Door
[8/2/2020, 9:06:25 AM] [Unifi Protect] Configuring accessory Man Cave
[8/2/2020, 9:06:25 AM] [Unifi Protect] Configuring accessory Workshop
[8/2/2020, 9:06:25 AM] [Unifi Protect] Configuring accessory Office Laundry Room
Setup Payload:
X-HM://BLAHBLAHBLAH
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ BLAHBLAHBLAH │     
    └────────────┘     
                       
[8/2/2020, 9:06:25 AM] Homebridge is running on port 51799.
[8/2/2020, 9:06:25 AM] [Unifi Protect] Endpoint Style: UnifiOS
[8/2/2020, 9:06:26 AM] [Unifi Protect] Found camera: Office Laundry Room (id: 5f0870da0085d003870003ee)
[8/2/2020, 9:06:26 AM] [Unifi Protect] Found camera: House Main Door (id: 5f0870da004ed003870003ed)
[8/2/2020, 9:06:26 AM] [Unifi Protect] Found camera: Sky Cam (id: 5f0870da00a0d003870003ef)
[8/2/2020, 9:06:26 AM] [Unifi Protect] Found camera: Workshop (id: 5f0870da0100d003870003f2)
[8/2/2020, 9:06:26 AM] [Unifi Protect] Found camera: Office Front Door (id: 5f0f5bbc01ad080387001ae8)
[8/2/2020, 9:06:26 AM] [Unifi Protect] Found camera: Man Cave (id: 5f0870da00dad003870003f1)
[8/2/2020, 9:06:26 AM] [Unifi Protect] Found camera: Guest Bedroom East (id: 5f18d7f40323f20387002294)
[8/2/2020, 9:06:26 AM] [Unifi Protect] Camera (Guest Bedroom East) has no streams, skipping!
[8/2/2020, 9:06:27 AM] [Home Alarm] Motion Sensor 'Downstairs' requires secret alerts to be enabled in SimpliSafe before you can add it to Homebridge.
[8/2/2020, 9:06:27 AM] [Home Alarm] Motion Sensor 'Upstairs' requires secret alerts to be enabled in SimpliSafe before you can add it to Homebridge.
[8/2/2020, 9:06:27 AM] [Home Alarm] Motion Sensor 'Downstairs' requires secret alerts to be enabled in SimpliSafe before you can add it to Homebridge.
[8/2/2020, 9:06:27 AM] [Home Alarm] Motion Sensor 'Upstairs' requires secret alerts to be enabled in SimpliSafe before you can add it to Homebridge.
[8/2/2020, 9:06:30 AM] [Unifi Protect] Motion checking setup done!
[8/2/2020, 9:06:39 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:06:42 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:06:42 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:06:42 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:06:43 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:06:43 AM] [Unifi Protect] Starting video stream: 1024x576, 15 fps, 299 kbps Office Front Door
[8/2/2020, 9:06:43 AM] [Unifi Protect] ffmpeg exited with code: 1 and signal: null (Error) Office Front Door
[8/2/2020, 9:06:43 AM] [Unifi Protect] Stopped video stream. Office Front Door
[8/2/2020, 9:06:52 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:06:56 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:06:56 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:06:56 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:06:57 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:06:57 AM] [Unifi Protect] Device appears to be inactive for over 5 seconds. Stopping stream. Office Front Door
[8/2/2020, 9:06:57 AM] [Unifi Protect] Stopped video stream. Office Front Door
[8/2/2020, 9:07:06 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:07:07 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:07:11 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:07:12 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:07:13 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:07:17 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:07:21 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:07:22 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:07:23 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:07:23 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:07:27 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:07:31 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:07:32 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:07:33 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:07:33 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:07:38 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:07:42 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:07:42 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:07:43 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:07:43 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:07:48 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:07:52 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:08:04 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:08:07 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:08:08 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:08:08 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:08:13 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:08:17 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:08:18 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:08:18 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:08:22 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:08:25 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:08:28 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:08:40 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:08:45 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:08:45 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:08:48 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:08:50 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:08:55 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:08:56 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:08:58 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:09:02 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:09:20 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:09:23 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:09:23 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:09:23 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:09:30 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:09:34 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:09:34 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:09:34 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:09:34 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:09:44 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:09:44 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:09:44 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:09:44 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:09:45 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:09:54 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:10:06 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:10:13 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:10:13 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:10:13 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:10:17 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:10:23 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:10:23 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:10:23 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:10:23 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:10:27 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:10:33 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:10:33 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:10:34 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:10:34 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:10:37 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:10:43 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:10:44 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:10:44 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:10:44 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:10:47 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:10:53 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:10:54 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:10:54 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:10:54 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:15:45 AM] [Unifi Protect] Sending snapshot: 1024x576 Workshop
[8/2/2020, 9:15:54 AM] [Unifi Protect] Sending snapshot: 1024x576 Man Cave
[8/2/2020, 9:15:57 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Front Door
[8/2/2020, 9:15:59 AM] [Unifi Protect] Sending snapshot: 1024x576 Office Laundry Room
[8/2/2020, 9:16:00 AM] [Unifi Protect] Sending snapshot: 1024x576 House Main Door
[8/2/2020, 9:16:01 AM] [Unifi Protect] Starting video stream: 1024x576, 15 fps, 299 kbps Man Cave
[8/2/2020, 9:16:31 AM] [Unifi Protect] Stopped video stream. Man Cave

^you can see there's one crash in there an one timeout

Result in Home app (note: this is on Bug Sur beta, but same happens on iOS non-beta and macOS Catalina)
Screen Shot 2020-08-02 at 6 16 34 AM

ffmpeg details

ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with Apple clang version 11.0.3 (clang-1103.0.32.62)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100

@beele
Copy link
Owner Author

beele commented Aug 2, 2020

@madrobby Maybe there is an issue when ffmpeg is installed, I'll try to get a special debug build together for the ffmpeg issues so we dan do some further digging.

@tillkruss
Copy link

Just upgraded to v0.4.1 and restarted. Same as before: Snapshots work, but the video still doesn't stream.

Setup

Hardware setup:

  • UniFi Cloud Key Plus (v1.1.13)
  • UniFi Protect (v1.13.4)
  • Raspberry Pi 4B

Software setup:

  • Linux raspberrypi (5.4.51-v7l+ #1326 SMP Fri Jul 17 10:51:18 BST 2020 armv7l GNU/Linux)
  • Homebridge (v1.1.1)
  • ffmpeg (v4.1.6)
  • Node (v10.22.0)

FFmpeg

Click to expand
ffmpeg version 4.1.6-1~deb10u1+rpt1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Raspbian 8.3.0-6+rpi1)
configuration: --prefix=/usr --extra-version='1~deb10u1+rpt1' --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-omx-rpi --enable-mmal --enable-neon --enable-rpi --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --libdir=/usr/lib/arm-linux-gnueabihf --cpu=arm1176jzf-s --arch=arm
libavutil      56. 22.100 / 56. 22.100
libavcodec     58. 35.100 / 58. 35.100
libavformat    58. 20.100 / 58. 20.100
libavdevice    58.  5.100 / 58.  5.100
libavfilter     7. 40.101 /  7. 40.101
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  3.100 /  5.  3.100
libswresample   3.  3.100 /  3.  3.100
libpostproc    55.  3.100 / 55.  3.100

Homebridge config

Click to expand! ```json { "bridge": { "name": "Homebridge BCA5", "username": "...", "manufacturer": "homebridge.io", "model": "homebridge", "port": 51061, "pin": "031-45-157" }, "accessories": [ { "name": "Occupancy Sensor", "unifi": { "controller": "https://10.0.1.3:8443", "username": "Homebridge", "password": "...", "site": "default" }, "watch": [ "...", "..." ], "mode": "any", "watchGuests": false, "interval": 10, "accessory": "UniFi Occupancy Sensor" } ], "platforms": [ { "platform": "config", "name": "Config", "theme": "dark-mode", "port": 8581, "sudo": false }, { "name": "Airmega", "platform": "Airmega", "username": "...", "password": "..." }, { "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": "Homebridge", "password": "...", "motion_interval": 5000, "motion_repeat_interval": 30000, "motion_score": 50, "enhanced_motion": true, "enhanced_motion_score": 50, "save_snapshot": true, "debug": true }, "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" } ] } ```

Homebridge logs

Click to expand!
[8/3/2020, 9:33:07 AM] [HB Supervisor] Sending SIGTERM to Homebridge
[8/3/2020, 9:33:07 AM] Got SIGTERM, shutting down Homebridge...
[8/3/2020, 9:33:12 AM] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[8/3/2020, 9:33:17 AM] [HB Supervisor] Restarting Homebridge...
[8/3/2020, 9:33:17 AM] [HB Supervisor] Starting Homebridge with extra flags: -I
[8/3/2020, 9:33:17 AM] [HB Supervisor] Started Homebridge v1.1.1 with PID: 30531
[8/3/2020, 9:33:18 AM] Loaded config.json with 1 accessories and 3 platforms.
[8/3/2020, 9:33:18 AM] ---
[8/3/2020, 9:33:19 AM] Loaded plugin: [email protected]
[8/3/2020, 9:33:19 AM] Registering platform 'homebridge-airmega.Airmega'
[8/3/2020, 9:33:19 AM] ---
[8/3/2020, 9:33:19 AM] Loaded plugin: [email protected]
[8/3/2020, 9:33:19 AM] Registering platform 'homebridge-config-ui-x.config'
[8/3/2020, 9:33:19 AM] ---
[8/3/2020, 9:33:20 AM] Loaded plugin: [email protected]
[8/3/2020, 9:33:20 AM] Registering accessory 'homebridge-unifi-occupancy-sensor.UniFi Occupancy Sensor'
[8/3/2020, 9:33:20 AM] ---
cpu backend was already registered. Reusing existing backend factory.
Platform node has already been set. Overwriting the platform with [object Object].
[8/3/2020, 9:33:23 AM] Loaded plugin: [email protected]
[8/3/2020, 9:33:23 AM] Registering platform 'homebridge-unifi-protect-camera-motion.UnifiProtectMotion'
[8/3/2020, 9:33:23 AM] ---
[8/3/2020, 9:33:23 AM] Loaded plugin: [email protected]
[8/3/2020, 9:33:23 AM] Registering accessory 'homebridge-wol.NetworkDevice'
[8/3/2020, 9:33:23 AM] ---
[8/3/2020, 9:33:23 AM] Loading 3 platforms...
[8/3/2020, 9:33:23 AM] [Config] Initializing config platform...
[8/3/2020, 9:33:23 AM] [Config] Running in Service Mode
[8/3/2020, 9:33:23 AM] [Airmega] Initializing Airmega platform...
[8/3/2020, 9:33:23 AM] [UniFi Protect] Initializing UnifiProtectMotion platform...
[8/3/2020, 9:33:23 AM] Loading 1 accessories...
[8/3/2020, 9:33:23 AM] [Occupancy Sensor] Initializing UniFi Occupancy Sensor accessory...
[8/3/2020, 9:33:23 AM] [UniFi Protect] Configuring accessory Backyard
[8/3/2020, 9:33:23 AM] [UniFi Protect] Configuring accessory Driveway
[8/3/2020, 9:33:23 AM] [UniFi Protect] Configuring accessory Compost
[8/3/2020, 9:33:23 AM] [Airmega] Authenticating...
Setup Payload:
X-HM://0023ISYX1O9I9
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ 031-45-157 │     
    └────────────┘     
                       
[8/3/2020, 9:33:24 AM] Homebridge is running on port 51061.
[8/3/2020, 9:33:24 AM] [UniFi Protect] Endpoint Style: Unifi Protect (Legacy)
[8/3/2020, 9:33:24 AM] [Occupancy Sensor] UniFi Events: Connected (1) - wss://10.0.1.3:8443/wss/s/default/events
[8/3/2020, 9:33:24 AM] [Occupancy Sensor] 0 monitored device(s) found. Accessory is in mode "any" so NOT triggering occupancy.
[8/3/2020, 9:33:24 AM] [UniFi Protect] Found camera: Driveway (id: 5e70108501502403e7004a04)
[8/3/2020, 9:33:24 AM] [UniFi Protect] Found camera: Compost (id: 5f162a820258da03e70040bb)
[8/3/2020, 9:33:24 AM] [UniFi Protect] Found camera: Backyard (id: 5ea76ecd002f4803e70010e4)
[8/3/2020, 9:33:28 AM] [UniFi Protect] Motion checking setup done!
[8/3/2020, 9:33:33 AM] [Airmega] Found AIRMEGA 300S
[8/3/2020, 9:33:34 AM] [Occupancy Sensor] 0 monitored device(s) found. Accessory is in mode "any" so NOT triggering occupancy.
[8/3/2020, 9:33:40 AM] [Airmega] [ERROR] Unable to get filter change indication for Max2 Filter. Cannot read property 'lifeLevel' of undefined
[8/3/2020, 9:33:40 AM] [Airmega] [ERROR] Unable to get filter life level for Max2 Filter. Cannot read property 'lifeLevel' of undefined
[8/3/2020, 9:33:40 AM] [Airmega] [ERROR] Unable to get filter change indication for Pre Filter. Cannot read property 'lifeLevel' of undefined
[8/3/2020, 9:33:40 AM] [Airmega] [ERROR] Unable to get filter life level for Pre Filter. Cannot read property 'lifeLevel' of undefined
[8/3/2020, 9:33:43 AM] [Airmega] [ERROR] Unable to get filter change indication for Max2 Filter. Cannot read property 'lifeLevel' of undefined
[8/3/2020, 9:33:43 AM] [Airmega] [ERROR] Unable to get filter life level for Max2 Filter. Cannot read property 'lifeLevel' of undefined
[8/3/2020, 9:33:43 AM] [Airmega] [ERROR] Unable to get filter change indication for Pre Filter. Cannot read property 'lifeLevel' of undefined
[8/3/2020, 9:33:43 AM] [Airmega] [ERROR] Unable to get filter life level for Pre Filter. Cannot read property 'lifeLevel' of undefined
[8/3/2020, 9:33:44 AM] [Occupancy Sensor] 0 monitored device(s) found. Accessory is in mode "any" so NOT triggering occupancy.
[8/3/2020, 9:33:54 AM] [Occupancy Sensor] 0 monitored device(s) found. Accessory is in mode "any" so NOT triggering occupancy.
[8/3/2020, 9:34:00 AM] [UniFi Protect] Sending snapshot: 1280x720 Backyard
[8/3/2020, 9:34:00 AM] [UniFi Protect] Sending snapshot: 1280x720 Compost
[8/3/2020, 9:34:00 AM] [UniFi Protect] Sending snapshot: 1280x720 Driveway
[8/3/2020, 9:34:04 AM] [Occupancy Sensor] 0 monitored device(s) found. Accessory is in mode "any" so NOT triggering occupancy.
[8/3/2020, 9:34:06 AM] [UniFi Protect] Starting video stream: 1280x720, 25 fps, 299 kbps Driveway
[8/3/2020, 9:34:14 AM] [Occupancy Sensor] 0 monitored device(s) found. Accessory is in mode "any" so NOT triggering occupancy.
[8/3/2020, 9:34:24 AM] [Occupancy Sensor] 0 monitored device(s) found. Accessory is in mode "any" so NOT triggering occupancy.
[8/3/2020, 9:34:32 AM] [UniFi Protect] Sending snapshot: 1280x720 Backyard
[8/3/2020, 9:34:33 AM] [UniFi Protect] Sending snapshot: 1280x720 Compost
[8/3/2020, 9:34:33 AM] [UniFi Protect] Sending snapshot: 1280x720 Driveway
[8/3/2020, 9:34:33 AM] [UniFi Protect] Stopped video stream. Driveway
[8/3/2020, 9:34:34 AM] [Occupancy Sensor] 0 monitored device(s) found. Accessory is in mode "any" so NOT triggering occupancy.
[8/3/2020, 9:34:43 AM] [UniFi Protect] Sending snapshot: 1280x720 Backyard
[8/3/2020, 9:34:43 AM] [UniFi Protect] Sending snapshot: 1280x720 Compost
[8/3/2020, 9:34:44 AM] [UniFi Protect] Sending snapshot: 1280x720 Driveway
[8/3/2020, 9:34:44 AM] [Occupancy Sensor] 0 monitored device(s) found. Accessory is in mode "any" so NOT triggering occupancy.

@s1rc
Copy link

s1rc commented Aug 5, 2020

Setup

Hardware:

  • Raspberry Pi 4B 4G
  • UDMP v1.8.0-rc11
  • UniFi Protect v1.14.11

Software:

  • Homebridge Raspian
    • Linux homebridge 5.4.51-v7l+ #1327 SMP Thu Jul 23 11:04:39 BST 2020 armv7l
    • Homebridge Raspbian v1.0.4 - Raspberry Pi 4 Model B Rev 1.1
  • Homebridge v1.1.1
  • Node v12.18.3
  • FFmpeg v4.2.git-47773f7

FFmpeg

Click to expand!
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

Homebridge Config

Click to expand!
{
          "name": "UniFi Protect",
          "unifi": {
              "enhanced_classes": [
                  "person"
              ],
              "controller": "https://10.0.0.1",
              "controller_rtsp": "rtsp://10.0.0.1:7447",
              "username": "****",
              "password": "****",
              "motion_interval": 5000,
              "motion_repeat_interval": 30000,
              "motion_score": 0,
              "enhanced_motion": true,
              "enhanced_motion_score": 55,
              "enable_motion_trigger": true,
              "save_snapshot": false,
              "debug": true,
              "debug_network_traffic": false
          },
          "googlePhotos": {
              "upload_gphotos": false,
              "auth_redirectUrl": "http://localhost:8080/oauth2-callback"
          },
          "videoConfig": {
              "vcodec": "h264_omx",
              "audio": true,
              "maxStreams": 2,
              "maxWidth": 1920,
              "maxHeight": 1080,
              "maxFPS": 15,
              "mapvideo": "0:1",
              "mapaudio": "0:0",
              "maxBitrate": "3000",
              "packetSize": 188,
              "additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp"
          },
          "platform": "UnifiProtectMotion"
      }

Homebridge Logs

Click to expand!
[8/5/2020, 08:41:12] [HB Supervisor] OS: Linux 5.4.51-v7l+ arm
[8/5/2020, 08:41:12] [HB Supervisor] Node.js v12.18.3 /usr/local/bin/node
[8/5/2020, 08:41:12] [HB Supervisor] Homebridge Path: /usr/local/lib/node_modules/homebridge/bin/homebridge
[8/5/2020, 08:41:12] [HB Supervisor] UI Path: /usr/local/lib/node_modules/homebridge-config-ui-x/dist/bin/standalone.js
[8/5/2020, 08:41:12] [HB Supervisor] Starting Homebridge with extra flags: -I
[8/5/2020, 08:41:12] [HB Supervisor] Started Homebridge v1.1.1 with PID: 20885
[8/5/2020, 08:41:13] Loaded config.json with 1 accessories and 4 platforms.
[8/5/2020, 08:41:13] ---
[8/5/2020, 08:41:14] Loaded plugin: [email protected]
[8/5/2020, 08:41:14] Registering platform 'homebridge-config-ui-x.config'
[8/5/2020, 08:41:14] ---
[8/5/2020, 08:41:15] [Config] Homebridge Config UI X v4.24.0 is listening on :: port 8080
[8/5/2020, 08:41:14] Loaded plugin: [email protected]
[8/5/2020, 08:41:14] Registering platform 'homebridge-dyson-pure-cool.DysonPureCoolPlatform'
[8/5/2020, 08:41:14] ---
[8/5/2020, 08:41:14] Loaded plugin: [email protected]
[8/5/2020, 08:41:14] Registering platform 'homebridge-myq2.myQ'
[8/5/2020, 08:41:14] ---
[8/5/2020, 08:41:14] Loaded plugin: [email protected]
[8/5/2020, 08:41:14] Registering accessory 'homebridge-pihole.Pihole'
[8/5/2020, 08:41:14] ---
cpu backend was already registered. Reusing existing backend factory.
Platform node has already been set. Overwriting the platform with [object Object].
[8/5/2020, 08:41:18] Loaded plugin: [email protected]
[8/5/2020, 08:41:18] Registering platform 'homebridge-unifi-protect-camera-motion.UnifiProtectMotion'
[8/5/2020, 08:41:18] ---
[8/5/2020, 08:41:18] Loading 4 platforms...
[8/5/2020, 08:41:18] [Config] Initializing config platform...
[8/5/2020, 08:41:18] [Config] Running in Service Mode
[8/5/2020, 08:41:18] [MyQ] Initializing myQ platform...
[8/5/2020, 08:41:18] [DysonPureCoolPlatform] Initializing DysonPureCoolPlatform platform...
[8/5/2020, 08:41:18] [UniFi Protect] Initializing UnifiProtectMotion platform...
[8/5/2020, 08:41:18] Loading 1 accessories...
[8/5/2020, 08:41:18] [Pihole] Initializing Pihole accessory...
[8/5/2020, 08:41:18] [UniFi Protect] Configuring accessory Backyard
[8/5/2020, 08:41:18] [UniFi Protect] Configuring accessory Front Door
[8/5/2020, 08:41:18] [UniFi Protect] Configuring accessory Driveway
[8/5/2020, 08:41:18] [UniFi Protect] Configuring accessory Garage
[8/5/2020, 08:41:18] [DysonPureCoolPlatform] Device credentials not stored, asking Dyson API. If you want to prevent communication with the Dyson API, copy the credentials for each device from the coming log entries to the config.json.
[8/5/2020, 08:41:18] [DysonPureCoolPlatform] Signing in.
Setup Payload:
X-HM://
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:
                    
 ┌────────────┐     
 │ xxx-xx-xxx │     
 └────────────┘     
                    
[8/5/2020, 08:41:18] Homebridge is running on port 51575.
[8/5/2020, 08:41:18] [UniFi Protect] Endpoint Style: UnifiOS
[8/5/2020, 08:41:18] [MyQ] myQ API: Successfully connected to the myQ API.
[8/5/2020, 08:41:19] [UniFi Protect] Found camera: Backyard (id: 5e7e473d01835903870003f0)
[8/5/2020, 08:41:19] [UniFi Protect] Found camera: Front Door (id: 5e7e473d01515903870003ee)
[8/5/2020, 08:41:19] [UniFi Protect] Found camera: Driveway (id: 5ee8ca2a02c9a40387001182)
[8/5/2020, 08:41:19] [UniFi Protect] Found camera: Garage (id: 5e7e473d01725903870003ef)
[8/5/2020, 08:41:21] [DysonPureCoolPlatform] Got devices from the Dyson API.
[8/5/2020, 08:41:23] [UniFi Protect] Motion checking setup done!
[8/5/2020, 08:41:52] [UniFi Protect] Sending snapshot: 480x270 Backyard
[8/5/2020, 08:41:55] [UniFi Protect] Sending snapshot: 480x270 Garage
[8/5/2020, 08:41:55] [UniFi Protect] Sending snapshot: 480x270 Front Door
[8/5/2020, 08:41:58] [UniFi Protect] Sending snapshot: 480x270 Driveway
[8/5/2020, 08:41:58] [UniFi Protect] Starting video stream: 1280x720, 15 fps, 299 kbps Garage
[8/5/2020, 08:41:58] [UniFi Protect] ffmpeg exited with code: 1 and signal: null (Error) Garage
[8/5/2020, 08:41:58] [UniFi Protect] Stopped video stream. Garage
[8/5/2020, 08:42:03] [UniFi Protect] Sending snapshot: 480x270 Front Door
[8/5/2020, 08:42:04] [UniFi Protect] Sending snapshot: 480x270 Backyard

@beele
Copy link
Owner Author

beele commented Aug 5, 2020

Could you try with: sudo npm i -g --unsafe-perm=true [email protected]
This version will also print the location of the ffmpeg binary that is being used by the plugin when it starts: VIDEO PROCESSOR: PATH_TO_FFMPEG

@s1rc
Copy link

s1rc commented Aug 5, 2020

VIDEO PROCESSOR: /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/ffmpeg-for-homebridge/ffmpeg

@beele that's from the Homebridge startup logs.

@beele
Copy link
Owner Author

beele commented Aug 5, 2020

Ok, thats already good.
Second, what interfaces does your device have (eth0, wlan0, ...) and which one is used?
Also, if you enable the debug boolean in the config from the plugin it should print detailed information when trying to start a stream (might need to run homebridge with the -D option)

@s1rc
Copy link

s1rc commented Aug 5, 2020

@beele It's just running on eth0, the only accessory the RPi has is a PoE hat.

Here's an output from -D:

[8/5/2020, 11:28:21] [UniFi Protect] Starting video stream: 1280x720, 15 fps, 299 kbps Garage
[8/5/2020, 11:28:21] [UniFi Protect] Stream command: /usr/local/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/ffmpeg-for-homebridge/ffmpeg -rtsp_transport tcp -re -i rtsp://10.0.0.1:7447/UEjbvyDxCL9gpG61 -map 0:1 -vcodec h264_omx -pix_fmt yuv420p -r 15 -f rawvideo -protocol_whitelist https,crypto,srtp,rtp,udp -vf scale=1280:720 -b:v 299k -bufsize 598k -maxrate 299k -payload_type 99 -ssrc 10754864 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params WnPuH+xFHj2JljC3gq49OWJarHecDMlZbq1ZSuts srtp://10.0.50.60:54763?rtcpport=54763&localrtcpport=54763&pkt_size=188 -map 0:0 -acodec libfdk_aac -profile:a aac_eld -flags +global_header -f null -ar 16k -b:a 24k -bufsize 24k -ac 1 -payload_type 110 -ssrc 1464170 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params vZTZn22SZ1d1W75n7/vYTkdqpVgRnaYEv/docKqY srtp://10.0.50.60:57799?rtcpport=57799&localrtcpport=57799&pkt_size=188 -loglevel level+verbose Garage true
[8/5/2020, 11:28:21] [UniFi Protect] Received first frame. Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [info] ffmpeg version 4.2.2-d1e8be3 Copyright (c) 2000-2019 the FFmpeg developers Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [info]   built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516 Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [info]   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-libspeex --enable-demuxer=rtsp --enable-omx-rpi --enable-mmal --enable-indev=alsa --enable-outdev=alsa Garage true
[8/5/2020, 11:28:21] [UniFi Protect]  Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [info]   libavutil      56. 31.100 / 56. 31.100 Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [info]   libavcodec     58. 54.100 / 58. 54.100 Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [info]   libavformat    58. 29.100 / 58. 29.100 Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [info]   libavdevice    58.  8.100 / 58.  8.100 Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [info]   libavfilter     7. 57.100 /  7. 57.100 Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [info]   libswscale      5.  5.100 /  5.  5.100 Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [info]   libswresample   3.  5.100 /  3.  5.100 Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [info]   libpostproc    55.  5.100 / 55.  5.100 Garage true
[8/5/2020, 11:28:21] [UniFi Protect]  Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [tcp @ 0x322f350] [verbose] Starting connection attempt to 10.0.0.1 port 7447 Garage true
[8/5/2020, 11:28:21] [UniFi Protect]  Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [tcp @ 0x322f350] [verbose] Successfully connected to 10.0.0.1 port 7447 Garage true
[8/5/2020, 11:28:21] [UniFi Protect] [error] rtsp://10.0.0.1:7447/UEjbvyDxCL9gpG61: Invalid data found when processing input Garage true
[8/5/2020, 11:28:21] [UniFi Protect]  Garage true
[8/5/2020, 11:28:21] [UniFi Protect] ffmpeg exited with code: 1 and signal: null (Error) Garage
[8/5/2020, 11:28:21] [UniFi Protect] Stopped video stream. Garage
[8/5/2020, 11:28:22] [UniFi Protect] {
  type: 'motion',
  start: 1596641289516,
  end: 1596641296089,
  camera: '5ee8ca2a02c9a40387001182',
  score: 2,
  id: '5f2ad00c0230b70387000ac8',
  metadata: { objectType: null, objectCoords: null, objectConfidence: null },
  modelKey: 'event',
  partition: null,
  thumbnail: 'e-5f2ad00c0230b70387000ac8',
  heatmap: 'e-5f2ad00c0230b70387000ac8'
}

@beele
Copy link
Owner Author

beele commented Aug 5, 2020

hmm, I see: rtsp://10.0.0.1:7447/UEjbvyDxCL9gpG61: Invalid data found when processing input Garage true
Which could mean there are corrupted frames coming from the video feed.
Which camera(s) do you have?

@s1rc
Copy link

s1rc commented Aug 5, 2020

@beele that camera is a UVC G3 Flex, there are other UVC G4 Pro which also don't work.

When I upgraded to [email protected] it worked once then all subsequent attempts to stream fail.

@Sunoo
Copy link

Sunoo commented Aug 5, 2020

@beele Yea, not quite sure what’s going on either, or why this type of issue seems to be spiking recently.

Are you on the Homebridge Discord? A few camera plugin developers are on there and it’s a convenient way to huddle on issues that impact us all.

@beele
Copy link
Owner Author

beele commented Aug 6, 2020

@Sunoo I'll join the discord to chime in

@mikestecker
Copy link

I'm having issues as well...

Hardware:

Ubuntu 20.04
Nvidia P2000 with latest CUDA drivers
UDMP v1.7.2
UniFi Protect v1.14.11

Software:

Docker v19.03.13-beta2, build ff3fbc9d55
Docker Homebridge: oznu/docker-homebridge:ubuntu (latest)
Plugin version: homebridge-unifi-protect-camera-motion v0.4.2-beta.1
Node: v12.18.3
ffmpeg version 4.2.2-d1e8be3

FFmpeg:

Click to expand!
ffmpeg version 4.2.2-d1e8be3 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+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-libspeex --enable-demuxer=rtsp --enable-indev=alsa --enable-outdev=alsa
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100

Homebridge Config:

Click to expand!
{
    "bridge": {
        "name": "Homebridge Docker",
        "username": "0E:E7:34:1E:DD:BD",
        "port": 53608,
        "pin": "**********"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8089,
            "auth": "form",
            "theme": "auto",
            "tempUnits": "f",
            "lang": "auto",
            "platform": "config",
            "sudo": true
        },
        {
            "name": "Unifi protect cameras & motion sensors",
            "unifi": {
                "enhanced_classes": [
                    "person"
                ],
                "controller": "https://**.**.**.**",
                "controller_rtsp": "rtsp://**.**.**.**:7447",
                "username": "************",
                "password": "******************",
                "motion_interval": 5000,
                "motion_repeat_interval": 30000,
                "motion_score": 0,
                "enhanced_motion": true,
                "enhanced_motion_score": 55,
                "enable_motion_trigger": true,
                "enable_doorbell_for": [
                    "5f122a9a00f1e70387000778"
                ],
                "save_snapshot": false,
                "debug": true,
                "debug_network_traffic": false
            },
            "googlePhotos": {
                "upload_gphotos": false,
                "auth_redirectUrl": "http://localhost:8080/oauth2-callback"
            },
            "videoConfig": {
                "maxStreams": 2,
                "maxWidth": 1920,
                "maxHeight": 1080,
                "maxFPS": 30,
                "maxBitrate": 5000,
                "vcodec": "h264",
                "packetSize": 376,
                "audio": true,
                "additionalCommandline": "-protocol_whitelist https,crypto,srtp,rtp,udp"
            },
            "platform": "UnifiProtectMotion"
        }
    ]
}

Homebridge Logs:

Click to expand!
[8/10/2020, 1:14:18 PM] [HB Supervisor] Starting Homebridge with extra flags: -I -P /homebridge/node_modules
[8/10/2020, 1:14:19 PM] [HB Supervisor] Started Homebridge v1.1.1 with PID: 17119
[8/10/2020, 1:14:19 PM] Loaded config.json with 0 accessories and 3 platforms.
[8/10/2020, 1:14:19 PM] ---
2020-08-10 13:14:19.877854: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-08-10 13:14:19.908619: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3998895000 Hz
2020-08-10 13:14:19.909027: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4551680 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-08-10 13:14:19.909041: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
[8/10/2020, 1:14:20 PM] Loaded plugin: [email protected]
[8/10/2020, 1:14:20 PM] Registering platform 'homebridge-unifi-protect-camera-motion.UnifiProtectMotion'
[8/10/2020, 1:14:20 PM] ---
[8/10/2020, 1:14:20 PM] Loaded plugin: [email protected]
[8/10/2020, 1:14:20 PM] Registering platform 'homebridge-weather-plus.WeatherPlus'
[8/10/2020, 1:14:20 PM] ---
[8/10/2020, 1:14:20 PM] Loaded plugin: [email protected]
[8/10/2020, 1:14:20 PM] Registering platform 'homebridge-config-ui-x.config'
[8/10/2020, 1:14:20 PM] ---
[8/10/2020, 1:14:20 PM] Loading 3 platforms...
[8/10/2020, 1:14:20 PM] [Config] Initializing config platform...
[8/10/2020, 1:14:20 PM] [Config] Running in Service Mode
[8/10/2020, 1:14:20 PM] [Unifi protect cameras & motion sensors] Initializing UnifiProtectMotion platform...
[8/10/2020, 1:14:20 PM] [Unifi protect cameras & motion sensors] VIDEO PROCESSOR: /homebridge/node_modules/homebridge-unifi-protect-camera-motion/node_modules/ffmpeg-for-homebridge/ffmpeg
[8/10/2020, 1:14:20 PM] [WeatherPlus] Initializing WeatherPlus platform...
[8/10/2020, 1:14:20 PM] [WeatherPlus] Adding station with weather service OpenWeatherMap named 'Now'
[8/10/2020, 1:14:20 PM] Initializing platform accessory 'Now'...
[8/10/2020, 1:14:20 PM] [Unifi protect cameras & motion sensors] Configuring accessory Doorbell
[8/10/2020, 1:14:20 PM] [Unifi protect cameras & motion sensors] Configuring accessory Garage
[8/10/2020, 1:14:20 PM] [Unifi protect cameras & motion sensors] Configuring accessory Side Gate
[8/10/2020, 1:14:20 PM] [Unifi protect cameras & motion sensors] Configuring accessory Living Room
[8/10/2020, 1:14:20 PM] [Unifi protect cameras & motion sensors] Configuring accessory Entryway
[8/10/2020, 1:14:20 PM] [Unifi protect cameras & motion sensors] Configuring accessory Driveway
Setup Payload:
X-HM://00253XGMMJOK9
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ ***-**-*** │     
    └────────────┘     
                       
[8/10/2020, 1:14:20 PM] Homebridge is running on port 53608.
[8/10/2020, 1:14:20 PM] [Unifi protect cameras & motion sensors] Endpoint Style: UnifiOS
[8/10/2020, 1:14:21 PM] [Unifi protect cameras & motion sensors] Found camera: Doorbell (id: 5f122a9a00f1e70387000778)
[8/10/2020, 1:14:21 PM] [Unifi protect cameras & motion sensors] Found camera: Garage (id: 5e33fd6703de1b03870003f7)
[8/10/2020, 1:14:21 PM] [Unifi protect cameras & motion sensors] Found camera: Side Gate (id: 5e33fd6703d41b03870003f6)
[8/10/2020, 1:14:21 PM] [Unifi protect cameras & motion sensors] Found camera: Living Room (id: 5e57086601e3150387000462)
[8/10/2020, 1:14:21 PM] [Unifi protect cameras & motion sensors] Found camera: Entryway (id: 5e345b120094710387000cf2)
[8/10/2020, 1:14:21 PM] [Unifi protect cameras & motion sensors] Found camera: Driveway (id: 5e33fd6703901b03870003f4)
[8/10/2020, 1:14:21 PM] [Unifi protect cameras & motion sensors] Motion checking setup done!
[8/10/2020, 1:14:24 PM] [Unifi protect cameras & motion sensors] Starting video stream: 1280x720, 30 fps, 299 kbps Doorbell
[8/10/2020, 1:14:27 PM] [Unifi protect cameras & motion sensors] ffmpeg exited with code: 1 and signal: null (Error) Doorbell
[8/10/2020, 1:14:27 PM] [Unifi protect cameras & motion sensors] Stopped video stream. Doorbell
[8/10/2020, 1:14:31 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Side Gate
[8/10/2020, 1:14:31 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Driveway
[8/10/2020, 1:14:31 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Entryway
[8/10/2020, 1:14:32 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Living Room
[8/10/2020, 1:14:32 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Doorbell
[8/10/2020, 1:14:32 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Garage
[8/10/2020, 1:14:33 PM] [Unifi protect cameras & motion sensors] Starting video stream: 1280x720, 30 fps, 299 kbps Driveway
[8/10/2020, 1:14:37 PM] [Unifi protect cameras & motion sensors] Device appears to be inactive for over 5 seconds. Stopping stream. Doorbell
[8/10/2020, 1:14:37 PM] [Unifi protect cameras & motion sensors] Stopped video stream. Doorbell
[8/10/2020, 1:14:40 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Side Gate
[8/10/2020, 1:14:40 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Driveway
[8/10/2020, 1:14:40 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Entryway
[8/10/2020, 1:14:40 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Living Room
[8/10/2020, 1:14:40 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Garage
[8/10/2020, 1:14:40 PM] [Unifi protect cameras & motion sensors] Stopped video stream. Driveway
[8/10/2020, 1:14:42 PM] [Unifi protect cameras & motion sensors] Sending snapshot: 1280x720 Doorbell

@s1rc
Copy link

s1rc commented Aug 14, 2020

@beele I just received my G4 Doorbell and set it up. Without changing any config in Homebridge except for adding the doorbell ID, the video streams just fine from the doorbell.

The G3 Flex's and G4 Pro's won't stream still.

Edit: All the RTSP streams work fine in VLC.

@s1rc
Copy link

s1rc commented Aug 16, 2020

@beele I think I know why ffmpeg is getting Invalid Data from the stream.

Looking at the logs it's showing the RTSP endpoint for that camera as rtsp://10.0.0.1:7447/UEjbvyDxCL9gpG61 but in UniFi Protect in the camera config it's rtsp://10.0.0.1:7447/7sn7aquqd4EUL3iU. I've only ever had one RTSP stream enabled.

image

I thought to check after I connected another G3 Flex and it worked without any issues and has the same settings/camera fw.

Maybe UniFi Protect changed the stream endpoints and they are cached?

@madrobby
Copy link
Contributor

Here's the output with debugging info when requesting a video stream:

[8/17/2020, 12:04:59 PM] [Unifi Protect] Video stream requested: 1280x720, 30 fps, 299 kbps Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect] Starting video stream: 1280x720, 15 fps, 299 kbps Sky Cam
[8/17/2020, 12:04:59 PM] [Unifi Protect] Stream command: /usr/local/bin/ffmpeg -rtsp_transport tcp -re -i rtsp://192.168.16.1:7447/cVNJiDdYp36QP3zx -map 0:0 -vcodec h264 -pix_fmt yuv420p -r 15 -f rawvideo -protocol_whitelist https,crypto,srtp,rtp,udp -loglevel verbose -vf scale=1280:720 -b:v 299k -bufsize 598k -maxrate 299k -payload_type 99 -ssrc 11056545 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params aDUiglquSrTRJNLKC+AB402jkCfsUyuWVl8c9HS9 srtp://192.168.17.70:65193?rtcpport=65193&localrtcpport=65193&pkt_size=188 -loglevel level+verbose Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect] Received first frame. Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect] ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]   built with Apple clang version 11.0.3 (clang-1103.0.32.62) Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]   configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]   libavutil      56. 51.100 / 56. 51.100 Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]   libavcodec     58. 91.100 / 58. 91.100 Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]   libavformat    58. 45.100 / 58. 45.100 Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]   libavdevice    58. 10.100 / 58. 10.100 Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]   libavfilter     7. 85.100 /  7. 85.100 Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]   libavresample   4.  0.  0 /  4.  0.  0 Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]   libswscale      5.  7.100 /  5.  7.100 Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]   libswresample   3.  7.100 /  3.  7.100 Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]   libpostproc    55.  7.100 / 55.  7.100 Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect] [tcp @ 0x7fba4c604380] [verbose] Starting connection attempt to 192.168.16.1 port 7447 Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect] [tcp @ 0x7fba4c604380] [verbose] Successfully connected to 192.168.16.1 port 7447 Sky Cam true
[8/17/2020, 12:04:59 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:03 PM] [Unifi Protect] [rtsp @ 0x7fba4c814600] [verbose] SDP: Sky Cam true
 Sky Cam true2:05:03 PM] [Unifi Protect] v=0
 Sky Cam true2:05:03 PM] [Unifi Protect] o=- 382 0 IN IP4 192.168.16.1
 Sky Cam true2:05:03 PM] [Unifi Protect] s=E063DA3F962A_1
 Sky Cam true2:05:03 PM] [Unifi Protect] u=www.evostream.com
 Sky Cam true2:05:03 PM] [Unifi Protect] [email protected]
 Sky Cam true2:05:03 PM] [Unifi Protect] c=IN IP4 192.168.16.1
 Sky Cam true2:05:03 PM] [Unifi Protect] t=0 0
 Sky Cam true2:05:03 PM] [Unifi Protect] a=recvonly
 Sky Cam true2:05:03 PM] [Unifi Protect] a=control:*
 Sky Cam true2:05:03 PM] [Unifi Protect] a=range:npt=now-
 Sky Cam true2:05:03 PM] [Unifi Protect] m=audio 0 RTP/AVP 96
 Sky Cam true2:05:03 PM] [Unifi Protect] a=recvonly
 Sky Cam true2:05:03 PM] [Unifi Protect] a=rtpmap:96 mpeg4-generic/48000/1
 Sky Cam true2:05:03 PM] [Unifi Protect] a=control:trackID=1
[8/17/2020, 12:05:03 PM] [Unifi Protect] a=fmtp:96 streamtype=5; profile-level-id=15; mode= Sky Cam trueig=1188; SizeLength=13; IndexLength=3; IndexDeltaLength=3;
 Sky Cam true2:05:03 PM] [Unifi Protect] m=video 0 RTP/AVP 97
 Sky Cam true2:05:03 PM] [Unifi Protect] a=recvonly
 Sky Cam true2:05:03 PM] [Unifi Protect] a=control:trackID=2
 Sky Cam true2:05:03 PM] [Unifi Protect] a=rtpmap:97 H264/90000
[8/17/2020, 12:05:03 PM] [Unifi Protect] a=fmtp:97 profile-level-id=4d401f; packetization-m Sky Cam trueparameter-sets=Z01AH42NQCgC3/gLcBAQFAAAD6AAAdTCdoIhGoA=,aO44gA==
[8/17/2020, 12:05:03 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:03 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:03 PM] [Unifi Protect] [rtsp @ 0x7fba4c814600] [verbose] setting jitter buffer size to 0 Sky Cam true
[8/17/2020, 12:05:03 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:03 PM] [Unifi Protect] [rtsp @ 0x7fba4c814600] [verbose] setting jitter buffer size to 0 Sky Cam true
[8/17/2020, 12:05:03 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:03 PM] [Unifi Protect] [h264 @ 0x7fba4e80c200] [verbose] Reinit context to 1280x720, pix_fmt: yuvj420p Sky Cam true
[8/17/2020, 12:05:03 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info] Input #0, rtsp, from 'rtsp://192.168.16.1:7447/cVNJiDdYp36QP3zx': Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]   Metadata: Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]     title           : E063DA3F962A_1 Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]   Duration: N/A, start: 0.000000, bitrate: N/A Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]     Stream #0:0: Audio: aac (LC), 48000 Hz, mono, fltp Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]     Stream #0:1: Video: h264 (Main), 1 reference frame, yuvj420p(pc, bt709, progressive, left), 1280x720 [SAR 1:1 DAR 16:9], 15 fps, 24 tbr, 90k tbn, 30 tbc Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [warning] Codec AVOption b (set bitrate (in bits/s)) specified for output file #0 (srtp://192.168.17.70:65193?rtcpport=65193&localrtcpport=65193&pkt_size=188) 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. Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info] Stream mapping: Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]  Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect]   Stream #0:0 -> #0:0 (aac (native) -> pcm_mulaw (native)) Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info] Press [q] to stop, [?] for help Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [graph_0_in_0_0 @ 0x7fba4c42c800] [verbose] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x4 Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [format_out_0_0 @ 0x7fba4c42eb40] [verbose] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_0' Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [auto_resampler_0 @ 0x7fba4c42f500] [verbose] ch:1 chl:mono fmt:fltp r:48000Hz -> ch:1 chl:mono fmt:s16 r:48000Hz Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info] Output #0, rtp, to 'srtp://192.168.17.70:65193?rtcpport=65193&localrtcpport=65193&pkt_size=188': Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]   Metadata: Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]     title           : E063DA3F962A_1 Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]     encoder         : Lavf58.45.100 Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]     Stream #0:0: Audio: pcm_mulaw, 48000 Hz, mono, s16, 384 kb/s Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]     Metadata: Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info]       encoder         : Lavc58.91.100 pcm_mulaw Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect]  Sky Cam true
[8/17/2020, 12:05:05 PM] [Unifi Protect] [info] size=      24kB time=00:00:00.46 bitrate= 4 Sky Cam truepeed=0.93x    
[8/17/2020, 12:05:06 PM] [Unifi Protect] [info] size=      50kB time=00:00:00.98 bitrate= 4 Sky Cam truepeed=0.947x    
[8/17/2020, 12:05:06 PM] [Unifi Protect] [info] size=      78kB time=00:00:01.53 bitrate= 4 Sky Cam truepeed=0.969x    
[8/17/2020, 12:05:07 PM] [Unifi Protect] [info] size=     105kB time=00:00:02.06 bitrate= 4 Sky Cam truepeed=0.984x    
[8/17/2020, 12:05:07 PM] [Unifi Protect] [info] size=     132kB time=00:00:02.60 bitrate= 4 Sky Cam truepeed=0.981x    
[8/17/2020, 12:05:08 PM] [Unifi Protect] [info] size=     160kB time=00:00:03.15 bitrate= 4 Sky Cam truepeed=0.992x    
[8/17/2020, 12:05:08 PM] [Unifi Protect] [info] size=     186kB time=00:00:03.66 bitrate= 4 Sky Cam truepeed=0.994x    
[8/17/2020, 12:05:09 PM] [Unifi Protect] [info] size=     213kB time=00:00:04.20 bitrate= 4 Sky Cam truepeed=0.987x    
[8/17/2020, 12:05:09 PM] [Unifi Protect] [info] size=     240kB time=00:00:04.73 bitrate= 4 Sky Cam truepeed=0.99x    
[8/17/2020, 12:05:10 PM] [Unifi Protect] [info] size=     268kB time=00:00:05.29 bitrate= 4 Sky Cam truepeed=0.99x    
[8/17/2020, 12:05:11 PM] [Unifi Protect] [info] size=     295kB time=00:00:05.82 bitrate= 4 Sky Cam truepeed=0.992x    
[8/17/2020, 12:05:11 PM] [Unifi Protect] [info] size=     322kB time=00:00:06.35 bitrate= 4 Sky Cam truepeed=0.997x    
[8/17/2020, 12:05:12 PM] [Unifi Protect] [info] size=     348kB time=00:00:06.86 bitrate= 4 Sky Cam truepeed=0.992x    
[8/17/2020, 12:05:12 PM] [Unifi Protect] [info] size=     378kB time=00:00:07.44 bitrate= 4 Sky Cam truepeed=0.997x    
[8/17/2020, 12:05:13 PM] [Unifi Protect] [info] size=     403kB time=00:00:07.93 bitrate= 4 Sky Cam truepeed=0.994x    
[8/17/2020, 12:05:13 PM] [Unifi Protect] [info] size=     430kB time=00:00:08.46 bitrate= 4 Sky Cam truepeed=0.994x    
[8/17/2020, 12:05:14 PM] [Unifi Protect] [info] size=     456kB time=00:00:08.98 bitrate= 4 Sky Cam truepeed=0.995x    
[8/17/2020, 12:05:14 PM] [Unifi Protect] [info] size=     485kB time=00:00:09.55 bitrate= 4 Sky Cam truepeed=0.995x    
[8/17/2020, 12:05:15 PM] [Unifi Protect] [info] size=     514kB time=00:00:10.13 bitrate= 4 Sky Cam truepeed=0.995x    
[8/17/2020, 12:05:15 PM] [Unifi Protect] [info] size=     543kB time=00:00:10.70 bitrate= 4 Sky Cam truepeed=0.997x    
[8/17/2020, 12:05:16 PM] [Unifi Protect] [info] size=     571kB time=00:00:11.26 bitrate= 4 Sky Cam truepeed=   1x    
[8/17/2020, 12:05:16 PM] [Unifi Protect] [info] size=     596kB time=00:00:11.75 bitrate= 4 Sky Cam truepeed=0.996x    
[8/17/2020, 12:05:17 PM] [Unifi Protect] [info] size=     624kB time=00:00:12.30 bitrate= 4 Sky Cam truepeed=0.997x    
[8/17/2020, 12:05:18 PM] [Unifi Protect] [info] size=     651kB time=00:00:12.84 bitrate= 4 Sky Cam truepeed=0.997x    
[8/17/2020, 12:05:18 PM] [Unifi Protect] [info] size=     680kB time=00:00:13.39 bitrate= 4 Sky Cam truepeed=0.996x    
[8/17/2020, 12:05:19 PM] [Unifi Protect] [info] size=     708kB time=00:00:13.95 bitrate= 4 Sky Cam truepeed=0.996x    
[8/17/2020, 12:05:19 PM] [Unifi Protect] [info] size=     737kB time=00:00:14.52 bitrate= 4 Sky Cam truepeed=0.997x    
[8/17/2020, 12:05:20 PM] [Unifi Protect] [info] size=     764kB time=00:00:15.06 bitrate= 4 Sky Cam truepeed=0.997x    
[8/17/2020, 12:05:20 PM] [Unifi Protect] [info] size=     791kB time=00:00:15.59 bitrate= 4 Sky Cam truepeed=0.996x    
[8/17/2020, 12:05:21 PM] [Unifi Protect] [info] size=     820kB time=00:00:16.17 bitrate= 4 Sky Cam truepeed=0.997x    
[8/17/2020, 12:05:21 PM] [Unifi Protect] [info] size=     846kB time=00:00:16.68 bitrate= 4 Sky Cam truepeed=0.997x    
[8/17/2020, 12:05:22 PM] [Unifi Protect] [info] size=     872kB time=00:00:17.19 bitrate= 4 Sky Cam truepeed=0.998x    
[8/17/2020, 12:05:22 PM] [Unifi Protect] [info] size=     899kB time=00:00:17.72 bitrate= 4 Sky Cam truepeed=0.998x    
[8/17/2020, 12:05:23 PM] [Unifi Protect] [info] size=     926kB time=00:00:18.26 bitrate= 4 Sky Cam truepeed=0.998x    
[8/17/2020, 12:05:24 PM] [Unifi Protect] [info] size=     953kB time=00:00:18.79 bitrate= 4 Sky Cam truepeed=0.998x    
[8/17/2020, 12:05:24 PM] [Unifi Protect] [info] size=     979kB time=00:00:19.30 bitrate= 4 Sky Cam truepeed=0.997x    
[8/17/2020, 12:05:25 PM] [Unifi Protect] [info] size=    1007kB time=00:00:19.86 bitrate= 4 Sky Cam truepeed=0.998x    
[8/17/2020, 12:05:25 PM] [Unifi Protect] Received request to reconfigure: 640x360, 30 fps, 132 kbps (Ignored) Sky Cam true
[8/17/2020, 12:05:25 PM] [Unifi Protect] [info] size=    1036kB time=00:00:20.41 bitrate= 4 Sky Cam truepeed=   1x    
[8/17/2020, 12:05:26 PM] [Unifi Protect] [info] size=    1059kB time=00:00:20.88 bitrate= 4 Sky Cam truepeed=0.998x    
[8/17/2020, 12:05:26 PM] [Unifi Protect] [info] size=    1086kB time=00:00:21.41 bitrate= 4 Sky Cam truepeed=0.999x    
[8/17/2020, 12:05:27 PM] [Unifi Protect] [info] size=    1115kB time=00:00:21.97 bitrate= 4 Sky Cam truepeed=   1x    
[8/17/2020, 12:05:27 PM] [Unifi Protect] [info] size=    1141kB time=00:00:22.48 bitrate= 4 Sky Cam truepeed=   1x    
[8/17/2020, 12:05:28 PM] [Unifi Protect] [info] size=    1164kB time=00:00:22.95 bitrate= 4 Sky Cam truepeed=0.999x    
[8/17/2020, 12:05:28 PM] [Unifi Protect] [info] size=    1190kB time=00:00:23.46 bitrate= 4 Sky Cam truepeed=0.999x    
[8/17/2020, 12:05:29 PM] [Unifi Protect] [info] size=    1217kB time=00:00:24.00 bitrate= 4 Sky Cam truepeed=0.999x    
[8/17/2020, 12:05:29 PM] [Unifi Protect] [info] size=    1246kB time=00:00:24.55 bitrate= 4 Sky Cam truepeed=0.998x    
[8/17/2020, 12:05:30 PM] [Unifi Protect] [info] size=    1273kB time=00:00:25.08 bitrate= 4 Sky Cam truepeed=0.999x    
[8/17/2020, 12:05:30 PM] [Unifi Protect] Stopped video stream. Sky Cam
[8/17/2020, 12:05:30 PM] [Unifi Protect] ffmpeg exited with code: null and signal: SIGKILL (Expected) Sky Cam true

Noticed this warning:

[8/17/2020, 12:05:05 PM] [Unifi Protect] [warning] Codec AVOption b (set bitrate (in bits/s)) specified for output file #0 (srtp://192.168.17.70:65193?rtcpport=65193&localrtcpport=65193&pkt_size=188) 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. Sky Cam true

@beele
Copy link
Owner Author

beele commented Aug 17, 2020

@s1rc I've checked this and it's indeed the case, I'm working on a fix that will update the source for the snapshots/stream every time that homebridge is (re)started.

@beele
Copy link
Owner Author

beele commented Aug 18, 2020

@s1rc @madrobby
Can you try with this beta version: [email protected]
It contains new logic to update the camera ip/rtsp streams every time homebridge is started and the new homebridge-camera-ffmpeg dependency that has fixes for streams that don't work/start.

sudo npm i -g [email protected] --unsafe-perm=true

@s1rc
Copy link

s1rc commented Aug 18, 2020

@beele so far so good! I've changed the RTSP stream endpoints by toggling on and off and restarting homebridge. All my cameras work now 🙇

@mikestecker
Copy link

mikestecker commented Aug 18, 2020

@beele Still not working for me, I've tried your new beta but still getting ffmpeg exited with code: 1 and signal: null (Error) <camera name>

My configs are in an earlier comment.

I have debugging turned on, but I'm not seeing the types of logs that @madrobby shows above. This is what I'm seeing in my logs:

[8/18/2020, 10:09:43 AM] [Unifi protect cameras & motion sensors] Starting video stream: 1280x720, 30 fps, 299 kbps Doorbell
[8/18/2020, 10:09:46 AM] [Unifi protect cameras & motion sensors] ffmpeg exited with code: 1 and signal: null (Error) Doorbell
[8/18/2020, 10:09:46 AM] [Unifi protect cameras & motion sensors] Stopped video stream. Doorbell
[8/18/2020, 10:10:03 AM] [Unifi protect cameras & motion sensors] Device appears to be inactive for over 5 seconds. Stopping stream. Doorbell
[8/18/2020, 10:10:03 AM] [Unifi protect cameras & motion sensors] Stopped video stream. Doorbell

@hjdhjd
Copy link

hjdhjd commented Aug 18, 2020

@beele Hope you don’t mind me posting here...I wanted to offer some insight on how to address the ffmpeg streaming issue. If you take a look at my UniFi Protect plugin, you can see how to address this one. There are a handful of unique issues to Protect streams...but the good news is that they’re pretty easy to overcome and you can get incredibly fast video streams.

There are two things that you need to do...the first involves adjusting the packet size. This is likely driving a lot of the long/slow starts that people are seeing above.

@Sunoo created a great starting point for camera plugins, but in doing so, he also made some of the shortcomings of Protect + ffmpeg more acute when those of us used it as a foundation. We all stand on his shoulders, and certainly my ffmpeg code is also directly based on his.

The second is that you don’t need to reencode the stream. This will speed things up dramatically. Protect outputs a very clean (minus the channel swaps for audio and video) H.264 stream.

In the spirit of collaboration, please feel free to crib my code from homebridge-unifi-protect2 as a starting point:

https://github.com/hjdhjd/homebridge-unifi-protect2/blob/772c6401f2923f950a50d5363b8a428c5b795a1a/src/protect-stream.ts#L207

This should also address #69

Finally, you might want to take a look at how I’ve approached snapshots for my plugin. I don’t rely on anonymous snapshots and instead pull it right from the camera API directly. It’s quite fast, and always sized correctly.

See here for that code:

https://github.com/hjdhjd/homebridge-unifi-protect2/blob/772c6401f2923f950a50d5363b8a428c5b795a1a/src/protect-stream.ts#L134

As you can see, it will auto-adjust the aspect ratio as well, addressing #70.

Hope this helps. You’ve created a nice plugin. Though we have different goals for our respective UniFi Protect homebridge plugins, I hope we can find opportunities to collaborate to provide a great experience to our user communities looking for UniFi Protect support for HomeKit.

@mikestecker
Copy link

@beele latest beta and no more ffmpeg errors! I also removed ALL of my previous videoConfig settings for the suggested stripped back version and it works! Before swapping out these settings, it wouldn't be live, but rather update every 8-10 seconds... but now it's live!

@hjdhjd
Copy link

hjdhjd commented Aug 21, 2020

@beele Hope the pointer to my codebase helped. Good luck!

@beele
Copy link
Owner Author

beele commented Aug 23, 2020

I think most issues have been resolved by this, thx again to @hjdhjd for the helpful insights.
However I noticed I'm no longer able to stream when not on my local wifi, the video just never starts. If I change the vcodec back to 'h264_omx' from the previous 'copy' value it starts working again. @hjdhjd any ideas as to why this might be?

@Sunoo
Copy link

Sunoo commented Aug 23, 2020

@beele I’ve had some users report similar things on my plugin, but I’ve never been able to recreate it or make sense of it. Maybe the home hub just rejects the stream if it’s way larger than it’s asking for or something? That’s just a wild guess though.

@hjdhjd
Copy link

hjdhjd commented Aug 23, 2020

@beele I’ve never had this issue, weirdly. What’s the quality of the stream (from the Protect end) that you’re trying to stream and what’s the camera model?

@hjdhjd
Copy link

hjdhjd commented Aug 23, 2020

@beele Just a hunch - add the -re option to your ffmpeg string and see if that does it. My hunch is that the reason why one works and the other doesn't is the slight delay that's introduced when you reencode. -re is not evil. It simply says only go as fast as the input I'm getting.

@Sunoo
Copy link

Sunoo commented Aug 23, 2020

@hjdhjd I will continue to recommend against using the option, until someone can point me to something from FFmpeg that supports using it. Right now all I've found from them says pretty explicitly not to use them in this situation.

@hjdhjd
Copy link

hjdhjd commented Aug 23, 2020

@Sunoo I understand your perspective. I've got experience that says, at least in this case, it works just fine and can alleviate some of these issues. You can choose to try or not.

All -re does is tell ffmpeg to only read information at the native frame rate of the input it's being provided. If you have hard data - not just documentation somewhere - that shows that this option doesn't work or is dangerous, I'm all for it.

ffmpeg is a great tool, but it's a Swiss army knife. I'm sure you're right in some situations, perhaps even in most situations. I'm just pointing to this situation and my own experience in spending time with it on this hardware platform and works well here.

@beele
Copy link
Owner Author

beele commented Aug 23, 2020

@hjdhjd I already have the option in the code (that was producing the issue)

  videoConfigCopy.source = '-re -rtsp_transport tcp -i ' + config.unifi.controller_rtsp + '/' + Unifi.pickHighestQualityAlias(cameraConfig.camera.streams);

On LTE it requests a stream of:
Starting video stream: 640x360, 30 fps, 132 kbps

On WiFi it requests a stream of:
Starting video stream: 1280x720, 30 fps, 299 kbps

The RTSP from the cameras is FHD, 15 fps, 3000kbps

@hjdhjd
Copy link

hjdhjd commented Aug 23, 2020

@beele Make only the lowest quality stream available and give it a go perhaps? Also...can you post the ffmpeg command that's attempted and any debug output? Let's give it a look and see what it tells us.

@hjdhjd
Copy link

hjdhjd commented Aug 23, 2020

@beele Also...you should try @Sunoo's recommendation of removing the -re flag and see if it helps in your environment.

@janthony6
Copy link

With beta 3, the plugin works upon reboot and then crashes shortly after. It was working fine until I turned notifications on from my wife's iphone and macbook too. Now I get this crash and snapshots & video only work after a few minutes on a reset:

TypeError: Cannot read property 'buffer' of undefined 0|homebrid | at Unifi.getSnapshotForCamera (/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/src/unifi/unifi.js:168:25) 0|homebrid | TypeError: Cannot read property 'buffer' of undefined 0|homebrid | at Unifi.getSnapshotForCamera (/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/src/unifi/unifi.js:168:25)

@beele
Copy link
Owner Author

beele commented Aug 25, 2020

@janthony6 can you try with:
sudo npm i -g [email protected] --unsafe-perm=true

@janthony6
Copy link

janthony6 commented Aug 25, 2020

@beele The snapshots still stop refreshing in beta 4. However, if I click the video, the stream works. Exiting the video gives me a refreshed snapshot for just that camera while the others may say 8 hours ago.

Example: Right now I have 2 cameras that say 8 hours ago, and 1 which I viewed 18 minutes ago, shows 18 minutes ago and has not refreshed the snapshot since.

@janthony6
Copy link

Beta 3 and 4 are not usable. After some time, all my devices become unresponsive and I have to restart homebridge. Had to roll back to 4.2 and just not have rtsp working.

@beele
Copy link
Owner Author

beele commented Aug 28, 2020

@janthony6 Ok, can you provide some logging from when it stops working. I've never had the plugin cause all other devices to report "no response". Are you using Unifi OS or legacy controller?

@JJJ When the snapshots streams stop working do you see the same "no response" on all other devices behaviour?

@janthony6
Copy link

@beele It's not an instant unresponsiveness of everything. Typically snapshots stop working first. Then if I go in there and turn off a bunch of lights, everything shuts stop responding. I'm off beta now.

@beele
Copy link
Owner Author

beele commented Aug 28, 2020

@janthony6 Can you give an indication of the timescale in which this occurs (minutes/hours/days)

Edit:
I've cleaned up some stuff and am now passing on some extra params when making a snapshot request.
Can you try with [email protected]
If the snapshot fails an error should be logged along with the full request. I suspect it might have something to do with a rate limit for API calls (I saw some checks for it in the protect 2 plugin source).

@janthony6
Copy link

@beele will give beta5 a try now. I had just installed beta4 again and it stopped responding in 1 hour.

@JJJ
Copy link
Contributor

JJJ commented Aug 28, 2020

@beele yes, I am seeing the same thing. Will try beta 5 now.

@janthony6
Copy link

@beele same issue on beta 5. after about an hour, no more snapshots come in. all the other devices work unless i interact with a few of them. Then it will all go unresponsive.

From the time that the snapshot stop working, if I hard close my home app and reopen, all my devices show unresponsive.

@beele
Copy link
Owner Author

beele commented Aug 28, 2020

Hmmm, I don't see that same behaviour. My system keeps running for days on end without issues (beta 3/4). Does your system use Unifi OS? Is there anything in the logs?
I'm leaving on holiday for a week so I would suggest rolling back to 0.4.2 for the time being. I'll look into this further when I get back.

@BadgerBadgerAndFox
Copy link

@beele i'm not seeing any of the issues reported with the beta builds. They have resolved the issues i was seeing, RTSP feeds are now working on 4.3 beta 5 no issue.
Previously the RTSP feeds were failing on 4.2.
I'm running Protect on CK2+ with beta builds enabled, i also have all three quality RTSP streams enabled for all my cameras.
Homebridge is on an RPi3 running the official image.

@beele
Copy link
Owner Author

beele commented Sep 14, 2020

@BadgerBadgerAndFox I see the same thing, I have had beta 5 running for two weeks without issue.
@janthony6 @JJJ You guys are using the plugin with Unifi OS? It might be some rate limiting going on.
Could you enable the debug and post the log output when the issue occurs?

@JJJ
Copy link
Contributor

JJJ commented Sep 14, 2020

You guys are using the plugin with Unifi OS?

Yes.

Could you enable the debug and post the log output when the issue occurs?

Will do!

@alezanott
Copy link

Hi there @beele , my config that is working with 0.4.2 on my RBPI 3 with latest HOOBS version 3.2.6/node 12.16.3.
Everything seems working good except for the camera stream. Every time I try to open a stream on the log I get this error: ffmpeg exited with code: 1 and signal: null (Error) "camera name XXX"

What could be the possible reason for this error?

@beele
Copy link
Owner Author

beele commented Sep 26, 2020

@alezanott Can you try with the latest beta:
sudo npm i -g --unsafe-perm=true [email protected]

@alezanott
Copy link

@alezanott Can you try with the latest beta:
sudo npm i -g --unsafe-perm=true [email protected]

@beele have tried but nothing changed :-(

@BadgerBadgerAndFox
Copy link

@beele looks like the issue with the snapshots stopping after a period of time is UnifiOS related, i have updated my CK2+ to the UnifiOS beta and am now seeing this issue.

UniFi Cloud Key Firmware 2.0.19
UniFi Protect 1.16.3-beta.2
Homebridge.io v1.2.3 on RPi3
[email protected]

Debugging is enabled, will try and grab them when i see the issue.

@beele beele closed this as completed Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ffmpeg Issue with ffmpeg, not the plugin itself
Projects
None yet
Development

No branches or pull requests