Validate and convert an `fps` argument into a positive `Fraction`. NTSC-like frame rates are handled via :func:`framerate_to_fraction`.
(fps: "FrameRate | FrameTimecode")
| 451 | |
| 452 | @staticmethod |
| 453 | def _ensure_fractional(fps: "FrameRate | FrameTimecode") -> Fraction: |
| 454 | """Validate and convert an `fps` argument into a positive `Fraction`. NTSC-like frame rates |
| 455 | are handled via :func:`framerate_to_fraction`.""" |
| 456 | if isinstance(fps, FrameTimecode): |
| 457 | if fps._rate is None: |
| 458 | raise TypeError("FrameTimecode passed as fps must have a known rate.") |
| 459 | return fps._rate |
| 460 | if isinstance(fps, (float, Fraction)): |
| 461 | return framerate_to_fraction(fps) |
| 462 | raise TypeError( |
| 463 | f"Wrong type for fps: {type(fps)} - expected float, Fraction, or FrameTimecode" |
| 464 | ) |
| 465 | |
| 466 | def _seconds_to_frames(self, seconds: float) -> int: |
| 467 | """Convert `seconds` to the nearest number of frames using the current framerate. |
no test coverage detected