Rate this Page
★ ★ ★ ★ ★

get_container_metadata#

torchcodec.decoders.get_container_metadata(source: str | Path | bytes | Tensor | RawIOBase | BufferedReader) → ContainerMetadata[source]#

Describe a container and every stream in it, without decoding anything.

metadata = get_container_metadata("video.mp4")
metadata.duration_seconds_from_header
metadata.streams[metadata.best_video_stream_index].width

Only the header is read, so this is what to reach for before you know what a file holds, and therefore which streams to ask a Demuxer for.

Parameters:

source (str, Pathlib.path, bytes, torch.Tensor or file-like object) – The source of the media, as for Demuxer.

Returns:

The container’s own metadata, plus one entry per stream, indexed by stream index.

Return type:

ContainerMetadata

Examples using get_container_metadata:

Build your own decoding pipeline

Build your own decoding pipeline