seydx / homebridge-camera-ui

Homebridge plugin for RTSP Cameras with HSV, motion detection support, Image Rekognition, Web UI to manage/watch streams and WebApp support
MIT License
652 stars 91 forks source link

Camera working in UI, but does not show up in HomeKit #400

Closed bjornand1 closed 2 years ago

bjornand1 commented 2 years ago

Hi, hope someone can help: I have been connecting two non-HomeKit cameras (Dafang and KingCam) through the Homebridge Camera FFmpeg plugin, and that has been working well. Wanting to get HomeKit Secure Video supported for these camera, I have now disabled that plugin and installed the homebridge-camera-ui plugin. I have used the same parameters in the config and I can now see the cameras in the camera.ui interface.

However, the cameras do not appear in HomeKit, and I see no obvious reason for this. Any ideas?

seydx commented 2 years ago

Hi, hope someone can help: I have been connecting two non-HomeKit cameras (Dafang and KingCam) through the Homebridge Camera FFmpeg plugin, and that has been working well. Wanting to get HomeKit Secure Video supported for these camera, I have now disabled that plugin and installed the homebridge-camera-ui plugin. I have used the same parameters in the config and I can now see the cameras in the camera.ui interface.

However, the cameras do not appear in HomeKit, and I see no obvious reason for this. Any ideas?

This is due to homebridge. Please change the names of the cameras and restart homebridge.

Then you can add the cameras via the Apple Home app with "+".

The PIN to add the cameras is the same as for homebridge.

bjornand1 commented 2 years ago

Thanks, @seydx, for your quick reply! I tried this, but when I try to add an accessory with the Homebridge code, I only see the bridge. I presume it should appear as a new camera?

seydx commented 2 years ago

Followed the steps above? The camera should appear in the list as a camera.

Is "undbridged" enabled in your config.json ?

bjornand1 commented 2 years ago

Tried again, but went through "Other options", then it appeared, thanks! HSV for a KingCam - unbelievable!

seydx commented 2 years ago

Tried again, but went through "Other options", then it appeared, thanks! HSV for a KingCam - unbelievable!

Great :)

bjornand1 commented 2 years ago

And Now I got my Dafang camera to work as well, sort of... It is very slow, both in the Camera UI and HomeKit. Any settings that should be tweaked to make it more responsive?

seydx commented 2 years ago

And Now I got my Dafang camera to work as well, sort of... It is very slow, both in the Camera UI and HomeKit. Any settings that should be tweaked to make it more responsive?

can you post your config.json pls

bjornand1 commented 2 years ago

Sure, for the Dafang camera it is as follows (I should also say that the KingCam is proving to be a bit flaky, it works in the Camera UI, bit now says "No response" in HomeKit despite working earlier.

{ "name": "CatCamUI", "manufacturer": "Dafang", "model": "CatCam", "motion": true, "unbridge": true, "hsv": true, "prebuffering": true, "prebufferLength": 4, "videoConfig": { "source": "-re -i rtsp://192.168.1.50:8554/unicast", "maxStreams": 2, "vcodec": "copy", "acodec": "libfdk_aac", "audio": false, "stillImageSource": "-re -i rtsp://192.168.1.50:8554/unicast", "subSource": "-re -i rtsp://192.168.1.50:8554/unicast" },

seydx commented 2 years ago

{ "name": "CatCamUI", "manufacturer": "Dafang", "model": "CatCam", "motion": true, "unbridge": true, "hsv": true, "prebuffering": true, "prebufferLength": 4, "videoConfig": { "source": "-re -i rtsp://192.168.1.50:8554/unicast", "maxStreams": 2, "vcodec": "copy", "acodec": "libfdk_aac", "audio": false, "stillImageSource": "-re -i rtsp://192.168.1.50:8554/unicast", "subSource": "-re -i rtsp://192.168.1.50:8554/unicast" }

try this config.json

{
  "name": "CatCamUI",
  "manufacturer": "Dafang",
  "model": "CatCam",
  "motion": true,
  "unbridge": true,
  "hsv": true,
  "prebuffering": true,
  "prebufferLength": 4,
  "videoConfig": {
    "source": "-i rtsp://192.168.1.50:8554/unicast",
    "subSource": "-i rtsp://192.168.1.50:8554/unicast",
    "stillImageSource": "-i rtsp://192.168.1.50:8554/unicast",
    "rtspTransport": "tcp",
    "maxStreams": 2,
    "vcodec": "copy",
    "acodec": "libfdk_aac",
    "audio": false
  }
}
bjornand1 commented 2 years ago

Thanks yet again for your help! Yes, that helped a bit, the Dafang camera now shows up in the UI, and sometimes it gets a still in HomeKit, but not video.

But now it is offline again in the UI as well, I think the problem might be the camera itself, it is quite old and very slow.

seydx commented 2 years ago

@bjornand1

try

{
  "name": "CatCamUI",
  "manufacturer": "Dafang",
  "model": "CatCam",
  "motion": true,
  "unbridge": true,
  "hsv": true,
  "prebuffering": true,
  "prebufferLength": 4,
  "videoConfig": {
    "source": "-i rtsp://192.168.1.50:8554/unicast",
    "subSource": "-i rtsp://192.168.1.50:8554/unicast",
    "stillImageSource": "-i rtsp://192.168.1.50:8554/unicast",
    "rtspTransport": "tcp",
    "maxStreams": 2,
    "vcodec": "libx264",
    "acodec": "libfdk_aac",
    "audio": false
  }
}
bjornand1 commented 2 years ago

Hmm now I get this error message:

The plugin "homebridge-camera-ui" requires Node.js version of >=14.18.2 which does not satisfy the current Node.js version of v14.16.1. You may need to upgrade your installation of Node.js - see https://git.io/JTKEF

seydx commented 2 years ago

Hmm now I get this error message:

The plugin "homebridge-camera-ui" requires Node.js version of >=14.18.2 which does not satisfy the current Node.js version of v14.16.1. You may need to upgrade your installation of Node.js - see https://git.io/JTKEF

This can be ignored and its not a new "error"

bjornand1 commented 2 years ago

OK, but I also see this:

CatCamUI: Videoanalysis timed out... killing ffmpeg session

seydx commented 2 years ago

OK, but I also see this:

CatCamUI: Videoanalysis timed out... killing ffmpeg session

can you post a screenshot from the cameras own settings pls (like fps, bitrate, resolution etc)

bjornand1 commented 2 years ago
image
bjornand1 commented 2 years ago

Does this help? Perhaps some settings here should be changed?

seydx commented 2 years ago

Does this help?

Does your stream has also a second/sub stream?

And use this settings (if possible)

Resolution: 1920x1080
FPS: 30
Keyframe Interval: 120 (Keyframe Interval = FPS x 4)
Bitrate: 2048 kbps (CBR)
bjornand1 commented 2 years ago

OK, I changed the parameters as you suggested, but now I get this error message:

CatCamUI: FFmpeg prebuffer process exited with error! (null) - [mp3float @ 0x5638ef127300] Header missing - - [tee @ 0x5638ef164dc0] dimensions not set - Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument - -

seydx commented 2 years ago

Can you enable "debug" in your config.json pls, restart HB and post me the whole log from startup till error

bjornand1 commented 2 years ago

Absolutely! I turned on debug mode, but where do I find the log?

bjornand1 commented 2 years ago

[1/24/2022, 11:26:06 AM] [CameraUI] CatCamUI: Can not determine stream codecs, probe timed out [1/24/2022, 11:26:14 AM] [CameraUI] CatCamUI: FFmpeg prebuffer process exited with error! (null) - [mp3float @ 0x564dec3f9300] Header missing - - [tee @ 0x564dec437680] dimensions not set - Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument - - [1/24/2022, 11:26:22 AM] [CameraUI] CatCamUI: FFmpeg videoanalysis process exited with error! (null) - [mp3float @ 0x55922e91a300] Header missing - - Output file #0 does not contain any stream - [1/24/2022, 11:26:22 AM] [CameraUI] CatCamUI: FFmpeg videoanalysis process exited with error! (null) - [mp3float @ 0x55922e91a300] Header missing - - Output file #0 does not contain any stream - [1/24/2022, 11:26:22 AM] [CameraUI] CatCamUI: Restart videoanalysis session.. [1/24/2022, 11:26:27 AM] [Homebridge UI] Starting terminal session [1/24/2022, 11:26:30 AM] [CameraUI] CatCamUI: FFmpeg prebuffer process exited with error! (null) - [mp3float @ 0x55cb78437300] Header missing - - [tee @ 0x55cb784756c0] dimensions not set - Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument - - [1/24/2022, 11:26:30 AM] [CameraUI] CatCamUI: Prebufferring process closed [1/24/2022, 11:26:30 AM] [CameraUI] CatCamUI: Restart prebuffer session.. [1/24/2022, 11:26:34 AM] [CameraUI] CatCamUI: Videoanalysis scheduled for restart at 4AM: 993 minutes [1/24/2022, 11:26:39 AM] [CameraUI] CatCamUI: FFmpeg videoanalysis process exited with error! (null) - [mp3float @ 0x56156dd08300] Header missing - - Output file #0 does not contain any stream - [1/24/2022, 11:26:39 AM] [CameraUI] CatCamUI: FFmpeg videoanalysis process exited with error! (null) - [mp3float @ 0x56156dd08300] Header missing - - Output file #0 does not contain any stream - [1/24/2022, 11:26:39 AM] [CameraUI] CatCamUI: Restart videoanalysis session.. [CatCamUI 9BD7] The image snapshot handler for the given accessory is slow to respond! See https://git.io/JtMGR for more info. [1/24/2022, 11:26:46 AM] [CameraUI] CatCamUI: Failed to fetch snapshot. Showing "offline" image instead. [1/24/2022, 11:26:46 AM] [CameraUI] CatCamUI: [mp3float @ 0x560e7fc09300] Header missing - - Output file #0 does not contain any stream - [1/24/2022, 11:26:50 AM] [CameraUI] CatCamUI: Videoanalysis scheduled for restart at 4AM: 993 minutes [1/24/2022, 11:26:54 AM] [CameraUI] CatCamUI: FFmpeg prebuffer process exited with error! (null) - [mp3float @ 0x559b0cc99300] Header missing - - [tee @ 0x559b0ccd7700] dimensions not set - Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument - - [1/24/2022, 11:26:54 AM] [CameraUI] CatCamUI: Prebufferring process closed [1/24/2022, 11:26:54 AM] [CameraUI] CatCamUI: Restart prebuffer session..

bjornand1 commented 2 years ago

These repeat after startup has finished

seydx commented 2 years ago

These repeat after startup has finished

can you open VLC pls and send me a screenshot from the media settings

VLC > Window > Media information

Bildschirmfoto 2022-01-24 um 11 32 37
bjornand1 commented 2 years ago

Hmm, I am on a Mac, but I do have VLC installed. Not sure how I can open camera stream there, though?

bjornand1 commented 2 years ago
Screen Shot 2022-01-24 at 11 39 20 Screen Shot 2022-01-24 at 11 40 08 Screen Shot 2022-01-24 at 11 40 16
seydx commented 2 years ago

Hmm, I am on a Mac, but I do have VLC installed. Not sure how I can open camera stream there, though?

https://user-images.githubusercontent.com/34152761/150771277-26d2886c-7a45-43e4-9126-f268f0e9fb15.mov

bjornand1 commented 2 years ago

Sorry for late reply, was in a meeting. But now I get this:

CleanShot 2022-01-24 at 13 35 27@2x

I can still see the stream in the browser window, though.

seydx commented 2 years ago

Sorry for late reply, was in a meeting. But now I get this:

CleanShot 2022-01-24 at 13 35 27@2x

I can still see the stream in the browser window, though.

Stop homebridge and try again

bjornand1 commented 2 years ago

So I restarted Homebridge, and now I don't get an error message in VLC. But there is no video showing in VLC, but I get this info:

CleanShot 2022-01-24 at 14 01 36@2x
seydx commented 2 years ago

So I restarted Homebridge, and now I don't get an error message in VLC. But there is no video showing in VLC, but I get this info:

CleanShot 2022-01-24 at 14 01 36@2x

Your stream is not a H264 stream, can you change it in your cameras own settings from mjpeg to H264? If not, you need to disable "prebuffering" in your config.json and set "vcodec" to "libx264"

bjornand1 commented 2 years ago

Hmm, there are controls in the camera settings to start/stop the H264 RTSP and MJPEG RTSP streams, and I have tried starting the former and stopping the latter. That does not seem to help, so I turned off prebuffering and changed the vcodec setting, but with no success.

bjornand1 commented 2 years ago

I am wondering if an issue could be safety certificate? Trying to access the camera though Chrome/Firefox, I partly get a safety warning and partly get asked a username/password (which are not required in Safari, where I can access it straight away)?

seydx commented 2 years ago

@bjornand1

if you disable prebuffering AND videoanalysis and set vcodec to „libx264“ there are still issues?

can you send me the log pls with prebuffering/videoanalysis disabled and vcodec = libx264

bjornand1 commented 2 years ago

Sure, this message keeps repeating:

[1/24/2022, 4:03:50 PM] [CameraUI] CatCamUI: FFmpeg videoanalysis process exited with error! (null) - [tcp @ 0x560d4fd5f7c0] Connection to tcp://192.168.1.50:8554?timeout=0 failed: Connection refused - rtsp://192.168.1.50:8554/unicast: Connection refused - [1/24/2022, 4:03:50 PM] [CameraUI] CatCamUI: FFmpeg videoanalysis process exited with error! (null) - [tcp @ 0x560d4fd5f7c0] Connection to tcp://192.168.1.50:8554?timeout=0 failed: Connection refused - rtsp://192.168.1.50:8554/unicast: Connection refused -

seydx commented 2 years ago

Sure, this message keeps repeating:

[1/24/2022, 4:03:50 PM] [CameraUI] CatCamUI: FFmpeg videoanalysis process exited with error! (null) - [tcp @ 0x560d4fd5f7c0] Connection to tcp://192.168.1.50:8554?timeout=0 failed: Connection refused - rtsp://192.168.1.50:8554/unicast: Connection refused - [1/24/2022, 4:03:50 PM] [CameraUI] CatCamUI: FFmpeg videoanalysis process exited with error! (null) - [tcp @ 0x560d4fd5f7c0] Connection to tcp://192.168.1.50:8554?timeout=0 failed: Connection refused - rtsp://192.168.1.50:8554/unicast: Connection refused -

This has something to do with your camera or the camera source. FFmpeg can't connect to the camera source and that's why the errors occur.

bjornand1 commented 2 years ago

Yes, I was starting to think so. Do you have any ideas how I could change things at the camera to make it work? It used to work with the Homebridge Camera FFmpeg plugin, before I started changing things to make it work under the Homebridge Camera Ui plugin?

bjornand1 commented 2 years ago

I rebooted the camera and now I get a different error message:

CatCamUI: FFmpeg videoanalysis process exited with error! (null) - [mp3float @ 0x558821a46300] Header missing - - Output file #0 does not contain any stream -

seydx commented 2 years ago
image

Lets try something else, can you put a "video username" & "video password" and try the stream within VLC again with following source pls

Example video username: admin video password: admin

VLC source: rtsp://admin:admin@192.168.1.50:8554/unicast

bjornand1 commented 2 years ago

Thanks, I will try that in the morning!

bjornand1 commented 2 years ago

What do you know, that works, not the stream plays in VLC!

bjornand1 commented 2 years ago

But now I see that this only works if I set the resolution to 1280X720, increasing it the stream fails. Here are the media information data:

CleanShot 2022-01-25 at 07 38 16@2x

But where must I add the username and password to allow access to the camera?

seydx commented 2 years ago

But now I see that this only works if I set the resolution to 1280X720, increasing it the stream fails. Here are the media information data:

CleanShot 2022-01-25 at 07 38 16@2x

But where must I add the username and password to allow access to the camera?

Just change the video source to

rtsp://admin:admin@192.168.1.50:8554/unicast

(Assuming username is admin and pw is also admin)

bjornand1 commented 2 years ago

Ah, easy, but I still get this error:

[1/25/2022, 7:59:45 AM] [CameraUI] CatCamTest: Videoanalysis timed out... killing ffmpeg session

bjornand1 commented 2 years ago

Followed by:

[1/25/2022, 8:00:40 AM] [CameraUI] CatCamTest: Videoanalysis timed out... killing ffmpeg session [1/25/2022, 8:00:40 AM] [CameraUI] CatCamTest: FFmpeg videoanalysis process exited with error! (SIGKILL) - [mp3float @ 0x562ef985b380] Header missing - [1/25/2022, 8:00:40 AM] [CameraUI] CatCamTest: FFmpeg videoanalysis process exited with error! (SIGKILL) - [mp3float @ 0x562ef985b380] Header missing -

bjornand1 commented 2 years ago

OK, something happening. In the UI dashboard, I now see at least a still image from the camera! It also detects motion, but it times out trying to stream, and it shows as No response in the Home app.

bjornand1 commented 2 years ago

And furthermore, now and then I can actually get the stream to work in the UI dashboard! But it seems a bit unstable, it can easily be interrupted. In HomeKit, however, there is always the No response message.

Perhaps some settings could be reduced in order to not put such a strain on the clearly limited capacity of this camera?

bjornand1 commented 2 years ago

Rebooting the camera again, it seems I can get it to work now and then. It seems the problem is the camera's performance itself.

seydx commented 2 years ago

Rebooting the camera again, it seems I can get it to work now and then. It seems the problem is the camera's performance itself.

Yeah i think so too, you can disable prebuffering and videoanalysis to avoid additional load