DVR-Scan icon indicating copy to clipboard operation
DVR-Scan copied to clipboard

Add option for setting a window for expanded events to be considered for merging (e.g. "merge-window")

Open Draxter14 opened this issue 1 year ago • 1 comments

Following the #192 discussion on events not joining and too many events generated, especially with bug from #72 , another option for controlling the number of output motion events (videos) would be beneficial. The solution has already been proposed in #68 by Breakthrough:

[1] With recent changes to PySceneDetect (specifically adding a merge strategy), it should be possible to further specify another window where, after the events have been expanded, they can also be considered for merging. For example, if there are two events detected at frames 10-20 and 50-60, and we set -tb=10 and -tp=15, the resulting events will be 0-35 and 40-75. You could then set another parameter to merge any motion events that are N frames close, e.g. --merge=5, that way you can also set an effective distance between events for them to be considered the same (rather than just relying on them overlapping). That way you can also ensure that for a given clip, you know there was no more motion detected for at least some time after the end of the event (otherwise they would be merged and the clip would have been longer).

Please add the functionality described.

Note: Probably the bug mentioned in #72 about --time-before-event not influencing the merging behavior should have bigger priority and if resolved would alleviate most of the initial issue. But a new "merge-window" parameter (this request) would add further options for controlling the output more precisely.

Draxter14 avatar Jan 10 '25 18:01 Draxter14

I've given this some more thought, and think that the following is probably best:

  • Add a new option which controls how close two frames with motion can be before they are split into separate events
  • Make it such that neither time before or time after event applies to events anymore. These options will only affect the exported clips, and the final list of motion events.

There's so many edge cases with multiple parameters controlling merging behaviour - using a single new parameter to control that seems ideal.

Breakthrough avatar Feb 05 '25 00:02 Breakthrough