Skip to content

Commit 1478117

Browse files
author
Molly Xu
committed
modify docstrings
1 parent b677863 commit 1478117

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/torchcodec/_core/_metadata.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,18 @@ class StreamMetadata:
4040

4141
# Computed fields (computed in C++ with fallback logic)
4242
duration_seconds: Optional[float]
43-
"""Duration of the stream in seconds. Tries to calculate from content
44-
if :term:`scan` was performed, otherwise falls back to header values."""
43+
"""Duration of the stream in seconds. We try to calculate the duration
44+
from the actual frames if a :term:`scan` was performed. Otherwise we
45+
fall back to ``duration_seconds_from_header``. If that value is also None,
46+
we instead calculate the duration from ``num_frames_from_header`` and
47+
``average_fps_from_header``.
48+
"""
4549
begin_stream_seconds: Optional[float]
46-
"""Beginning of the stream, in seconds."""
50+
"""Beginning of the stream, in seconds (float). Conceptually, this
51+
corresponds to the first frame's :term:`pts`. If a :term:`scan` was performed
52+
and ``begin_stream_seconds_from_content`` is not None, then it is returned.
53+
Otherwise, this value is 0.
54+
"""
4755

4856
def __repr__(self):
4957
s = self.__class__.__name__ + ":\n"
@@ -97,15 +105,21 @@ class VideoStreamMetadata(StreamMetadata):
97105
# Computed fields (computed in C++ with fallback logic)
98106
end_stream_seconds: Optional[float]
99107
"""End of the stream, in seconds (float or None).
100-
Conceptually, this corresponds to last_frame.pts + last_frame.duration."""
108+
Conceptually, this corresponds to last_frame.pts + last_frame.duration.
109+
If :term:`scan` was performed and``end_stream_seconds_from_content`` is not None, then that value is
110+
returned. Otherwise, returns ``duration_seconds``.
111+
"""
101112
num_frames: Optional[int]
102113
"""Number of frames in the stream (int or None).
103-
Uses content if :term:`scan` was performed,
104-
otherwise falls back to header values or calculates from duration and fps."""
114+
This corresponds to ``num_frames_from_content`` if a :term:`scan` was made,
115+
otherwise it corresponds to ``num_frames_from_header``. If that value is also
116+
None, the number of frames is calculated from the duration and the average fps.
117+
"""
105118
average_fps: Optional[float]
106-
"""Average fps of the stream (float or None).
107-
if :term:`scan` was performed, computes from
108-
num_frames and duration, otherwise uses header value."""
119+
"""Average fps of the stream. If a :term:`scan` was perfomed, this is
120+
computed from the number of frames and the duration of the stream.
121+
Otherwise we fall back to ``average_fps_from_header``.
122+
"""
109123

110124
def __repr__(self):
111125
return super().__repr__()

0 commit comments

Comments
 (0)