Skip to content

Commit

Permalink
[cli] Fix scene list always being printed
Browse files Browse the repository at this point in the history
Regressed in 46e170e
  • Loading branch information
Breakthrough committed Feb 17, 2024
1 parent 2dafc32 commit 65ce4a6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions scenedetect/_cli/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ def __init__(self):
self.list_scenes_quiet: bool = None # list-scenes -q/--quiet
self.scene_list_dir: str = None # list-scenes -o/--output
self.scene_list_name_format: str = None # list-scenes -f/--filename
self.scene_list_output: bool = None # list-scenes -n/--no-output
self.scene_list_output: bool = None # list-scenes -n/--no-output-file
self.skip_cuts: bool = None # list-scenes -s/--skip-cuts
self.display_cuts: bool = False # [list-scenes] display-cuts
self.display_cuts: bool = True # [list-scenes] display-cuts
self.display_scenes: bool = True # [list-scenes] display-scenes
self.cut_format: TimecodeFormat = TimecodeFormat.TIMECODE # [list-scenes] cut-format

Expand Down
34 changes: 20 additions & 14 deletions scenedetect/_cli/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ def _save_stats(context: CliContext) -> None:
def _list_scenes(context: CliContext, scene_list: List[Tuple[FrameTimecode, FrameTimecode]],
cut_list: List[FrameTimecode]) -> None:
"""Handles the `list-scenes` command."""
if not context.list_scenes:
return
# Write scene list CSV to if required.
if context.scene_list_output:
scene_list_filename = Template(
context.scene_list_name_format).safe_substitute(VIDEO_NAME=context.video_stream.name)
Expand All @@ -154,24 +157,27 @@ def _list_scenes(context: CliContext, scene_list: List[Tuple[FrameTimecode, Fram
scene_list=scene_list,
include_cut_list=not context.skip_cuts,
cut_list=cut_list)
if not context.list_scenes_quiet:
if context.display_scenes:
logger.info(
"""Scene List:
# Suppress output if requested.
if context.list_scenes_quiet:
return
# Print scene list.
if context.display_scenes:
logger.info(
"""Scene List:
-----------------------------------------------------------------------
| Scene # | Start Frame | Start Time | End Frame | End Time |
| Scene # | Start Frame | Start Time | End Frame | End Time |
-----------------------------------------------------------------------
%s
-----------------------------------------------------------------------""", '\n'.join([
" | %5d | %11d | %s | %11d | %s |" %
(i + 1, start_time.get_frames() + 1, start_time.get_timecode(),
end_time.get_frames(), end_time.get_timecode())
for i, (start_time, end_time) in enumerate(scene_list)
]))

if cut_list and context.display_cuts:
logger.info("Comma-separated timecode list:\n %s",
",".join([context.cut_format.format(cut) for cut in cut_list]))
" | %5d | %11d | %s | %11d | %s |" %
(i + 1, start_time.get_frames() + 1, start_time.get_timecode(),
end_time.get_frames(), end_time.get_timecode())
for i, (start_time, end_time) in enumerate(scene_list)
]))
# Print cut list.
if cut_list and context.display_cuts:
logger.info("Comma-separated timecode list:\n %s",
",".join([context.cut_format.format(cut) for cut in cut_list]))


def _save_images(
Expand Down
4 changes: 2 additions & 2 deletions website/pages/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ This release focuses on bugfixes and quality of life improvements. This has help

- [bugfix] Fix `AttributeError` thrown when accessing `aspect_ratio` on certain videos using `VideoStreamAv` [#355](https://github.com/Breakthrough/PySceneDetect/issues/355)
- [bugfix] Fix circular imports due to partially initialized module for some development environments [#350](https://github.com/Breakthrough/PySceneDetect/issues/350)
- [feature] Add `output_dir` argument to split_video_* functions to customize output directory [#298](https://github.com/Breakthrough/PySceneDetect/issues/298)
- [feature] Add `formatter` argument to split_video_ffmpeg to customize filename generation [#359](https://github.com/
- [feature] Add `output_dir` argument to `split_video_ffmpeg` and `split_video_mkvmerge` functions to set output directory [#298](https://github.com/Breakthrough/PySceneDetect/issues/298)
- [feature] Add `formatter` argument to `split_video_ffmpeg` to allow formatting filenames via callback [#359](https://github.com/
Breakthrough/PySceneDetect/issues/359)
- [improvement] `scenedetect.stats_manager` module improvements:
- The `StatsManager.register_metrics()` method no longer throws any exceptions
Expand Down

0 comments on commit 65ce4a6

Please sign in to comment.