VideoStreamMetadata¶
- class torchcodec.decoders.VideoStreamMetadata(duration_seconds_from_header: Optional[float], begin_stream_seconds_from_header: Optional[float], bit_rate: Optional[float], codec: Optional[str], stream_index: int, begin_stream_seconds_from_content: Optional[float], end_stream_seconds_from_content: Optional[float], width: Optional[int], height: Optional[int], num_frames_from_header: Optional[int], num_frames_from_content: Optional[int], average_fps_from_header: Optional[float])[source]¶
Metadata of a single video stream.
Examples using
VideoStreamMetadata
:- property average_fps: Optional[float]¶
Average fps of the stream. If a scan was perfomed, this is computed from the number of frames and the duration of the stream. Otherwise we fall back to
average_fps_from_header
.
- average_fps_from_header: Optional[float]¶
Averate fps of the stream, obtained from the header (float or None). We recommend using the
average_fps
attribute instead.
- property begin_stream_seconds: float¶
Beginning of the stream, in seconds (float). Conceptually, this corresponds to the first frame’s pts. If
begin_stream_seconds_from_content
is not None, then it is returned. Otherwise, this value is 0.
- begin_stream_seconds_from_content: Optional[float]¶
Beginning of the stream, in seconds (float or None). Conceptually, this corresponds to the first frame’s pts. It is only computed when a scan is done as min(frame.pts) across all frames in the stream. Usually, this is equal to 0.
- begin_stream_seconds_from_header: Optional[float]¶
Beginning of the stream, in seconds, obtained from the header (float or None). Usually, this is equal to 0.
- property duration_seconds: Optional[float]¶
Duration of the stream in seconds. We try to calculate the duration from the actual frames if a scan was performed. Otherwise we fall back to
duration_seconds_from_header
.
- duration_seconds_from_header: Optional[float]¶
Duration of the stream, in seconds, obtained from the header (float or None). This could be inaccurate.
- property end_stream_seconds: Optional[float]¶
End of the stream, in seconds (float or None). Conceptually, this corresponds to last_frame.pts + last_frame.duration. If
end_stream_seconds_from_content
is not None, then that value is returned. Otherwise, returnsduration_seconds
.
- end_stream_seconds_from_content: Optional[float]¶
End of the stream, in seconds (float or None). Conceptually, this corresponds to last_frame.pts + last_frame.duration. It is only computed when a scan is done as max(frame.pts + frame.duration) across all frames in the stream. Note that no frame is played at this time value, so calling
get_frame_played_at()
with this value would result in an error. Retrieving the last frame is best done by simply indexing theVideoDecoder
object with[-1]
.
- property num_frames: Optional[int]¶
Number of frames in the stream. This corresponds to
num_frames_from_content
if a scan was made, otherwise it corresponds tonum_frames_from_header
.
- num_frames_from_content: Optional[int]¶
Number of frames computed by TorchCodec by scanning the stream’s content (the scan doesn’t involve decoding). This is more accurate than
num_frames_from_header
. We recommend using thenum_frames
attribute instead. (int or None).