Skip to content

Commit

Permalink
[docs] Add missing docs for FlashFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
Breakthrough committed Dec 31, 2024
1 parent 9760c0a commit 09f2b64
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion scenedetect/scene_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def is_processing_required(self, frame_num: int) -> bool:
True otherwise (i.e. the frame_img passed to process_frame is required
to be passed to process_frame for the given frame_num).
:meta private:
"""
metric_keys = self.get_metrics()
return not metric_keys or not (
Expand Down Expand Up @@ -132,6 +134,8 @@ class SparseSceneDetector(SceneDetector):
as opposed to just a single cut.
An example of a SparseSceneDetector is the MotionDetector.
:meta private:
"""

def process_frame(
Expand Down Expand Up @@ -160,13 +164,22 @@ def post_process(self, frame_num: int) -> ty.List[ty.Tuple[int, int]]:


class FlashFilter:
"""Filters fast-cuts to enforce minimum scene length."""

class Mode(Enum):
"""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."""

def __init__(self, mode: Mode, length: int):
"""
Arguments:
mode: The mode to use when enforcing `length`.
length: Number of frames to use when filtering cuts.
"""
self._mode = mode
self._filter_length = length # Number of frames to use for activating the filter.
self._last_above = None # Last frame above threshold.
Expand All @@ -176,7 +189,6 @@ def __init__(self, mode: Mode, length: int):

@property
def max_behind(self) -> int:
"""Maximum number of frames a filtered cut can be behind the current frame."""
return 0 if self._mode == FlashFilter.Mode.SUPPRESS else self._filter_length

def filter(self, frame_num: int, above_threshold: bool) -> ty.List[int]:
Expand Down
2 changes: 1 addition & 1 deletion scenedetect/scene_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def get_scenes_from_cuts(
was processed (used to generate last scene's end time).
start_frame: The start frame or FrameTimecode of the cut list. Used to generate the first
scene's start time.
base_timecode: [DEPRECATED] DO NOT USE. For backwards compatibility only.
base_timecode: [DEPRECATED] DO NOT USE. For backwards compatibility only.
Returns:
List of tuples in the form (start_time, end_time), where both start_time and
end_time are FrameTimecode objects representing the exact time/frame where each
Expand Down

0 comments on commit 09f2b64

Please sign in to comment.