#ffmpeg #video #audio-video #file-input #audio

ffmpeg-cli

Wraps the ffpmeg cli, using -progress to report progress

1 unstable release

0.1.0 Apr 11, 2021

#250 in Multimedia

Download history 44/week @ 2024-03-11 23/week @ 2024-03-18 46/week @ 2024-03-25 100/week @ 2024-04-01 38/week @ 2024-04-08 31/week @ 2024-04-15 19/week @ 2024-04-22 14/week @ 2024-04-29 24/week @ 2024-05-06 18/week @ 2024-05-13 19/week @ 2024-05-20 11/week @ 2024-05-27 18/week @ 2024-06-03 14/week @ 2024-06-10 18/week @ 2024-06-17 21/week @ 2024-06-24

73 downloads per month

GPL-2.0-or-later

20KB
277 lines

Wraps the ffpmeg cli, using -progress to report progress

Sometimes you just want a simple way to use ffmpeg. Most crates just use ffi, leading to complicated interfaces. ffmpeg_cli avoids this by wrapping the cli, for when you don't need the flexibility the real ffmpeg api gives you.

use std::process::Stdio;

use ffmpeg_cli::{FfmpegBuilder, File, Parameter};
use futures::{future::ready, StreamExt};

#[tokio::main]
async fn main() {
    let builder = FfmpegBuilder::new()
        .stderr(Stdio::piped())
        .option(Parameter::Single("nostdin"))
        .option(Parameter::Single("y"))
        .input(File::new("input.mkv"))
        .output(
            File::new("output.mp4")
                .option(Parameter::KeyValue("vcodec", "libx265"))
                .option(Parameter::KeyValue("crf", "28")),
        );

    let ffmpeg = builder.run().await.unwrap();

    ffmpeg
        .progress
        .for_each(|x| {
            dbg!(x.unwrap());
            ready(())
        })
        .await;

    let output = ffmpeg.process.wait_with_output().unwrap();

    println!(
        "{}\nstderr:\n{}",
        output.status,
        std::str::from_utf8(&output.stderr).unwrap()
    );
}

Dependencies

~3–12MB
~131K SLoC