spdl.io.Demuxer

class Demuxer(src: str | Path | bytes | object, **kwargs)[source]

Demuxer can demux audio, video and image from the soure.

Parameters:
  • src – Source identifier. If str type, it is interpreted as a source location, such as local file path or URL. If bytes type, then they are interpreted as in-memory data. If array type (objects implement buffer protocol, such as NumPy NDArray and PyTorch Tensor), then they must be 1 dimentional uint8 array, which contains the raw bytes of the source.

  • demux_config (DemuxConfig) – Custom I/O config.

Methods

demux_audio([window])

Demux audio from the source.

demux_image(**kwargs)

Demux image from the source.

demux_video([window])

Demux video from the source.

has_audio()

Returns true if the source has audio stream.

streaming_demux_video(num_packets[, bsf])

Demux video frames in streaming fashion.

Attributes

audio_codec

The codec metadata of the default audio stream.

image_codec

The codec metadata of the default image stream.

video_codec

The codec metadata of the default video stream.

property audio_codec: AudioCodec[source]

The codec metadata of the default audio stream.

demux_audio(window: tuple[float, float] | None = None, **kwargs) AudioPackets[source]

Demux audio from the source.

Parameters:

timestamp – A time window. If omitted, the entire audio are demuxed.

Returns:

Demuxed audio packets.

demux_image(**kwargs) ImagePackets[source]

Demux image from the source.

Returns:

Demuxed image packets.

demux_video(window: tuple[float, float] | None = None, **kwargs) VideoPackets[source]

Demux video from the source.

Parameters:

timestamp – A time window. If omitted, the entire audio are demuxed.

Returns:

Demuxed video packets.

has_audio() bool[source]

Returns true if the source has audio stream.

property image_codec: ImageCodec[source]

The codec metadata of the default image stream.

streaming_demux_video(num_packets: int, bsf: str | None = None) Iterator[VideoPackets][source]

Demux video frames in streaming fashion.

Parameters:

num_packets – The number of packets to return at a time.

property video_codec: VideoCodec[source]

The codec metadata of the default video stream.