Crate rust_ffprobe

Crate rust_ffprobe 

Source
Expand description

Safe and idiomatic Rust wrapper for FFprobe

This crate provides a high-level, safe interface to FFprobe functionality, allowing you to extract metadata and information from multimedia files.

§Examples

§Basic usage

use ffprobe_rs::FFprobeBuilder;

// Probe a file for format and stream information
let result = FFprobeBuilder::probe("video.mp4")
    .run()
    .await?;

// Access format information
if let Some(format) = &result.format {
    println!("Format: {}", format.format_name.as_deref().unwrap_or("unknown"));
    println!("Duration: {} seconds", result.duration().unwrap_or(0.0));
}

// Access stream information
for stream in &result.streams {
    match stream.codec_type.as_deref() {
        Some("video") => {
            println!("Video: {}x{}", 
                stream.width.unwrap_or(0), 
                stream.height.unwrap_or(0)
            );
        }
        Some("audio") => {
            println!("Audio: {} Hz, {} channels",
                stream.sample_rate.as_deref().unwrap_or("?"),
                stream.channels.unwrap_or(0)
            );
        }
        _ => {}
    }
}

§Advanced usage

use ffprobe_rs::{FFprobeBuilder, OutputFormat};
use ffprobe_rs::format::presets;
use ffmpeg_common::StreamSpecifier;

// Detailed probe with specific options
let result = FFprobeBuilder::new()?
    .input("https://example.com/stream.m3u8")
    .show_format()
    .show_streams()
    .show_chapters()
    .count_frames(true)
    .select_streams(StreamSpecifier::Type(ffmpeg_common::StreamType::Video))
    .output_format(OutputFormat::Json)
    .pretty(true)
    .run()
    .await?;

// Get primary video stream
if let Some(video) = result.primary_video_stream() {
    println!("Video codec: {}", video.codec_name.as_deref().unwrap_or("unknown"));
    println!("Frame rate: {:.2} fps", video.frame_rate().unwrap_or(0.0));
    println!("Bit rate: {} bps", video.bit_rate_bps().unwrap_or(0));
}

Re-exports§

pub use builder::FFprobeBuilder;
pub use format::EscapeMode;
pub use format::OutputFormat;
pub use format::StringValidation;
pub use format::WriterOptions;
pub use types::ChapterInfo;
pub use types::ErrorInfo;
pub use types::FormatInfo;
pub use types::FrameInfo;
pub use types::IntervalPosition;
pub use types::PacketInfo;
pub use types::ProbeResult;
pub use types::ProbeSection;
pub use types::ProgramInfo;
pub use types::ReadInterval;
pub use types::StreamInfo;

Modules§

builder
format
helpers
Helper functions for common probe operations
parsers
prelude
Prelude module for convenient imports
types

Structs§

Capabilities
Capabilities detection for FFmpeg tools
Duration
Represents a duration in FFmpeg format (HH:MM:SS.MS or seconds)
MediaPath
Input or output file/URL
Version
Version information for the FFmpeg suite

Enums§

Error
Main error type for FFmpeg suite operations
LogLevel
Log level for FFmpeg tools
StreamSpecifier
Represents a stream specifier in FFmpeg
StreamType
Stream type

Functions§

capabilities
Get FFprobe capabilities
get_version
Get version information for an FFmpeg executable
is_available
Check if FFprobe is available
probe
Quick probe a file for basic information
probe_format
Probe only format information
probe_streams
Probe only stream information
version
Get FFprobe version

Type Aliases§

Result
Result type for FFmpeg suite operations