beele / homebridge-unifi-protect-camera-motion

Camera & Motion sensor support for Unifi Protect cameras in Homekit via Homebridge
Apache License 2.0
103 stars 12 forks source link

No snapshot / live feed - FFMPEG error 2 #35

Closed dvlamoen closed 4 years ago

dvlamoen commented 4 years ago

@beele continuing here. Thanks so much for your support.

Quick recap of issue:

I just took the following steps:

This is the log output:

Log Dump.txt

beele commented 4 years ago

The latest version (non beta, 0.3.3) should contain a lot of fixes. If this does not fix it we'll have to look at why ffmpeg is not working correctly. Do you have any special network or AV software on your mac (little snitch/charles/proxy) and is the OS firewall enabled or disabled? OS version (high siera/catalina?)

dvlamoen commented 4 years ago

Ok, rolled back the beta and installed 0.3.3.

Its a clean system install. Here is the log of things installed:

The OS firewall is off.

This is what it logs in non verbose mode:

[5/13/2020, 8:35:12 AM] Homebridge is running on port 51783. [5/13/2020, 8:35:12 AM] [Unifi protect cameras & motion sensors] Endpoint Style: Unifi Protect (Legacy) [5/13/2020, 8:35:12 AM] [Unifi protect cameras & motion sensors] WARNING: No previous session found, a new session must be created! [5/13/2020, 8:35:13 AM] [Unifi protect cameras & motion sensors] Authenticated, returning session [5/13/2020, 8:35:13 AM] [Unifi protect cameras & motion sensors] Cameras retrieved, enumerating motion sensors [5/13/2020, 8:35:13 AM] [Unifi protect cameras & motion sensors] Cameras: 2 [5/13/2020, 8:35:13 AM] [Unifi protect cameras & motion sensors] Motion checking setup done! [5/13/2020, 8:35:13 AM] [Unifi protect cameras & motion sensors] Setup done [5/13/2020, 8:35:13 AM] UVC G3 Dome is running on port 53353. [5/13/2020, 8:35:13 AM] Please add [UVC G3 Dome] manually in Home app. Setup Code: 999-99-999 [5/13/2020, 8:35:13 AM] Garden G3 Pro is running on port 53354. [5/13/2020, 8:35:13 AM] Please add [Garden G3 Pro] manually in Home app. Setup Code: 999-99-999 [5/13/2020, 8:35:52 AM] [Unifi protect cameras & motion sensors] Snapshot from UVC G3 Dome at 480:270 [5/13/2020, 8:35:52 AM] [Unifi protect cameras & motion sensors] An error occurs while making snapshot request [5/13/2020, 8:35:58 AM] [Unifi protect cameras & motion sensors] Start streaming video from UVC G3 Dome with 640:360@15fps (132kBit) [5/13/2020, 8:35:58 AM] [Unifi protect cameras & motion sensors] An error occurs while making stream request [5/13/2020, 8:35:58 AM] [Unifi protect cameras & motion sensors] ERROR: FFmpeg exited with code -2

The snapshot is viewable at: ip/snapshot.jpg

Detailed debug logging attached. Log Dump.txt

beele commented 4 years ago

It seems that node has issues calling ffmpeg (it can't find the ffmpeg command)

[5/13/2020, 8:40:53 AM] [Unifi protect cameras & motion sensors] Error: spawn ffmpeg ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19) at onErrorNT (internal/child_process.js:469:16) at processTicksAndRejections (internal/process/task_queues.js:84:21) { errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn ffmpeg', path: 'ffmpeg',

These errors come from node and not from ffmpeg itself. Could you try to install ffmpeg with homebrew and try again? If that does not work, keep ffmpeg installed (via homebrew), open the plugin config and in the videoConfig section add: "videoProcessor": "path/to/homebrew/ffmpeg/binary" (as per: https://github.com/homebridge-plugins/homebridge-camera-ffmpeg#using-another-video-processor) If that does work we can start to figure out why it's not working out of the box

hfagelnour commented 4 years ago

@beele I was getting ffmpeg exit error until i added "mapaudio": "0:0", "mapvideo": "0:1" in my config which solved the problem

only left out with the one frame per 15 seconds now, which isn't the case when i use the RTSP feed directly with the Camera FFMEG plugin. mind you the audio is fine even with the very slow video frames

could it be the need to use "-rtsp_transport tcp -re -i" somewhere in the coding. this solved the same issue with my wyze cams?

beele commented 4 years ago

@hfagelnour Ok good to hear that it's (mostly) working now.

It' already in the code:
videoConfigCopy.source = '-rtsp_transport tcp -re -i ' + this.config.unifi.controller_rtsp + '/' + Unifi.pickHighestQualityAlias(camera.streams);

hfagelnour commented 4 years ago

@hfagelnour Ok good to hear that it's (mostly) working now.

It' already in the code: videoConfigCopy.source = '-rtsp_transport tcp -re -i ' + this.config.unifi.controller_rtsp + '/' + Unifi.pickHighestQualityAlias(camera.streams);

@beele this is very weird, I am currently running 2 instances On the same home app room page for the same cameras to compare, one thru your plugin and the other thru the ffmpeg camera plugin..... beats me if the same config setting on both. Why does one update every second and the other every 15!!!!

dvlamoen commented 4 years ago

Ok, with a fresh install of FFmpeg (brew install ffmpeg) I am now producing snapshots every ~10 seconds (Yay!). Upon stream initiation I am now seeing an Error 1.

@hfagelnour I tried your "mapaudio": "0:0", "mapvideo": "0:1" unfortunately (but perhaps logically if its already in the code, didn't make a difference).

Looking through the detailed logging, it looks like its reaching FFMPEG for the stream.

Dump.txt

s1rc commented 4 years ago

It seems that node has issues calling ffmpeg (it can't find the ffmpeg command)

[5/13/2020, 8:40:53 AM] [Unifi protect cameras & motion sensors] Error: spawn ffmpeg ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19) at onErrorNT (internal/child_process.js:469:16) at processTicksAndRejections (internal/process/task_queues.js:84:21) { errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn ffmpeg', path: 'ffmpeg',

These errors come from node and not from ffmpeg itself. Could you try to install ffmpeg with homebrew and try again? If that does not work, keep ffmpeg installed (via homebrew), open the plugin config and in the videoConfig section add: "videoProcessor": "path/to/homebrew/ffmpeg/binary" (as per: https://github.com/homebridge-plugins/homebridge-camera-ffmpeg#using-another-video-processor) If that does work we can start to figure out why it's not working out of the box

@beele I'm having the same issue, fresh Ubuntu VM, Homebridge install and latest homebridge-unifi-protect-camera-motion.

I tried adding "videoProcessor": "/usr/lib/node_modules/homebridge-unifi-protect-camera-motion/node_modules/ffmpeg-for-homebridge/ffmpeg" to my videoConfig block, but still the same error.

beele commented 4 years ago

I'm looking into this on a fresh vm install

beele commented 4 years ago

@s1rc @dvlamoen The newest build (0.3.4) has some fixes (I've tested this on a fresh ubuntu server vm and had the same issue, with my newest fixes it works)

If you had the videoProcessor param in the videoConfig remove it!
The videoProcessor config field can still be used, but the location has changed, see the readme. But it shouldn't be needed anymore

s1rc commented 4 years ago

@beele 0.3.4 worked for using the pre-compiled ffmpeg, thank you!

I'll have to play around with other config, my old homebridge-camera-ffmpeg config used on FreeBSD isn't giving me video, only one frame every 5-10 seconds and lots of cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream) logged errors.

I may just get a RPi 4 and run homebridge on it only.