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

Method parse_timecode

scenedetect/_cli/context.py:152–174  ·  view source on GitHub ↗

Parses a user input string into a FrameTimecode assuming the given framerate. If `value` is None it will be passed through without processing. Raises: click.BadParameter, click.ClickException

(self, value: str | None, correct_pts: bool = False)

Source from the content-addressed store, hash-verified

150 return parsed.frame_num
151
152 def parse_timecode(self, value: str | None, correct_pts: bool = False) -> FrameTimecode | None:
153 """Parses a user input string into a FrameTimecode assuming the given framerate. If `value`
154 is None it will be passed through without processing.
155
156 Raises:
157 click.BadParameter, click.ClickException
158 """
159 if value is None:
160 return None
161 try:
162 if self.video_stream is None:
163 raise click.ClickException("No input video (-i/--input) was specified.")
164 timecode: int | str
165 if correct_pts and value.isdigit():
166 int_value = int(value)
167 timecode = int_value - 1 if int_value >= 1 else int_value
168 else:
169 timecode = value
170 return FrameTimecode(timecode=timecode, fps=self.video_stream.frame_rate)
171 except ValueError as ex:
172 raise click.BadParameter(
173 "timecode must be in seconds (100.0), frames (100), or HH:MM:SS"
174 ) from ex
175
176 def handle_options(
177 self,

Callers 3

handle_optionsMethod · 0.95
time_commandFunction · 0.80

Calls 1

FrameTimecodeClass · 0.90

Tested by

no test coverage detected