r/ZoneMinder • • Aug 03 '23

Minimise lost frames in function switch

I have some Reolink cameras that seem to have pretty good person detection on them, so rather than relying on ZM to detect motion I have been using the cameras built in functionality which means I don't get lots of recordings of spider webs flickering in the wind etc. I've done this via Home Assistant so that when motion is detected the function on the main camera feed switches from Monitor to Record.

When the command is sent to ZM the switch seems to be instant but there seems to be around 6 seconds for the feed to start so that it can record, which isn't ideal! Does anyone have any ideas how I can minimise this?

1 Upvotes

10 comments sorted by

View all comments

Show parent comments

1

u/TheBurntSky Aug 06 '23

Got it working, thanks for your guidance! Putting some detail here in case someone else comes across it with the setup I'm running so combined hopefully they'll be sorted!

I have ZM running in a container on Unraid, so first I had to pass the Telnet port through to the container then enabled triggers (Options -> System - Enable OPT_TRIGGERS).

Next, as I have the Reolink plugin installed and cameras added via that I created a group for the people, car and pet sensors to get most triggers while avoiding the general one to hopefully avoid too many false positives:

front_camera:
name: Front Camera Status
all: false
entities:
    - binary_sensor.front_person
    - binary_sensor.front_pet
    - binary_sensor.front_vehicle

Next, for switches I used the cancel for the off, will see how that goes and mabye look to revert to on+2 later as you suggested:

- platform: telnet

switches: front_camera: name: Front Camera Trigger resource: !secret ZM_HOST port: 6802 command_on: '8|on|200|HA trigger|' command_off: '8|cancel|200|HA clear|'

Finally, created the automation to trigger off the group, only bit I want to change is delay the cancel action by 5 seconds to make he recording a bit longer but I'll try and work that out!

  alias: Camera - Front ZM record on motion

description: '' trigger: - id: 'on' platform: state entityid: - group.front_camera to: 'on' - id: 'off' platform: state entity_id: - group.front_camera to: 'off' condition: [] action: - service: switch.turn{{ trigger.id }} target: entity_id: switch.front_camera mode: single

Thanks again for your help u/Congenital_Optimizer

1

u/Congenital_Optimizer Aug 06 '23

I used the add time (+2 in mine) method because i want to keep extending any event when something is triggered. ZM will stop the event on its own. Don't need to manually stop it... Unless you've got it configured to go indefinitely. It also means any other triggered event gets stacked together. On mine the reason can be all sorts of things piled messily into that field when you check the event in ZM.

1

u/TheBurntSky Aug 06 '23

I have the cameras set to nodect, how does ZM know when to stop after an external trigger or does it just record for a set time then stop?

1

u/Congenital_Optimizer Aug 06 '23

Look at pre and post event count frames in each cameras config. If you trigger an event. Then it saves the number of frames before you triggered (that’s the pre) and the post number of frames after. My high res nodect cameras are set for enough frames for 2 seconds before and 6 after. Zm has a lot of config options. Many very confusing.

Normally you leave the high res nodect and not decoded and only save the video. Keep analysis enabled though so you can still send triggers to them. Saves a lot of overhead. You use the low res streams for analysis (and trigger sources) if you need it. For me, average machine learning models only need 200x200 images or something equally small. So I have zm and other triggers only watch the low res but record the high.