1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
//! # ff-probe
//!
//! Media file metadata extraction - the Rust way.
//!
//! This crate provides functionality for extracting metadata from media files,
//! including video streams, audio streams, and container information. It serves
//! as the Rust equivalent of ffprobe with a clean, idiomatic API.
//!
//! ## Module Structure
//!
//! - `error` - Error types ([`ProbeError`])
//! - `probe` - Media info extraction ([`open`])
//!
//! ## Quick Start
//!
//! ```no_run
//! use ff_probe::open;
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let info = open("video.mp4")?;
//!
//! println!("Format: {}", info.format());
//! println!("Duration: {:?}", info.duration());
//!
//! // Check for video stream
//! if let Some(video) = info.primary_video() {
//! println!("Video: {}x{} @ {:.2} fps",
//! video.width(),
//! video.height(),
//! video.fps()
//! );
//! }
//!
//! // Check for audio stream
//! if let Some(audio) = info.primary_audio() {
//! println!("Audio: {} Hz, {} channels",
//! audio.sample_rate(),
//! audio.channels()
//! );
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Extracting Detailed Information
//!
//! ```no_run
//! use ff_probe::{open, ColorSpace, ColorPrimaries};
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let info = open("hdr_video.mp4")?;
//!
//! // Enumerate all video streams
//! for (i, stream) in info.video_streams().iter().enumerate() {
//! println!("Video stream {}: {} {}x{}",
//! i, stream.codec_name(), stream.width(), stream.height());
//! println!(" Color space: {:?}", stream.color_space());
//! println!(" Color range: {:?}", stream.color_range());
//!
//! // Check for HDR content
//! if stream.color_primaries() == ColorPrimaries::Bt2020 {
//! println!(" HDR content detected!");
//! }
//!
//! if let Some(bitrate) = stream.bitrate() {
//! println!(" Bitrate: {} kbps", bitrate / 1000);
//! }
//! }
//!
//! // Enumerate all audio streams
//! for (i, stream) in info.audio_streams().iter().enumerate() {
//! println!("Audio stream {}: {} {} Hz, {} ch",
//! i, stream.codec_name(), stream.sample_rate(), stream.channels());
//! if let Some(lang) = stream.language() {
//! println!(" Language: {}", lang);
//! }
//! }
//!
//! // Access container metadata
//! if let Some(title) = info.title() {
//! println!("Title: {}", title);
//! }
//! if let Some(artist) = info.artist() {
//! println!("Artist: {}", artist);
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Error Handling
//!
//! The crate provides detailed error types through [`ProbeError`]:
//!
//! ```
//! use ff_probe::{open, ProbeError};
//!
//! let result = open("/nonexistent/path.mp4");
//!
//! match result {
//! Err(ProbeError::FileNotFound { path }) => {
//! println!("File not found: {}", path.display());
//! }
//! Err(ProbeError::CannotOpen { path, reason }) => {
//! println!("Cannot open {}: {}", path.display(), reason);
//! }
//! Err(ProbeError::InvalidMedia { path, reason }) => {
//! println!("Invalid media {}: {}", path.display(), reason);
//! }
//! Err(e) => println!("Other error: {}", e),
//! Ok(info) => println!("Opened: {}", info.format()),
//! }
//! ```
//!
//! ## Features
//!
//! - Extract container format information (MP4, MKV, AVI, etc.)
//! - List all video and audio streams with detailed properties
//! - Get codec parameters (codec type, pixel format, sample format)
//! - Read container and stream metadata (title, artist, etc.)
//! - Color space and HDR information (BT.709, BT.2020, etc.)
//! - Bitrate extraction and calculation
//! - Duration and frame count information
// Re-export types from ff-format for convenience
pub use ;
pub use ProbeError;
// Re-export the open function at the crate level
pub use open;
/// Prelude module for convenient imports.
///
/// This module re-exports all commonly used types for easy access:
///
/// ```no_run
/// use ff_probe::prelude::*;
///
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let info = open("video.mp4")?;
///
/// // Access stream information
/// if let Some(video) = info.primary_video() {
/// let _codec: VideoCodec = video.codec();
/// let _color: ColorSpace = video.color_space();
/// }
///
/// Ok(())
/// }
/// ```