pub struct ThumbnailSelector { /* private fields */ }Expand description
Automatically selects the best thumbnail frame from a video file.
Candidates are sampled at regular intervals. Frames that are near-black (mean luma < 10), near-white (mean luma > 245), or blurry (Laplacian variance < 100) are skipped. The first candidate that passes all quality gates is returned. If no candidate passes, the sharpest frame seen is returned as a fallback.
§Examples
ⓘ
use ff_decode::ThumbnailSelector;
use std::time::Duration;
let frame = ThumbnailSelector::new("video.mp4")
.candidate_interval(Duration::from_secs(5))
.run()?;Implementations§
Source§impl ThumbnailSelector
impl ThumbnailSelector
Sourcepub fn new(input: impl AsRef<Path>) -> Self
pub fn new(input: impl AsRef<Path>) -> Self
Creates a new ThumbnailSelector for the given input file.
Default candidate interval is 5 seconds.
Sourcepub fn candidate_interval(self, d: Duration) -> Self
pub fn candidate_interval(self, d: Duration) -> Self
Sets the interval between candidate frames (default: 5s).
Sourcepub fn run(self) -> Result<VideoFrame, DecodeError>
pub fn run(self) -> Result<VideoFrame, DecodeError>
Runs thumbnail selection and returns the best frame.
§Errors
DecodeError::AnalysisFailed— the interval is zero, or no frame can be sampled from the video.- Any other
DecodeErrorpropagated from the decoder.
Auto Trait Implementations§
impl Freeze for ThumbnailSelector
impl RefUnwindSafe for ThumbnailSelector
impl Send for ThumbnailSelector
impl Sync for ThumbnailSelector
impl Unpin for ThumbnailSelector
impl UnsafeUnpin for ThumbnailSelector
impl UnwindSafe for ThumbnailSelector
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