Important FIX: Local recording and Homekit Security Video recording. Cut recordings or no recordings.
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);
      }
    });

```

<img width="1145" alt="Zrzut ekranu 2023-10-22 o 16 00 20" src="https://github.com/seydx/homebridge-camera-ui/assets/82271669/1b8eee5c-1245-402d-bdcf-bc2881790b63">

6. Restart Homebridge. 



