Rate this Page

AudioStreamMetadata#

class torchcodec.decoders.AudioStreamMetadata(duration_seconds_from_header: float | None, begin_stream_seconds_from_header: float | None, bit_rate: float | None, codec: str | None, stream_index: int, duration_seconds: float | None, begin_stream_seconds: float | None, sample_rate: int | None, num_channels: int | None, sample_format: str | None)[source]#

Metadata of a single audio stream.

Examples using AudioStreamMetadata:

Decoding audio streams with AudioDecoder

Decoding audio streams with AudioDecoder
begin_stream_seconds: float | None#

Beginning of the stream, in seconds (float). Conceptually, this corresponds to the first frame’s pts. If a scan was performed and begin_stream_seconds_from_content is not None, then it is returned. Otherwise, this value is 0.

begin_stream_seconds_from_header: float | None#

Beginning of the stream, in seconds, obtained from the header (float or None). Usually, this is equal to 0.

bit_rate: float | None#

Bit rate of the stream, in seconds (float or None).

codec: str | None#

Codec (str or None).

duration_seconds: float | None#

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. If that value is also None, we instead calculate the duration from num_frames_from_header and average_fps_from_header. If all of those are unavailable, we fall back to the container-level duration_seconds_from_header.

duration_seconds_from_header: float | None#

Duration of the stream, in seconds, obtained from the header (float or None). This could be inaccurate.

num_channels: int | None#

The number of channels (1 for mono, 2 for stereo, etc.)

sample_format: str | None#

The original sample format, as described by FFmpeg. E.g. ‘fltp’, ‘s32’, etc.

sample_rate: int | None#

The original sample rate.

stream_index: int#

Index of the stream that this metadata refers to (int).