progress/
progress.rs

1use ffmpeg_sidecar::command::FfmpegCommand;
2
3/// Output progress events from a standard ffmpeg command
4/// which writes to a file.
5///
6/// ```console
7/// cargo run --example progress
8/// ```
9fn main() {
10  let fps = 60;
11  let duration = 10;
12  let total_frames = fps * duration;
13  let arg_string = format!(
14    "-f lavfi -i testsrc=duration={}:size=1920x1080:rate={} -y output/test.mp4",
15    duration, fps
16  );
17  FfmpegCommand::new()
18    .args(arg_string.split(' '))
19    .spawn()
20    .unwrap()
21    .iter()
22    .unwrap()
23    .filter_progress()
24    .for_each(|progress| println!("{}%", (progress.frame * 100) / total_frames));
25}