ac_ffmpeg::codec

Trait Encoder

Source
pub trait Encoder {
    type CodecParameters;
    type Frame;

    // Required methods
    fn codec_parameters(&self) -> Self::CodecParameters;
    fn try_push(&mut self, frame: Self::Frame) -> Result<(), CodecError>;
    fn try_flush(&mut self) -> Result<(), CodecError>;
    fn take(&mut self) -> Result<Option<Packet>, Error>;

    // Provided methods
    fn push(&mut self, frame: Self::Frame) -> Result<(), Error> { ... }
    fn flush(&mut self) -> Result<(), Error> { ... }
}
Expand description

A media encoder.

§Common encoder operation

  1. Push a frame to the encoder.
  2. Take all packets from the encoder until you get None.
  3. If there are more frames to be encoded, continue with 1.
  4. Flush the encoder.
  5. Take all packets from the encoder until you get None.

Required Associated Types§

Required Methods§

Source

fn codec_parameters(&self) -> Self::CodecParameters

Get codec parameters.

Source

fn try_push(&mut self, frame: Self::Frame) -> Result<(), CodecError>

Push a given frame to the encoder.

Source

fn try_flush(&mut self) -> Result<(), CodecError>

Flush the encoder.

Source

fn take(&mut self) -> Result<Option<Packet>, Error>

Take the next packet from the encoder.

Provided Methods§

Source

fn push(&mut self, frame: Self::Frame) -> Result<(), Error>

Push a given frame to the encoder.

§Panics

The method panics if the operation is not expected (i.e. another operation needs to be done).

Source

fn flush(&mut self) -> Result<(), Error>

Flush the encoder.

§Panics

The method panics if the operation is not expected (i.e. another operation needs to be done).

Implementors§