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={duration}:size=1920x1080:rate={fps} -y output/test.mp4"
15 );
16 FfmpegCommand::new()
17 .args(arg_string.split(' '))
18 .spawn()
19 .unwrap()
20 .iter()
21 .unwrap()
22 .filter_progress()
23 .for_each(|progress| println!("{}%", (progress.frame * 100) / total_frames));
24}