(
ctx: click.Context,
start: str | None,
duration: str | None,
end: str | None,
)
| 494 | ) |
| 495 | @click.pass_context |
| 496 | def time_command( |
| 497 | ctx: click.Context, |
| 498 | start: str | None, |
| 499 | duration: str | None, |
| 500 | end: str | None, |
| 501 | ): |
| 502 | ctx = ctx.obj |
| 503 | assert isinstance(ctx, CliContext) |
| 504 | |
| 505 | if duration is not None and end is not None: |
| 506 | raise click.BadParameter( |
| 507 | "Only one of --duration/-d or --end/-e can be specified, not both.", |
| 508 | param_hint="time", |
| 509 | ) |
| 510 | logger.debug("Setting video time:\n start: %s, duration: %s, end: %s", start, duration, end) |
| 511 | # *NOTE*: The Python API uses 0-based frame indices, but the CLI uses 1-based indices to |
| 512 | # match the default start number used by `ffmpeg` when saving frames as images. As such, |
| 513 | # we must correct start time if set as frames. See the test_cli_time* tests for for details. |
| 514 | ctx.start_time = ctx.parse_timecode(start, correct_pts=True) |
| 515 | ctx.end_time = ctx.parse_timecode(end) |
| 516 | ctx.duration = ctx.parse_timecode(duration) |
| 517 | if ctx.start_time and ctx.end_time and (ctx.start_time + 1) > ctx.end_time: |
| 518 | raise click.BadParameter("-e/--end time must be greater than -s/--start") |
| 519 | |
| 520 | |
| 521 | DETECT_CONTENT_HELP = """Find fast cuts using differences in HSL (filtered). |
nothing calls this directly
no test coverage detected