Rate this Page
★ ★ ★ ★ ★

Packet#

class torchcodec.decoders.Packet(handle: Tensor, stream_index: int, *, generation: int = 0)[source]#

One compressed packet of one stream, as a Demuxer produced it.

You should not build one yourself: a Demuxer creates them, and a VideoPacketDecoder or an AudioPacketDecoder consumes them. The contents are opaque: a Packet is a handle to an FFmpeg packet.

Examples using Packet:

Build your own decoding pipeline

Build your own decoding pipeline
stream_index: int#

The index of the stream this packet belongs to, absolute across all media types. When a demuxer follows more than one stream, this is what routes each packet to the right decoder.