Interface which all video backends must implement.
| 77 | |
| 78 | |
| 79 | class VideoStream(ABC): |
| 80 | """Interface which all video backends must implement.""" |
| 81 | |
| 82 | # |
| 83 | # Default Implementations |
| 84 | # |
| 85 | |
| 86 | @property |
| 87 | def base_timecode(self) -> FrameTimecode: |
| 88 | """FrameTimecode object to use as a time base.""" |
| 89 | return FrameTimecode(timecode=0, fps=self.frame_rate) |
| 90 | |
| 91 | # |
| 92 | # Backend Identification |
| 93 | # |
| 94 | |
| 95 | BACKEND_NAME: ty.ClassVar[str] |
| 96 | """Unique name used to identify this backend. Each subclass must set this to a unique str.""" |
| 97 | |
| 98 | # |
| 99 | # Abstract Properties |
| 100 | # |
| 101 | |
| 102 | @property |
| 103 | @abstractmethod |
| 104 | def path(self) -> str: |
| 105 | """Video or device path.""" |
| 106 | ... |
| 107 | |
| 108 | @property |
| 109 | @abstractmethod |
| 110 | def name(self) -> str: |
| 111 | """Name of the video, without extension, or device.""" |
| 112 | ... |
| 113 | |
| 114 | @property |
| 115 | @abstractmethod |
| 116 | def is_seekable(self) -> bool: |
| 117 | """True if seek() is allowed, False otherwise.""" |
| 118 | ... |
| 119 | |
| 120 | @property |
| 121 | @abstractmethod |
| 122 | def frame_rate(self) -> Fraction: |
| 123 | """Frame rate in frames/sec as a rational Fraction (e.g. Fraction(24000, 1001)).""" |
| 124 | ... |
| 125 | |
| 126 | @property |
| 127 | @abstractmethod |
| 128 | def duration(self) -> FrameTimecode | None: |
| 129 | """Duration of the stream as a FrameTimecode, or None if non terminating.""" |
| 130 | ... |
| 131 | |
| 132 | @property |
| 133 | @abstractmethod |
| 134 | def frame_size(self) -> tuple[int, int]: |
| 135 | """Size of each video frame in pixels as a tuple of (width, height).""" |
| 136 | ... |
nothing calls this directly
no outgoing calls
no test coverage detected