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]
- process_frame(timecode, frame_img)¶
Process the next frame. frame_num 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]
- stats_manager_required()¶
Stats Manager Required: Prototype indicating if detector requires stats.
- Returns:
True if a StatsManager is required for the detector, False otherwise.
- Return type:
bool
- property event_buffer_length: int¶
The amount of frames a given event can be buffered for, in time. Represents maximum amount any event can be behind frame_number in the result of
process_frame()
.
- stats_manager: StatsManager | None = None¶
Optional
StatsManager
to use for caching frame metrics to and from.