diff --git a/mediapy/__init__.py b/mediapy/__init__.py index 22686e5..afbbf0b 100644 --- a/mediapy/__init__.py +++ b/mediapy/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2023 The mediapy Authors. +# Copyright 2024 The mediapy Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -1185,7 +1185,8 @@ class VideoMetadata(typing.NamedTuple): Attributes: num_images: Number of frames that is expected from the video stream. This is estimated from the framerate and the duration stored in the video - header, so it might be inexact. + header, so it might be inexact. We set the value to -1 if number of + frames is not found in the header. shape: The dimensions (height, width) of each video frame. fps: The framerate in frames per second. bps: The estimated bitrate of the video stream in bits per second, retrieved @@ -1241,7 +1242,7 @@ def _get_video_metadata(path: _Path) -> VideoMetadata: if match := re.fullmatch(r'.*rotation of (-?\d+).*\sdegrees', line): rotation = int(match.group(1)) if not num_images: - raise RuntimeError(f'Unable to find frames in video: {err}') + num_images = -1 if not width: raise RuntimeError(f'Unable to parse video header: {err}') # By default, ffmpeg enables "-autorotate"; we just fix the dimensions. diff --git a/mediapy_test.py b/mediapy_test.py index 840d861..0ffa935 100755 --- a/mediapy_test.py +++ b/mediapy_test.py @@ -1,4 +1,4 @@ -# Copyright 2023 The mediapy Authors. +# Copyright 2024 The mediapy Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/pdoc_files/make.py b/pdoc_files/make.py index bce7f97..1644976 100644 --- a/pdoc_files/make.py +++ b/pdoc_files/make.py @@ -1,4 +1,4 @@ -# Copyright 2023 The mediapy Authors. +# Copyright 2024 The mediapy Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.