MCPcopy Create free account
hub / github.com/Breakthrough/PySceneDetect / list_scenes

Function list_scenes

scenedetect/_cli/commands.py:104–166  ·  view source on GitHub ↗

Handles the `list-scenes` command.

(
    context: CliContext,
    scenes: SceneList,
    cuts: CutList,
    no_output_file: bool,
    filename: str,
    output: str,
    skip_cuts: bool,
    quiet: bool,
    display_scenes: bool,
    display_cuts: bool,
    cut_format: str,
    col_separator: str,
    row_separator: str,
)

Source from the content-addressed store, hash-verified

102
103
104def list_scenes(
105 context: CliContext,
106 scenes: SceneList,
107 cuts: CutList,
108 no_output_file: bool,
109 filename: str,
110 output: str,
111 skip_cuts: bool,
112 quiet: bool,
113 display_scenes: bool,
114 display_cuts: bool,
115 cut_format: str,
116 col_separator: str,
117 row_separator: str,
118):
119 """Handles the `list-scenes` command."""
120 assert context.video_stream is not None
121 # Write scene list CSV to if required.
122 if not no_output_file:
123 scene_list_filename = Template(filename).safe_substitute(
124 VIDEO_NAME=context.video_stream.name
125 )
126 if not scene_list_filename.lower().endswith(".csv"):
127 scene_list_filename += ".csv"
128 scene_list_path = get_and_create_path(
129 scene_list_filename,
130 output,
131 )
132 logger.info("Writing scene list to CSV file:\n %s", scene_list_path)
133 with open(scene_list_path, "w") as scene_list_file:
134 write_scene_list(
135 output_csv_file=scene_list_file,
136 scene_list=scenes,
137 include_cut_list=not skip_cuts,
138 cut_list=cuts,
139 col_separator=col_separator,
140 row_separator=row_separator,
141 )
142 # Suppress output if requested.
143 if quiet:
144 return
145 # Print scene list.
146 if display_scenes:
147 logger.info(
148 """Scene List:
149-----------------------------------------------------------------------
150 | Scene # | Start Frame | Start Time | End Frame | End Time |
151-----------------------------------------------------------------------
152%s
153-----------------------------------------------------------------------""",
154 "\n".join(
155 [
156 f" | {i + 1:5d} | {start_time.frame_num + 1:11d} | {start_time.get_timecode()} | {end_time.frame_num:11d} | {end_time.get_timecode()} |"
157 for i, (start_time, end_time) in enumerate(scenes)
158 ]
159 ),
160 )
161 # Print cut list.

Callers

nothing calls this directly

Calls 5

get_and_create_pathFunction · 0.90
write_scene_listFunction · 0.90
TemplateClass · 0.85
get_timecodeMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected