Frigate, recordings contain unnecessary video (pre_capture/post_capture not working)

Hey.

Ive configured frigate to record events, but the recordings contain mostly video without movement, as an example my latest video is 47 seconds;
first 15 seconds is without movement, then 12 seconds of movement followed by 20 seconds without movement.
So that video is 35 seconds/~75% useless data.

Ideally the video should only contain the 12 seconds of movement/active event, but 5s before & 5s after would be good.

I have 0 seconds in “pre_capture” and 5 seconds in “post_capture”, but that does not seem to make any difference.

How can i optimize this?

record:
      enabled: True
      retain:
        days: 5
        mode: active_objects
      events:
        pre_capture: 0
        post_capture: 5

Try adjusting what its seeing as motion
This may come at expense of missing object/event.

If it is only certain object types having this issue you could adjust “threshold” for those object types possibly

Since you say records are too long after event i would think “post_capture” should be 0.

motion:
  # Optional: The threshold passed to cv2.threshold to determine if a pixel is different enough to be counted as motion. (default: shown below)
  # Increasing this value will make motion detection less sensitive and decreasing it will make motion detection more sensitive.
  # The value should be between 1 and 255.
  threshold: 25
  # Optional: Minimum size in pixels in the resized motion image that counts as motion (default: 30)
  # Increasing this value will prevent smaller areas of motion from being detected. Decreasing will
  # make motion detection more sensitive to smaller moving objects.
  # As a rule of thumb:
  #  - 15 - high sensitivity
  #  - 30 - medium sensitivity
  #  - 50 - low sensitivity
  contour_area: 30
  # Optional: Alpha value passed to cv2.accumulateWeighted when averaging the motion delta across multiple frames (default: shown below)
  # Higher values mean the current frame impacts the delta a lot, and a single raindrop may register as motion.
  # Too low and a fast moving person wont be detected as motion.
  delta_alpha: 0.2
  # Optional: Alpha value passed to cv2.accumulateWeighted when averaging frames to determine the background (default: shown below)
  # Higher values mean the current frame impacts the average a lot, and a new object will be averaged into the background faster.
  # Low values will cause things like moving shadows to be detected as motion for longer.
  # https://www.geeksforgeeks.org/background-subtraction-in-an-image-using-concept-of-running-average/
  frame_alpha: 0.2
  # Optional: Height of the resized motion frame  (default: 50)
  # This operates as an efficient blur alternative. Higher values will result in more granular motion detection at the expense
  # of higher CPU usage. Lower values result in less CPU, but small changes may not register as motion.
  frame_height: 50
  # Optional: motion mask
  # NOTE: see docs for more detailed info on creating masks

Recordings segments are 10 seconds long so the recording is going to be in a multiple of 10 seconds (with some level of accuracy depending on how consistent your cameras iframe interval is)

Its all object types that i have chosen, adjusting the thresholds might reduce the empty video by a couple of seconds, not 15-20s, it feels like the problem is not motion sensitivity.
Yeah of course the post_capture should also be zero, but that would only reduce the trailing 20s of empty video to 15s, not solving the main issue.

The recording in my example is 47s, not in a multiple of 10s, most of my recordings are odd multiples.

Like I said, it depends on your camera. Some cameras do not provide consistent key frames

detection starts with motion. when motion detected frigate looks for object. if object detected, I believe, this is registered as event. This is where the pre and post capture come in. I presume the event stops after no more motion detected.

If motion is sensitive then it will likely run longer and start earlier on detected events. This could result in more false positives but since an object has to be present this is not necessarily true.

I suggest adjusting the motion sensitivity and see what that does.

No, the event keeps going until the object is no longer visible in the frame.