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

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

Open
mkz212 opened this issue Oct 23, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@mkz212
Copy link
Contributor

mkz212 commented Oct 23, 2023

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:

  • Video analysis detects movement
  • Recording is launched and the motion detection process is blocked for 10 seconds
  • The local recording process is completed and the video is created and if there is no next move after the 10 seconds HSV recording ends.
  • If there is another move then: another local recording is created and the HSV recording is extended.

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
Copy link
Contributor Author

mkz212 commented Oct 24, 2023

What else would I do?

  • Set motion detection for 10 seconds permanently (hardcoded) - for HSV recording, local recording and for the motion sensor.
  • Remove from the plugin settings in homebridge: Motion Timeout and Interface Recording Timer,
  • Remove from the Camera UI : Recording time, and from Videoanalisys: Dwell Time and Reset Motion after.
  • Separation of settings: local recording from HKS (so that each can be turned on / off independently).

@mkz212
Copy link
Contributor Author

mkz212 commented Nov 10, 2023

@seydx Can You take a look, please?

@seydx
Copy link
Owner

seydx commented Nov 10, 2023

@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 ([email protected])

Edit:

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

-seydx

@mkz212
Copy link
Contributor Author

mkz212 commented Nov 10, 2023

@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
Copy link

@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
Copy link

@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
Copy link
Contributor Author

mkz212 commented Dec 23, 2023

@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
Copy link

@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
Copy link
Contributor Author

mkz212 commented Jul 29, 2024

🎉 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: seydx/camera.ui#448 .

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants