Skip to main content

Encodable

Trait Encodable 

Source
pub trait Encodable {
    // Required methods
    fn new(config: EncoderConfig) -> Result<Self>
       where Self: Sized;
    fn update_bitrate_kbps(&mut self, kbps: u32) -> Result<()>;
    fn encode(&mut self, pts: i64, i420: &[u8]) -> Result<Option<EncodedFrame>>;
}
Expand description

A codec-agnostic video encoder.

Implementations accept planar I420 frames and emit at most one compressed frame per call. Because some backends buffer frames (e.g. lag_in_frames), encode may return None for a call that produced no output yet; callers must tolerate zero-frame results.

Required Methods§

Source

fn new(config: EncoderConfig) -> Result<Self>
where Self: Sized,

Create a new encoder with the given configuration.

Source

fn update_bitrate_kbps(&mut self, kbps: u32) -> Result<()>

Update the target bitrate at runtime.

Source

fn encode(&mut self, pts: i64, i420: &[u8]) -> Result<Option<EncodedFrame>>

Encode one planar I420 frame.

pts is the presentation timestamp in time-base units. i420 is the full I420 buffer (width * height * 3 / 2 bytes). Returns the compressed frame if one is ready, or None if the encoder buffered it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§