pub trait Encoder: Send {
// Required methods
fn send_frame(&mut self, frame: &Frame) -> Result<()>;
fn receive_packet(&mut self) -> Result<Packet>;
// Provided methods
fn configure(&mut self, _options: &Dictionary) -> Result<()> { ... }
fn accepted_sample_rates(&self) -> Option<Vec<u32>> { ... }
fn accepted_pixel_formats(&self) -> Option<Vec<PixelFormat>> { ... }
fn flush(&mut self) { ... }
}Required Methods§
Sourcefn send_frame(&mut self, frame: &Frame) -> Result<()>
fn send_frame(&mut self, frame: &Frame) -> Result<()>
Submit one raw frame for encoding.
Sourcefn receive_packet(&mut self) -> Result<Packet>
fn receive_packet(&mut self) -> Result<Packet>
Retrieve the next encoded packet, if one is ready.
Provided Methods§
Sourcefn configure(&mut self, _options: &Dictionary) -> Result<()>
fn configure(&mut self, _options: &Dictionary) -> Result<()>
Receive output options before encoding begins — rate control and tuning:
crf/qp (quality), preset (speed/quality trade-off), b (bitrate),
pass (1 or 2). Default: ignore them. Called once, after construction.
Sourcefn accepted_sample_rates(&self) -> Option<Vec<u32>>
fn accepted_sample_rates(&self) -> Option<Vec<u32>>
The input sample rates this encoder accepts, or None for “any rate”.
The transcode pipeline resamples audio to the nearest accepted rate
before feeding frames (mirrors FFmpeg’s automatic aresample).
Sourcefn accepted_pixel_formats(&self) -> Option<Vec<PixelFormat>>
fn accepted_pixel_formats(&self) -> Option<Vec<PixelFormat>>
The pixel formats this encoder accepts, most-preferred first, or None
for “any format”. The transcode pipeline converts video to the first
accepted format before feeding frames (FFmpeg’s automatic scale).
Declaring this lets decoders emit whatever layout is cheapest for them —
a JPEG decoder can hand out planar Y’CbCr instead of converting to RGB —
without breaking encoders that need something else. An encoder that
leaves this None must genuinely handle every format it is given.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".