pub struct MediaInfo { /* private fields */ }Expand description
Information about a media file.
This struct contains all metadata about a media container, including format information, duration, file size, and all contained streams.
§Construction
Use MediaInfo::builder() for fluent construction:
use ff_format::media::MediaInfo;
use std::time::Duration;
let info = MediaInfo::builder()
.path("/path/to/video.mp4")
.format("mp4")
.duration(Duration::from_secs(120))
.file_size(1_000_000)
.build();Implementations§
Source§impl MediaInfo
impl MediaInfo
Sourcepub fn builder() -> MediaInfoBuilder
pub fn builder() -> MediaInfoBuilder
Creates a new builder for constructing MediaInfo.
§Examples
use ff_format::media::MediaInfo;
use std::time::Duration;
let info = MediaInfo::builder()
.path("/path/to/video.mp4")
.format("mp4")
.duration(Duration::from_secs(120))
.file_size(1_000_000)
.build();Sourcepub fn format_long_name(&self) -> Option<&str>
pub fn format_long_name(&self) -> Option<&str>
Returns the long format name, if available.
Sourcepub const fn bitrate(&self) -> Option<u64>
pub const fn bitrate(&self) -> Option<u64>
Returns the overall bitrate in bits per second, if known.
Sourcepub fn video_streams(&self) -> &[VideoStreamInfo]
pub fn video_streams(&self) -> &[VideoStreamInfo]
Returns all video streams in the file.
Sourcepub fn audio_streams(&self) -> &[AudioStreamInfo]
pub fn audio_streams(&self) -> &[AudioStreamInfo]
Returns all audio streams in the file.
Sourcepub fn subtitle_streams(&self) -> &[SubtitleStreamInfo]
pub fn subtitle_streams(&self) -> &[SubtitleStreamInfo]
Returns all subtitle streams in the file.
Sourcepub fn chapters(&self) -> &[ChapterInfo]
pub fn chapters(&self) -> &[ChapterInfo]
Returns all chapters in the file.
Sourcepub fn has_chapters(&self) -> bool
pub fn has_chapters(&self) -> bool
Returns true if the file contains at least one chapter marker.
Sourcepub fn chapter_count(&self) -> usize
pub fn chapter_count(&self) -> usize
Returns the number of chapters.
Sourcepub fn metadata_value(&self, key: &str) -> Option<&str>
pub fn metadata_value(&self, key: &str) -> Option<&str>
Returns a specific metadata value by key.
Sourcepub fn has_subtitles(&self) -> bool
pub fn has_subtitles(&self) -> bool
Returns true if the file contains at least one subtitle stream.
Sourcepub fn video_stream_count(&self) -> usize
pub fn video_stream_count(&self) -> usize
Returns the number of video streams.
Sourcepub fn audio_stream_count(&self) -> usize
pub fn audio_stream_count(&self) -> usize
Returns the number of audio streams.
Sourcepub fn subtitle_stream_count(&self) -> usize
pub fn subtitle_stream_count(&self) -> usize
Returns the number of subtitle streams.
Sourcepub fn stream_count(&self) -> usize
pub fn stream_count(&self) -> usize
Returns the total number of streams (video + audio + subtitle).
Sourcepub fn primary_video(&self) -> Option<&VideoStreamInfo>
pub fn primary_video(&self) -> Option<&VideoStreamInfo>
Returns the primary video stream.
The primary video stream is the first video stream in the file.
Returns None if there are no video streams.
Sourcepub fn primary_audio(&self) -> Option<&AudioStreamInfo>
pub fn primary_audio(&self) -> Option<&AudioStreamInfo>
Returns the primary audio stream.
The primary audio stream is the first audio stream in the file.
Returns None if there are no audio streams.
Sourcepub fn video_stream(&self, index: usize) -> Option<&VideoStreamInfo>
pub fn video_stream(&self, index: usize) -> Option<&VideoStreamInfo>
Returns a video stream by index within the video streams list.
Sourcepub fn audio_stream(&self, index: usize) -> Option<&AudioStreamInfo>
pub fn audio_stream(&self, index: usize) -> Option<&AudioStreamInfo>
Returns an audio stream by index within the audio streams list.
Sourcepub fn subtitle_stream(&self, index: usize) -> Option<&SubtitleStreamInfo>
pub fn subtitle_stream(&self, index: usize) -> Option<&SubtitleStreamInfo>
Returns a subtitle stream by index within the subtitle streams list.
Sourcepub fn resolution(&self) -> Option<(u32, u32)>
pub fn resolution(&self) -> Option<(u32, u32)>
Returns the resolution of the primary video stream.
Returns None if there are no video streams.
Sourcepub fn frame_rate(&self) -> Option<f64>
pub fn frame_rate(&self) -> Option<f64>
Returns the frame rate of the primary video stream.
Returns None if there are no video streams.
Sourcepub fn sample_rate(&self) -> Option<u32>
pub fn sample_rate(&self) -> Option<u32>
Returns the sample rate of the primary audio stream.
Returns None if there are no audio streams.
Sourcepub fn channels(&self) -> Option<u32>
pub fn channels(&self) -> Option<u32>
Returns the channel count of the primary audio stream.
Returns None if there are no audio streams.
Sourcepub fn is_video_only(&self) -> bool
pub fn is_video_only(&self) -> bool
Returns true if this is a video-only file (no audio streams).
Sourcepub fn is_audio_only(&self) -> bool
pub fn is_audio_only(&self) -> bool
Returns true if this is an audio-only file (no video streams).
Sourcepub fn title(&self) -> Option<&str>
pub fn title(&self) -> Option<&str>
Returns the title from metadata.
This is a convenience method for accessing the “title” metadata key, which is commonly used by media containers to store the title of the content.
Sourcepub fn artist(&self) -> Option<&str>
pub fn artist(&self) -> Option<&str>
Returns the artist from metadata.
This is a convenience method for accessing the “artist” metadata key.
Sourcepub fn album(&self) -> Option<&str>
pub fn album(&self) -> Option<&str>
Returns the album from metadata.
This is a convenience method for accessing the “album” metadata key.
Sourcepub fn creation_time(&self) -> Option<&str>
pub fn creation_time(&self) -> Option<&str>
Returns the creation time from metadata.
This is a convenience method for accessing the creation_time metadata key,
which is commonly used by media containers to store when the file was created.
The format is typically ISO 8601 (e.g., 2024-01-15T10:30:00.000000Z).
Sourcepub fn date(&self) -> Option<&str>
pub fn date(&self) -> Option<&str>
Returns the date from metadata.
This is a convenience method for accessing the “date” metadata key.