Template Class Encoder

Class Documentation

template<MediaType media>
class Encoder

Media encoder for compressing raw frames into packets.

Encoder converts raw frames (audio or video) into compressed packets using FFmpeg codecs.

Template Parameters:

media – The media type (Audio or Video).

Public Functions

explicit Encoder(detail::EncoderImpl<media> *pImpl)

Construct an encoder from implementation.

Parameters:

pImpl – Pointer to encoder implementation.

Encoder(const Encoder<media>&) = delete

Deleted copy constructor.

Encoder &operator=(const Encoder<media>&) = delete

Deleted copy assignment operator.

Encoder(Encoder<media>&&) = delete

Deleted move constructor.

Encoder &operator=(Encoder<media>&&) = delete

Deleted move assignment operator.

~Encoder()

Destructor.

std::optional<PacketsPtr<media>> encode(const FramesPtr<media>&&)

Encode frames into packets.

Parameters:

framesFrames to encode.

Returns:

Encoded packets, or std::nullopt if no packets are available yet.

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

Flush the encoder to retrieve any remaining packets.

Returns:

Remaining encoded packets, or std::nullopt if no packets are available.

int get_frame_size() const

Get the frame size for audio encoding.

Returns:

Number of samples per frame required by the encoder.