Skip to main content

GifPreview

Struct GifPreview 

Source
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

Source

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.

Source

pub fn start(self, t: Duration) -> Self

Sets the start time within the video (default: 0s).

Source

pub fn duration(self, d: Duration) -> Self

Sets the duration of the GIF clip (default: 3s).

Source

pub fn fps(self, fps: f64) -> Self

Sets the output frame rate in frames per second (default: 10.0).

Source

pub fn width(self, w: u32) -> Self

Sets the output width in pixels (default: 320). Height is scaled proportionally, rounded to an even number.

Source

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.

Source

pub fn run(self) -> Result<(), EncodeError>

Runs the GIF generation.

§Errors

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.