Current position within stream as a Timecode.
(self)
| 210 | |
| 211 | @property |
| 212 | def timecode(self) -> Timecode: |
| 213 | """Current position within stream as a Timecode.""" |
| 214 | # *NOTE*: Although OpenCV has `CAP_PROP_PTS`, it doesn't seem to be reliable. For now, we |
| 215 | # use `CAP_PROP_POS_MSEC` instead, converting to microseconds for sufficient precision to |
| 216 | # avoid frame-boundary rounding errors at common framerates like 24000/1001. |
| 217 | ms = self._cap.get(cv2.CAP_PROP_POS_MSEC) |
| 218 | time_base = Fraction(1, 1000000) |
| 219 | return Timecode(pts=round(ms * 1000), time_base=time_base) |
| 220 | |
| 221 | @property |
| 222 | def position(self) -> FrameTimecode: |