diff --git a/avi_r/reader.py b/avi_r/reader.py index fe0a09f..1cfb4bd 100644 --- a/avi_r/reader.py +++ b/avi_r/reader.py @@ -249,19 +249,24 @@ def _get_frame_gen(self, start_frame_id=0, retry=5, retry_step=120): self._logger.info( 'Failed to seek to frame %d, retrying with frame %d', start_frame_id, seek_frame_id) - self._container.seek(seek_frame_id, stream=self._stream) - frame_gen = self._fix_missing(start_frame_id) try: + self._container.seek(seek_frame_id, stream=self._stream) + frame_gen = self._fix_missing(start_frame_id) frame = next(frame_gen) break - except StopIteration: + except: seek_frame_id -= retry_step else: seek_frame_id = 0 self._logger.warn( 'Failed to seek to frame %d, iterating from the beginning', start_frame_id) - self._container.seek(seek_frame_id, stream=self._stream) + try: + self._container.seek(seek_frame_id, stream=self._stream) + except: + self._logger.exception( + 'Failed to seek to frame 0, still trying to read the ' + 'current frame, please check its frame id') frame_gen = self._fix_missing(seek_frame_id) frame = next(frame_gen) while frame.frame_id < start_frame_id: diff --git a/docs/version.md b/docs/version.md index 381669a..bb9b266 100644 --- a/docs/version.md +++ b/docs/version.md @@ -1,5 +1,9 @@ # Version History +## AVI-R v1.3.2 + +* More robust seek. + ## AVI-R v1.3.1 * Optimized reorder buffer for faster random access. diff --git a/setup.py b/setup.py index 257eaab..ec3c1b3 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='avi-r', - version='1.3.1', + version='1.3.2', author='Lijun Yu', author_email='lijun@lj-y.com', description='A robust reader for avi videos.',