Skip to main content

AnimationEncoder

Trait AnimationEncoder 

Source
pub trait AnimationEncoder: Send {
    // Required methods
    fn write_frame(&mut self, image: &Rgb8Image) -> Result<()>;
    fn finish(self: Box<Self>) -> Result<()>;
}
Expand description

Accepts rendered frames one at a time and finishes a file. Implemented per container so the caller can stream a long recording without holding every frame in memory.

Send because finishing an MP4 blocks on ffmpeg exiting, and the Python bindings release the GIL around that — a wait that can take seconds must not hold up every other thread.

Required Methods§

Source

fn write_frame(&mut self, image: &Rgb8Image) -> Result<()>

Writes one frame. Frames must all share the dimensions of the first.

Source

fn finish(self: Box<Self>) -> Result<()>

Finalises the file. Not folded into Drop because it can fail and the caller must see that.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§