Files
video_probe/docs/API.md
2026-03-11 01:47:34 +08:00

81 lines
1.5 KiB
Markdown

# 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<dyn std::error::Error>> {
// 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<VideoMetadata>
```
Probes a video file and returns metadata.
### probe_video_to_file
```rust
pub fn probe_video_to_file(video_path: &str) -> Result<String>
```
Probes a video and saves metadata to JSON file.
### save_metadata
```rust
pub fn save_metadata(video_path: &str, metadata: &VideoMetadata) -> Result<String>
```
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<Utc>
- `format`: FormatInfo
- `video_stream`: Option<VideoStream>
- `audio_streams`: Vec<AudioStream>
- `subtitle_streams`: Vec<SubtitleStream>