metadata/
metadata.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
use ffmpeg_sidecar::{command::FfmpegCommand, event::{FfmpegEvent, FfmpegProgress}};

/// Add metadata to a video file, with progress updates and FFmpeg log output.
fn main() {
  let mut ffmpeg_runner = FfmpegCommand::new()
    .testsrc()
    .args(["-metadata", "title=some cool title"])
    .overwrite() // -y
    .output("output/metadata.mp4")
    .print_command()
    .spawn()
    .unwrap();

  ffmpeg_runner
    .iter()
    .unwrap()
    .for_each(|e| {
      match e {
        FfmpegEvent::Progress(FfmpegProgress { frame, .. }) =>
          println!("Current frame: {frame}"),
        FfmpegEvent::Log(_level, msg) =>
          println!("[ffmpeg] {msg}"),
        _ => {}
      }
    });
}