ffmpeg_sidecar/
lib.rs

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
//! Wrap a standalone FFmpeg binary in an intuitive Iterator interface.
//!
//! ## Example
//!
//! ```rust
//! use ffmpeg_sidecar::{command::FfmpegCommand, event::FfmpegEvent};
//!
//!fn main() -> anyhow::Result<()> {
//!  FfmpegCommand::new() // <- Builder API like `std::process::Command`
//!      .testsrc() // <- Discoverable aliases for FFmpeg args
//!      .rawvideo() // <- Convenient argument presets
//!      .spawn()? // <- Uses an ordinary `std::process::Child`
//!      .iter()? // <- Iterator over all log messages and video output
//!      .for_each(|event: FfmpegEvent| {
//!        match event {
//!          FfmpegEvent::OutputFrame(frame) => {
//!            println!("frame: {}x{}", frame.width, frame.height);
//!            let _pixels: Vec<u8> = frame.data; // <- raw RGB pixels! 🎨
//!          }
//!          FfmpegEvent::Progress(progress) => {
//!            eprintln!("Current speed: {}x", progress.speed); // <- parsed progress updates
//!          }
//!          FfmpegEvent::Log(_level, msg) => {
//!            eprintln!("[ffmpeg] {}", msg); // <- granular log message from stderr
//!          }
//!          FfmpegEvent::ParsedInputStream(stream) => {
//!            if let Some(video_data) = stream.video_data() {
//!              println!(
//!                "Found video stream with index {} in input {} that has fps {}, width {}px, height {}px.",
//!                stream.stream_index,
//!                stream.parent_index,
//!                video_data.fps,
//!                video_data.width,
//!                video_data.height
//!              );
//!            }
//!          }
//!          _ => {}
//!        }
//!      });
//!  Ok(())
//!}
//! ```
//!

#[cfg(test)]
mod test;

pub mod child;
pub mod comma_iter;
pub mod command;
pub mod download;
pub mod event;
pub mod ffprobe;
pub mod iter;
pub mod log_parser;
pub mod metadata;
pub mod paths;
pub mod pix_fmt;
pub mod read_until_any;
pub mod version;

#[cfg(feature = "named_pipes")]
pub mod named_pipes;