Class Demuxer

Class Documentation

class Demuxer

Media demuxer for extracting packets from containers.

Demuxer reads media files or streams and extracts compressed packets for individual streams (audio, video, etc.). It supports both one-shot demuxing (demux_window) and streaming demuxing for large files.

Public Functions

explicit Demuxer(DataInterfacePtr di)

Construct a demuxer from a data interface.

Parameters:

di – Data interface providing access to media data.

~Demuxer()

Destructor.

bool has_audio() const

Check if the media contains audio streams.

Returns:

true if audio is present, false otherwise.

template<MediaType media>
Codec<media> get_default_codec() const

Get the codec of the default stream for the given media type.

Template Parameters:

media – Media type (Audio, Video, or Image).

Returns:

Codec information for the default stream.

template<MediaType media>
int get_default_stream_index() const

Get the default stream index for the given media type.

Template Parameters:

media – Media type (Audio, Video, or Image).

Returns:

Stream index of the default stream.

template<MediaType media>
PacketsPtr<media> demux_window(const std::optional<TimeWindow> &window = std::nullopt, const std::optional<std::string> &bsf = std::nullopt)

Demux a time window from the default stream.

Template Parameters:

media – Media type (Audio, Video, or Image).

Parameters:
  • window – Optional time window to extract. If not specified, extracts all packets.

  • bsf – Optional bitstream filter to apply.

Returns:

Extracted packets.

StreamingDemuxerPtr streaming_demux(const std::set<int> &indices, int num_packets, double duration)

Create a streaming demuxer for specified streams.

Parameters:
  • indices – Set of stream indices to demux.

  • num_packets – Number of packets to extract per iteration.

  • duration – Duration in seconds to extract per iteration.

Returns:

Streaming demuxer instance.