Skip to main content

Encoder

Trait Encoder 

Source
pub trait Encoder: Send {
    // Required methods
    fn send_frame(&mut self, frame: Option<&Frame>) -> Result<()>;
    fn receive_packet(&mut self) -> Result<Packet>;
    fn flush(&mut self);
}
Expand description

Encoder trait — the main abstraction for all encoders.

Follows FFmpeg’s send/receive model:

  1. send_frame() — feed raw data
  2. receive_packet() — pull compressed data
  3. flush() — signal end-of-stream

Required Methods§

Source

fn send_frame(&mut self, frame: Option<&Frame>) -> Result<()>

Send a raw frame to the encoder. Pass None to signal end-of-stream (drain mode).

Source

fn receive_packet(&mut self) -> Result<Packet>

Receive an encoded packet from the encoder. Returns Error::Again when more input is needed. Returns Error::Eof when all data has been drained.

Source

fn flush(&mut self)

Flush the encoder (reset internal state).

Implementors§