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
647 stars 92 forks source link

Important FIX: Local recording and Homekit Security Video recording. Cut recordings or no recordings. #855

Open mkz212 opened 1 year ago

mkz212 commented 1 year ago

Recording works here like this: when motion is detected (e.g. by Videoanalisys), it gives a signal for local or HSV recording. My corrections will make you to one and the other. But... The problem arises further. Local recording works like this: motion detection starts the recording for a predetermined time. On the other hand, HSV recordings work differently: motion detection starts the recording and each movement within couple of seconds extends the recording. While you can record both locally and HSV, the detection process itself (Videoanalisys) is one. If it is busy with one process, it will not work in the other. Hence the gaps in the recordings. The simplest and probably good solution is: set local recordings for 10 seconds and correct the code as below.

How it will work then:

SOLUTION:

  1. Set recording time to 10 seconds (in Camera UI Interface / settings / Recordings).

  2. For better results enable prebuffering 4 sec.

  3. in /homebridge-camera-ui/node_modules/camera.ui/src/controller/event/event.controller.js , replace: if (!EventController.#movementHandler[cameraName] || fileBuffer) to: if (true)

  4. in: /node_modules/homebridge-camera-ui/node_modules/camera.ui/src/controller/motion/motion.controller.js , replace: if (camera.recordOnMovement) to: if (camera)

  5. in: /homebridge-camera-ui/node_modules/camera.ui/src/controller/camera/services/videoanalysis.service.js , find a part of code similar to this one and change to this one:

// eslint-disable-next-line no-unused-vars
    pamDiff.on('diff', async (data) => {
      if (!this.finishLaunching) {
        return;
      }

      const recordingSettings = await Database.interfaceDB.chain
            .get('settings')
            .get('recordings')
            .cloneDeep()
            .value();

      const recTimer = recordingSettings.timer || 10;

      const event = data.trigger.map((data) => {
        return {
          zone: data.name,
          percent: data.percent,
          sensitivity: Math.round(100 - data.percent) + 1,
          recTimer: recTimer,
        };
      });

      if (!this.motionEventTimeout) {
        this.#triggerMotion(true, event);

        this.motionEventTimeout = setTimeout(() => {
          this.#triggerMotion(false, {
            time: new Date(),
            event: `forceClose`,
          });
        }, recTimer * 1000);
      }
    });
Zrzut ekranu 2023-10-22 o 16 00 20
  1. Restart Homebridge.
mkz212 commented 1 year ago

What else would I do?

mkz212 commented 12 months ago

@seydx Can You take a look, please?

seydx commented 12 months ago

@seydx Can You take a look, please?

Hey m8, it's been a long time since I've spoken here. I'm sorry. I became a father and unfortunately didn't have any more time :D

But here is the good news:

I am already developing a new version of camera.ui. Backend has been completely rewritten in Typescript. Changes have also been made to the UI itself (Vue 3). At the same time, an Electron app is being programmed for Linux, Mac and Windows that can work completely independently.

Later also for iOS/Android.

I can't say much about the future of homebridge-camera-ui yet, maybe camera.ui will get native HomeKit support for all integrated cameras. But maybe I will implement this via homebridge-camera-ui.

The bad news:

Unfortunately, it will be a while before I release a stable version. Camera.ui should offer a complete NVR solution including 24/7 recording, timeline, events, object and motion detection. Support for many different cameras (incl. Ring cameras) etc.

I will always try to keep you up to date. Many thanks for your support so far!

If you have any questions you can always reach me via Discord (see homebridge discord) or email (dev@seydx.com)

Edit:

If you have any wishes or ideas for the new version, feel free to write me!

-seydx

mkz212 commented 12 months ago

@seydx Thank you very much for your reply. At the beginning I will praise Camera UI - a lot of great super work. I am looking forward to hearing about the new version.

But I know that currently in the current version many people have a problem in recording (local and HSV). I searched for a solution for a long time and found it. I tested it and it works! And even works sensationally! The whole problem is that currently in Camera UI the length of recording is determined in advance, and in HSV dynamically. I described everything at the beginning of the entry. Please take a look at my PR (in camera ui, not here in homebridge camera ui) or just see code i post here above. The code is not great but it works flawlessly! Until the release of a new plugin, maybe you would include such a fix? If you release at least a beta with this amendment, I will be happy to help with the tests.

MattGeale commented 11 months ago

@seydx I know you're extremely busy, but what is your approx timeline for the new version of Camera-UI? I'm running into the hksv issue we're referencing above with a Raspi-V3 cam being sent in via an rtsp stream and doesn't appear to be recording :/

jondgrant commented 10 months ago

@mks212 How do I implement your solution steps #3-5 within Homebridge? I cannot figure out how to get to the locations you suggest in order to edit the code.

mkz212 commented 10 months ago

@jondgrant

I talked with the author of the plugin - @seydx and he promised to release the correction. But I don't know when.

When it comes to editing files, you need to activate ssh and connect via ftp. How to do it you will find out on the Internet.

brianhackel commented 9 months ago

@seydx Thank you very much for your reply. At the beginning I will praise Camera UI - a lot of great super work. I am looking forward to hearing about the new version.

But I know that currently in the current version many people have a problem in recording (local and HSV). I searched for a solution for a long time and found it. I tested it and it works! And even works sensationally! The whole problem is that currently in Camera UI the length of recording is determined in advance, and in HSV dynamically. I described everything at the beginning of the entry. Please take a look at my PR (in camera ui, not here in homebridge camera ui) or just see code i post here above. The code is not great but it works flawlessly! Until the release of a new plugin, maybe you would include such a fix? If you release at least a beta with this amendment, I will be happy to help with the tests.

is this the PR?

mkz212 commented 3 months ago

🎉 A new version of camera.ui

A new version of camera.ui is currently under active development. An initial alpha/beta release and previews are coming soon. Stay tuned for exciting updates: https://github.com/seydx/camera.ui/issues/448 .

This version will no longer be developed / fixed. The new version contains many novelties and fixes (most important is for HKSV recording).