pub struct GifPreview { /* private fields */ }Expand description
Generates an animated GIF preview from a configurable time range.
Uses FFmpeg’s two-pass palettegen + paletteuse approach for
high-quality colour fidelity within GIF’s 256-colour limit.
§Examples
ⓘ
use ff_encode::GifPreview;
use std::time::Duration;
GifPreview::new("video.mp4")
.start(Duration::from_secs(10))
.duration(Duration::from_secs(3))
.fps(15.0)
.width(480)
.output("preview.gif")
.run()?;Implementations§
Source§impl GifPreview
impl GifPreview
Sourcepub fn new(input: impl AsRef<Path>) -> Self
pub fn new(input: impl AsRef<Path>) -> Self
Creates a new GifPreview for the given input file.
Defaults: start=0s, duration=3s, fps=10.0, width=320,
no output path set.
Sourcepub fn fps(self, fps: f64) -> Self
pub fn fps(self, fps: f64) -> Self
Sets the output frame rate in frames per second (default: 10.0).
Sourcepub fn width(self, w: u32) -> Self
pub fn width(self, w: u32) -> Self
Sets the output width in pixels (default: 320). Height is scaled proportionally, rounded to an even number.
Sourcepub fn output(self, path: impl AsRef<Path>) -> Self
pub fn output(self, path: impl AsRef<Path>) -> Self
Sets the output path for the generated GIF file.
The path must have a .gif extension.
Sourcepub fn run(self) -> Result<(), EncodeError>
pub fn run(self) -> Result<(), EncodeError>
Runs the GIF generation.
§Errors
EncodeError::MediaOperationFailed— output path not set, output extension is not.gif,fps≤ 0, orwidthis zero.EncodeError::Ffmpeg— any FFmpeg filter graph or encoding call fails.
Auto Trait Implementations§
impl Freeze for GifPreview
impl RefUnwindSafe for GifPreview
impl Send for GifPreview
impl Sync for GifPreview
impl Unpin for GifPreview
impl UnsafeUnpin for GifPreview
impl UnwindSafe for GifPreview
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