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)
| 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, |
no test coverage detected