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

Method _get_other_as_seconds

scenedetect/common.py:757–774  ·  view source on GitHub ↗

Get the time in seconds from `other` for arithmetic operations.

(self, other: "TimecodeLike")

Source from the content-addressed store, hash-verified

755 return self.frame_num
756
757 def _get_other_as_seconds(self, other: "TimecodeLike") -> float:
758 """Get the time in seconds from `other` for arithmetic operations."""
759 if isinstance(other, int):
760 # Convert frame number to seconds using framerate.
761 if self._rate is None:
762 raise NotImplementedError(
763 "Cannot convert frame number to seconds without framerate"
764 )
765 return float(other) / float(self._rate)
766 if isinstance(other, float):
767 return other
768 if isinstance(other, str):
769 return self._timecode_to_seconds(other)
770 if isinstance(other, Timecode):
771 return other.seconds
772 if isinstance(other, FrameTimecode):
773 return other.seconds
774 raise TypeError("Unsupported type for performing arithmetic with FrameTimecode.")
775
776
777def _compare_as_fixed(other: ty.Any, base: FrameTimecode) -> ty.TypeGuard[FrameTimecode]:

Callers 8

__eq__Method · 0.95
__ne__Method · 0.95
__lt__Method · 0.95
__le__Method · 0.95
__gt__Method · 0.95
__ge__Method · 0.95
__iadd__Method · 0.95
__isub__Method · 0.95

Calls 1

_timecode_to_secondsMethod · 0.95

Tested by

no test coverage detected