hello_world/hello_world.rs
1use ffmpeg_sidecar::command::FfmpegCommand;
2
3/// Iterates over the frames of a `testsrc`.
4///
5/// ```console
6/// cargo run --example hello_world
7/// ```
8fn main() -> anyhow::Result<()> {
9 // Run an FFmpeg command that generates a test video
10 let iter = FfmpegCommand::new() // <- Builder API like `std::process::Command`
11 .testsrc() // <- Discoverable aliases for FFmpeg args
12 .rawvideo() // <- Convenient argument presets
13 .spawn()? // <- Ordinary `std::process::Child`
14 .iter()?; // <- Blocking iterator over logs and output
15
16 // Use a regular "for" loop to read decoded video data
17 for frame in iter.filter_frames() {
18 println!("frame: {}x{}", frame.width, frame.height);
19 let _pixels: Vec<u8> = frame.data; // <- raw RGB pixels! 🎨
20 }
21
22 Ok(())
23}