From 38a593337502fd940bf89656e307d2973e5da7e1 Mon Sep 17 00:00:00 2001 From: Warren Lo Date: Wed, 11 Mar 2026 01:47:34 +0800 Subject: [PATCH] Add API.md --- docs/API.md | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 docs/API.md diff --git a/docs/API.md b/docs/API.md new file mode 100644 index 0000000..6993a14 --- /dev/null +++ b/docs/API.md @@ -0,0 +1,81 @@ +# API Documentation + +This document provides API documentation for using video_probe as a library. + +## Installation + +Add to your Cargo.toml: + +```toml +[dependencies] +video_probe = { path = "../video_probe" } +``` + +## Quick Start + +```rust +use video_probe::*; + +fn main() -> Result<(), Box> { + // Probe video + let metadata = probe_video("video.mp4")?; + + // Access metadata + println!("Duration: {} seconds", metadata.format.duration); + + if let Some(ref video) = metadata.video_stream { + println!("Resolution: {}x{}", video.width, video.height); + } + + // Save to file + let output_file = save_metadata("video.mp4", &metadata)?; + println!("Saved to: {}", output_file); + + Ok(()) +} +``` + +## Core Functions + +### probe_video + +```rust +pub fn probe_video(video_path: &str) -> Result +``` + +Probes a video file and returns metadata. + +### probe_video_to_file + +```rust +pub fn probe_video_to_file(video_path: &str) -> Result +``` + +Probes a video and saves metadata to JSON file. + +### save_metadata + +```rust +pub fn save_metadata(video_path: &str, metadata: &VideoMetadata) -> Result +``` + +Saves metadata to a JSON file. + +### print_summary + +```rust +pub fn print_summary(metadata: &VideoMetadata) +``` + +Prints formatted summary to console. + +## Data Structures + +### VideoMetadata + +- `video_path`: String +- `probed_at`: DateTime +- `format`: FormatInfo +- `video_stream`: Option +- `audio_streams`: Vec +- `subtitle_streams`: Vec \ No newline at end of file