Skip to content

Commit

Permalink
[export-html] Invoke save-images automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Breakthrough committed Oct 19, 2024
1 parent c03a423 commit 08f9dcb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
42 changes: 22 additions & 20 deletions scenedetect/_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,10 @@ def load_scenes_command(
)
@click.option(
"--no-images",
"-n",
is_flag=True,
flag_value=True,
help="Export the scene list including or excluding the saved images.%s"
help="Do not include images with the result.%s"
% (USER_CONFIG.get_help_string("export-html", "no-images")),
)
@click.option(
Expand Down Expand Up @@ -997,21 +998,22 @@ def export_html_command(
image_height: ty.Optional[int],
show: bool,
):
"""Export scene list to HTML file. Requires save-images unless --no-images is specified."""
"""Export scene list to HTML file.
To customize image generation, specify the `save-images` command before `export-html`. This command always uses the result of the preceeding `save-images` command, or runs it with the default config values unless `--no-images` is set.
"""
ctx = ctx.obj
assert isinstance(ctx, CliContext)

no_images = no_images or ctx.config.get_value("export-html", "no-images")
if not ctx.save_images and not no_images:
raise click.BadArgumentUsage(
"export-html requires that save-images precedes it or --no-images is specified."
)
export_html_args = {
"html_name_format": ctx.config.get_value("export-html", "filename", filename),
"image_width": ctx.config.get_value("export-html", "image-width", image_width),
"image_height": ctx.config.get_value("export-html", "image-height", image_height),
"show": ctx.config.get_value("export-html", "show", show),
}
no_images = no_images or ctx.config.get_value("export-html", "no-images")
if not ctx.save_images and not no_images:
# Ensure we generate some images for the HTML unless --no-images was specified.
save_images_command.callback()
ctx.add_command(cli_commands.export_html, export_html_args)


Expand Down Expand Up @@ -1366,18 +1368,18 @@ def split_video_command(
@click.pass_context
def save_images_command(
ctx: click.Context,
output: ty.Optional[ty.AnyStr],
filename: ty.Optional[ty.AnyStr],
num_images: ty.Optional[int],
jpeg: bool,
webp: bool,
quality: ty.Optional[int],
png: bool,
compression: ty.Optional[int],
frame_margin: ty.Optional[int],
scale: ty.Optional[float],
height: ty.Optional[int],
width: ty.Optional[int],
output: ty.Optional[ty.AnyStr] = None,
filename: ty.Optional[ty.AnyStr] = None,
num_images: ty.Optional[int] = None,
jpeg: bool = False,
webp: bool = False,
quality: ty.Optional[int] = None,
png: bool = False,
compression: ty.Optional[int] = None,
frame_margin: ty.Optional[int] = None,
scale: ty.Optional[float] = None,
height: ty.Optional[int] = None,
width: ty.Optional[int] = None,
):
"""Create images for each detected scene.
Expand Down
3 changes: 3 additions & 0 deletions website/pages/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,6 @@ Development
- [bugfix] Fix `ContentDetector` crash when using callbacks [#416](https://github.com/Breakthrough/PySceneDetect/issues/416) [#420](https://github.com/Breakthrough/PySceneDetect/issues/420)
- [general] Timecodes of the form `MM:SS[.nnn]` are now processed correctly [#443](https://github.com/Breakthrough/PySceneDetect/issues/443)
- [api] The `save_to_csv` function now works correctly with paths from the `pathlib` module
- [feature] Add new `--show` flag to `export-html` command to launch browser after processing (#442)
- [improvement] The `export-html` command now implicitly invokes `save-images` with default parameters
- The output of the `export-html` command will always use the result of the `save-images` command that *precedes* it

0 comments on commit 08f9dcb

Please sign in to comment.