pub struct ImageEncoder { /* private fields */ }Expand description
Encodes a single VideoFrame to a still image file.
The output format is inferred from the file extension: .jpg/.jpeg,
.png, .bmp, .tif/.tiff, or .webp.
§Example
ⓘ
use ff_encode::ImageEncoder;
use ff_format::PixelFormat;
let encoder = ImageEncoder::create("thumbnail.jpg")
.width(320)
.height(240)
.quality(85)
.build()?;
encoder.encode(&frame)?;Implementations§
Source§impl ImageEncoder
impl ImageEncoder
Sourcepub fn create(path: impl AsRef<Path>) -> ImageEncoderBuilder
pub fn create(path: impl AsRef<Path>) -> ImageEncoderBuilder
Start building an image encoder that writes to path.
This is infallible; extension validation happens in
ImageEncoderBuilder::build.
Sourcepub fn encode(self, frame: &VideoFrame) -> Result<(), EncodeError>
pub fn encode(self, frame: &VideoFrame) -> Result<(), EncodeError>
Encode frame and write it to the output file.
If width or height were set on the builder and differ from the
source frame dimensions, swscale is used to resize. If pixel_format
was set and differs from the frame format, swscale performs conversion.
§Errors
Returns an error if the FFmpeg encoder is unavailable, the output file cannot be created, or encoding fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ImageEncoder
impl RefUnwindSafe for ImageEncoder
impl Send for ImageEncoder
impl Sync for ImageEncoder
impl Unpin for ImageEncoder
impl UnsafeUnpin for ImageEncoder
impl UnwindSafe for ImageEncoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more