Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify --min-duration arguments to accept a timecode instead of frame numbers #128

Merged
merged 3 commits into from
Nov 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions scenedetect/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,11 @@ def time_command(ctx, start, duration, end):
# '[Optional] Intensity cutoff threshold to disable scene cut detection. Useful for avoiding.'
# ' scene changes triggered by flashes. Refers to frame metric delta_lum in stats file.')
@click.option(
'--min-scene-len', '-m', metavar='FRAMES',
type=click.INT, default=15, show_default=True, help=
'Minimum size/length of any scene, in number of frames.')
'--min-scene-len', '-m', metavar='TIMECODE',
type=click.STRING, default="0", help=
'Minimum size/length of any scene. TIMECODE can be specified as exact'
' number of frames, a time in seconds followed by s, or a timecode in the'
' format HH:MM:SS or HH:MM:SS.nnn')
@click.pass_context
def detect_content_command(ctx, threshold, min_scene_len): #, intensity_cutoff):
""" Perform content detection algorithm on input video(s).
Expand All @@ -428,6 +430,8 @@ def detect_content_command(ctx, threshold, min_scene_len): #, intensity_cutoff):
#if intensity_cutoff is not None:
# raise NotImplementedError()

min_scene_len = parse_timecode(ctx.obj, min_scene_len)

logging.debug('Detecting content, parameters:\n'
' threshold: %d, min-scene-len: %d',
threshold, min_scene_len)
Expand All @@ -447,9 +451,11 @@ def detect_content_command(ctx, threshold, min_scene_len): #, intensity_cutoff):
'Threshold value (integer) that the delta_rgb frame metric must exceed to trigger a new scene.'
' Refers to frame metric delta_rgb in stats file.')
@click.option(
'--min-scene-len', '-m', metavar='FRAMES',
type=click.INT, default=15, show_default=True, help=
'Minimum size/length of any scene, in number of frames.')
'--min-scene-len', '-m', metavar='TIMECODE',
type=click.STRING, default="0", help=
'Minimum size/length of any scene. TIMECODE can be specified as exact'
' number of frames, a time in seconds followed by s, or a timecode in the'
' format HH:MM:SS or HH:MM:SS.nnn')
@click.option(
'--fade-bias', '-f', metavar='PERCENT',
type=click.IntRange(-100, 100), default=0, show_default=True, help=
Expand Down Expand Up @@ -488,6 +494,8 @@ def detect_threshold_command(ctx, threshold, min_scene_len, fade_bias, add_last_
# Handle case where add_last_scene is not set and is None.
add_last_scene = True if add_last_scene else False

min_scene_len = parse_timecode(ctx.obj, min_scene_len)

# Convert min_percent and fade_bias from integer to floats (0.0-1.0 and -1.0-+1.0 respectively).
min_percent /= 100.0
fade_bias /= 100.0
Expand Down Expand Up @@ -745,4 +753,3 @@ def colors_command(ctx):
add_cli_command(scenedetect_cli, split_video_command)

add_cli_command(scenedetect_cli, export_html_command)