Add lib.rs
This commit is contained in:
36
src/lib.rs
Normal file
36
src/lib.rs
Normal file
@@ -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<metadata::VideoMetadata> {
|
||||
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<String> {
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user