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

Method handle_options

scenedetect/_cli/context.py:176–332  ·  view source on GitHub ↗

Parse all global options/arguments passed to the main scenedetect command, before other sub-commands (e.g. this function processes the [options] when calling `scenedetect [options] [commands [command options]]`). Raises: click.BadParameter: One of the given optio

(
        self,
        input_path: str | None,
        output: str | None,
        frame_rate: float | None,
        stats_file: str | None,
        frame_skip: int | None,
        min_scene_len: str | None,
        drop_short_scenes: bool | None,
        merge_last_scene: bool | None,
        backend: str | None,
        crop: tuple[int, int, int, int] | None,
        downscale: int | None,
        quiet: bool,
        logfile: str | None,
        config: str | None,
        stats: str | None,
        verbosity: str | None,
    )

Source from the content-addressed store, hash-verified

174 ) from ex
175
176 def handle_options(
177 self,
178 input_path: str | None,
179 output: str | None,
180 frame_rate: float | None,
181 stats_file: str | None,
182 frame_skip: int | None,
183 min_scene_len: str | None,
184 drop_short_scenes: bool | None,
185 merge_last_scene: bool | None,
186 backend: str | None,
187 crop: tuple[int, int, int, int] | None,
188 downscale: int | None,
189 quiet: bool,
190 logfile: str | None,
191 config: str | None,
192 stats: str | None,
193 verbosity: str | None,
194 ):
195 """Parse all global options/arguments passed to the main scenedetect command,
196 before other sub-commands (e.g. this function processes the [options] when calling
197 `scenedetect [options] [commands [command options]]`).
198
199 Raises:
200 click.BadParameter: One of the given options/parameters is invalid.
201 click.Abort: Fatal initialization failure.
202 """
203
204 # TODO(v1.0): Make the stats value optional (e.g. allow -s only), and allow use of
205 # $VIDEO_NAME macro in the name. Default to $VIDEO_NAME.csv.
206
207 # The `scenedetect` command was just started, let's initialize logging and try to load any
208 # config files that were specified.
209 init_log: list = []
210 try:
211 init_failure = not self.config.initialized
212 init_log = self.config.get_init_log()
213 quiet = not init_failure and quiet
214 self._initialize_logging(quiet, verbosity, logfile)
215
216 # Configuration file was specified via CLI argument -c/--config.
217 if config and not init_failure:
218 self.config = ConfigRegistry(config)
219 init_log += self.config.get_init_log()
220 # Re-initialize logger with the correct verbosity.
221 if verbosity is None and not self.config.is_default("global", "verbosity"):
222 verbosity_str = self.config.get_value("global", "verbosity")
223 assert verbosity_str in CHOICE_MAP["global"]["verbosity"]
224 self.quiet_mode = False
225 self._initialize_logging(verbosity=verbosity_str, logfile=logfile)
226
227 except ConfigLoadFailure as ex:
228 init_failure = True
229 init_log += ex.init_log
230 if ex.reason is not None:
231 init_log += [
232 (logging.ERROR, "Error: {}".format(str(ex.reason).replace("\t", " ")))
233 ]

Callers 1

scenedetectFunction · 0.80

Calls 15

_initialize_loggingMethod · 0.95
_open_video_streamMethod · 0.95
parse_timecodeMethod · 0.95
ConfigRegistryClass · 0.90
StatsManagerClass · 0.90
SceneManagerClass · 0.90
CropValueClass · 0.90

Tested by

no test coverage detected