From 75b5b05332fbfab2cf7bd91332e3715488e539d2 Mon Sep 17 00:00:00 2001 From: Warren Lo Date: Wed, 11 Mar 2026 01:42:24 +0800 Subject: [PATCH] Add lib.rs --- src/lib.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/lib.rs diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..70e0aa3 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,36 @@ +pub mod error; +pub mod metadata; +pub mod parser; +pub mod probe; +pub mod output; + +pub use error::{ProbeError, Result}; +pub use metadata::*; +pub use parser::parse_ffprobe_json; +pub use probe::run_ffprobe; +pub use output::{save_metadata, print_summary}; + +/// Convenience function to probe a video and get metadata +pub fn probe_video(video_path: &str) -> Result { + let json_output = run_ffprobe(video_path)?; + let metadata = parse_ffprobe_json(&json_output, video_path)?; + Ok(metadata) +} + +/// Convenience function to probe a video and save to file +pub fn probe_video_to_file(video_path: &str) -> Result { + let metadata = probe_video(video_path)?; + let output_file = save_metadata(video_path, &metadata)?; + Ok(output_file) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_probe_video_file_not_found() { + let result = probe_video("nonexistent.mp4"); + assert!(result.is_err()); + } +} \ No newline at end of file