def _num_clips(
    duration_sec: float,
    fps: float,
    stride_frames: int,
    window_size_frames: int,
    backpad_last: bool = True,
) -> int:
    """
    Utility to calculate the number of clips for a given duration, fps, stride & window_size
    """
    num_frames = round(duration_sec * fps)
    N = num_frames - window_size_frames
    if N < 0:
        return 1

    result = N // stride_frames + 1

    # handle padded frame
    if backpad_last and N % stride_frames != 0:
        result += 1
    return result