#ffmpeg #multimedia #metadata #multimedia-metadata

rust_ffprobe

Safe and idiomatic Rust wrapper for FFprobe

2 releases (1 stable)

Uses new Rust 2024

1.0.0 Jul 19, 2025
0.1.0 Jul 19, 2025

#663 in Video

MIT/Apache

135KB
3K SLoC

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));
}

Dependencies

~10–17MB
~225K SLoC