Detector Interface¶
scenedetect.detector Module
This module contains the SceneDetector interface, from which all scene detectors in
scenedetect.detectors module are derived from.
The SceneDetector class represents the interface which detection algorithms are expected to provide in order to be compatible with PySceneDetect.
Warning
This API is still unstable, and changes and design improvements are planned for the v1.0 release. Instead of just timecodes, detection algorithms will also provide a specific type of event (in, out, cut, etc…).
- class scenedetect.detector.FlashFilter(mode, length)¶
Filters fast-cuts to enforce minimum scene length.
- Parameters:
mode (Mode) – The mode to use when enforcing length.
length (int) – Number of frames to use when filtering cuts.
- class Mode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Which mode the filter should use for enforcing minimum scene length.
- MERGE = 0¶
Merge consecutive cuts shorter than filter length.
- SUPPRESS = 1¶
Suppress consecutive cuts until the filter length has passed.
- class scenedetect.detector.SceneDetector¶
Base class to inherit from when implementing a scene detection algorithm.
This API is not yet stable and subject to change.
- get_metrics()¶
Returns a list of all metric names/keys used by this detector.
- Returns:
List of strings of frame metric key names that will be used by the detector when a StatsManager is passed to process_frame.
- Return type:
List[str]
- post_process(timecode)¶
Called after there are no more frames to process.
- Parameters:
timecode (int) – The last position in the video which was read.
- Returns:
List of timecodes where scene cuts have been detected, if any.
- Return type:
List[FrameTimecode]
- abstract process_frame(timecode, frame_img)¶
Process the next frame. timecode is assumed to be sequential.
- Parameters:
timecode (FrameTimecode) – Timecode corresponding to the frame being processed.
frame_img (ndarray) – Video frame as a 24-bit BGR image.
- Returns:
List of timecodes where scene cuts have been detected, if any.
- Return type:
List[FrameTimecode]
- property event_buffer_length: int¶
The amount of frames a given event can be buffered for, in time. This must be set to the amount of frames a detector might emit an event in the past.
- property stats_manager: StatsManager | None¶
Optional
StatsManagerto use for storing frame metrics. When this detector is added to a parentSceneManager, then this is set to the sameStatsManagerof the parent - but only if it has one itself.