Skip to content

Commit

Permalink
No longer raise RuntimeError if number of frames is not found in Meta…
Browse files Browse the repository at this point in the history
…data.

PiperOrigin-RevId: 609383580
  • Loading branch information
The mediapy Authors committed Feb 22, 2024
1 parent d7948a5 commit 50d675e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions mediapy/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion mediapy_test.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pdoc_files/make.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 50d675e

Please sign in to comment.