How ffmpeg-sidecar works: The Iterator abstraction
mainThe core concept of ffmpeg-sidecar is to wrap the FFmpeg CLI and expose its output as a high-level Rust Iterator.
Instead of manually parsing CLI arguments or stderr logs, you use a builder API (similar to std::process::Command) to configure FFmpeg. When you call .spawn(), it returns a process handle that can be converted into an iterator via .iter(). This iterator allows you to loop over decoded video frames as raw RGB data, abstracting away the complexity of video decoding, container formats, and stream mappings.
let iter = FfmpegCommand::new()
.testsrc()
.rawvideo()
.spawn()?
.iter()?;
for frame in iter.filter_frames() {
// frame.data contains raw RGB pixels
}