pub struct MediaProbe;Expand description
Lightweight media file probe.
Opens the file, extracts metadata, and immediately closes the demuxer.
The resulting MediaMetadata is identical to what
MediaFile::metadata returns, but
without keeping the file open for extraction.
§Example
use unbundle::{MediaProbe, UnbundleError};
let metadata = MediaProbe::probe("input.mp4")?;
println!("Duration: {:?}, format: {}", metadata.duration, metadata.format);
if let Some(video) = &metadata.video {
println!("Video: {}x{} @ {} fps", video.width, video.height, video.frames_per_second);
}Implementations§
Source§impl MediaProbe
impl MediaProbe
Sourcepub fn probe<P: AsRef<Path>>(path: P) -> Result<MediaMetadata, UnbundleError>
pub fn probe<P: AsRef<Path>>(path: P) -> Result<MediaMetadata, UnbundleError>
Probe a media file and return its metadata.
Opens the file, extracts all available metadata (video, audio,
subtitle streams, chapters), and closes the demuxer. The returned
MediaMetadata is owned and fully independent of any file handle.
§Errors
Returns UnbundleError::FileOpen if the file cannot be opened or
recognised as a media file.
§Example
use unbundle::{MediaProbe, UnbundleError};
let metadata = MediaProbe::probe("video.mkv")?;
println!("{:?}", metadata);Sourcepub fn probe_many<P: AsRef<Path>>(
paths: &[P],
) -> Vec<Result<MediaMetadata, UnbundleError>>
pub fn probe_many<P: AsRef<Path>>( paths: &[P], ) -> Vec<Result<MediaMetadata, UnbundleError>>
Probe multiple media files and return their metadata.
Files that cannot be probed produce an Err entry in the result
vector rather than aborting the entire batch.
§Example
use unbundle::MediaProbe;
let results = MediaProbe::probe_many(&["a.mp4", "b.mkv", "c.avi"]);
for result in &results {
match result {
Ok(meta) => println!("{}: {:?}", meta.format, meta.duration),
Err(err) => eprintln!("Error: {err}"),
}
}Auto Trait Implementations§
impl Freeze for MediaProbe
impl RefUnwindSafe for MediaProbe
impl Send for MediaProbe
impl Sync for MediaProbe
impl Unpin for MediaProbe
impl UnsafeUnpin for MediaProbe
impl UnwindSafe for MediaProbe
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more