Template Class Decoder

Class Documentation

template<MediaType media>
class Decoder

Media decoder for audio, video, or image data.

Decoder converts compressed packets into raw frames using FFmpeg codecs. It supports optional filtering of decoded frames.

Template Parameters:

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

Public Functions

Decoder(const Codec<media> &codec, const std::optional<DecodeConfig> &cfg, const std::optional<std::string> &filter_desc)

Construct a decoder.

Parameters:
  • codecCodec information for the decoder.

  • cfg – Optional decode configuration.

  • filter_desc – Optional FFmpeg filter description to apply to decoded frames.

Decoder(const Decoder&) = delete

Deleted copy constructor.

Decoder &operator=(const Decoder&) = delete

Deleted copy assignment operator.

Decoder(Decoder&&) = delete

Deleted move constructor.

Decoder &operator=(Decoder&&) = delete

Deleted move assignment operator.

~Decoder()

Destructor.

FramesPtr<media> decode_and_flush(PacketsPtr<media> packets, int num_frames = -1)

Decode packets and flush the decoder in one operation.

Parameters:
  • packetsPackets to decode.

  • num_frames – Maximum number of frames to decode. Negative values decode all frames.

Returns:

Decoded frames.

std::optional<FramesPtr<media>> decode(PacketsPtr<media> packets)

Decode packets without flushing.

Parameters:

packetsPackets to decode.

Returns:

Decoded frames, or std::nullopt if no frames are available yet.

std::optional<FramesPtr<media>> flush()

Flush the decoder to retrieve any remaining frames.

Returns:

Remaining decoded frames, or std::nullopt if no frames are available.