We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ede4c25 commit 63613c7Copy full SHA for 63613c7
src/torchcodec/_core/_metadata.py
@@ -85,7 +85,9 @@ class VideoStreamMetadata(StreamMetadata):
85
def duration_seconds(self) -> Optional[float]:
86
"""Duration of the stream in seconds. We try to calculate the duration
87
from the actual frames if a :term:`scan` was performed. Otherwise we
88
- fall back to ``duration_seconds_from_header``.
+ fall back to ``duration_seconds_from_header``. If that value is None,
89
+ we instead calculate the duration from ``num_frames_from_header`` and
90
+ ``average_fps_from_header``.
91
"""
92
if (
93
self.end_stream_seconds_from_content is not None
test/test_metadata.py
@@ -173,7 +173,7 @@ def test_calculate_num_frames_using_fps_and_duration(
173
174
@pytest.mark.parametrize(
175
"duration_seconds_from_header, begin_stream_seconds_from_content, end_stream_seconds_from_content, expected_duration_seconds",
176
- [(60, 5, 20, 15), (60, 1, None, 60), (None, 0, 10, 10)],
+ [(60, 5, 20, 15), (60, 1, None, 60), (60, None, 1, 60), (None, 0, 10, 10)],
177
)
178
def test_duration_seconds_fallback(
179
duration_seconds_from_header,
@@ -204,7 +204,7 @@ def test_duration_seconds_fallback(
204
205
206
"num_frames_from_header, average_fps_from_header, expected_duration_seconds",
207
- [(100, 10, 10), (100, None, None), (None, None, None)],
+ [(100, 10, 10), (100, None, None), (None, 10, None), (None, None, None)],
208
209
def test_calculate_duration_seconds_using_fps_and_num_frames(
210
num_frames_from_header, average_fps_from_header, expected_duration_seconds
0 commit comments