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

ffmpeg-cli

封装了ffpmeg命令行工具,使用-progress报告进度

1个不稳定版本

0.1.0 2021年4月11日

多媒体类别中排名第250

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

每月下载量73

GPL-2.0-or-later

20KB
277 代码行

封装了ffpmeg命令行工具,使用-progress报告进度

有时候你只是想简单使用ffmpeg。大多数crate都使用ffi,导致接口复杂。ffmpeg_cli通过封装命令行,避免了这种情况,当你不需要真实ffmpeg API提供的灵活性时。

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()
    );
}

依赖关系

~3–12MB
~131K SLoC