use std::path::Path;
use std::process::Command;
use anyhow::Result;
use ffprobe::{Config as FfprobeConfig, FfProbe, ffprobe_config};
pub fn check_ffprobe_available() -> Result<()> {
match Command::new("ffprobe").arg("-version").output() {
Ok(output) if output.status.success() => Ok(()),
_ => {
log::warn!(
"ffprobe not found. Skipping video/audio metadata extraction.\n\
Install FFmpeg (includes ffprobe) for full media metadata support:\n\
https://ffmpeg.org/download.html"
);
Err(anyhow::anyhow!("ffprobe not available"))
}
}
}
pub fn run_ffprobe_safe(file_path: impl AsRef<Path>) -> Result<FfProbe> {
let config = FfprobeConfig::builder().build();
ffprobe_config(config, file_path).map_err(|e| anyhow::anyhow!("ffprobe failed: {e}"))
}