| 98 | self.__timestamp = 0 |
| 99 | |
| 100 | def _get_next(self) -> tuple[bytes, int, int]: |
| 101 | # Get next frame |
| 102 | ret = self._decoder.get_next() |
| 103 | self.__physical_frame += 1 |
| 104 | |
| 105 | # Check if an error occurred |
| 106 | if ret is None: |
| 107 | self._reset() # Reset just to be safe |
| 108 | self.seek(0) |
| 109 | msg = "failed to decode next frame in WebP file" |
| 110 | raise EOFError(msg) |
| 111 | |
| 112 | # Compute duration |
| 113 | data, timestamp = ret |
| 114 | duration = timestamp - self.__timestamp |
| 115 | self.__timestamp = timestamp |
| 116 | |
| 117 | # libwebp gives frame end, adjust to start of frame |
| 118 | timestamp -= duration |
| 119 | return data, timestamp, duration |
| 120 | |
| 121 | def _seek(self, frame: int) -> None: |
| 122 | if self.__physical_frame == frame: |