搜索插件、代码仓与 APP 分类

插件详情v0.3.0

ffmpeg_cli

从 Dart 运行 FFMPEG 命令行工具。

AndroidiOSmacOSWindowsLinux
近 30 天下载
657
喜欢数
49
Pub 分数
135

安装插件

flutter pub add ffmpeg_cli

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter/Dart 包,可直接从 Dart 代码执行 FFMPEG 命令行界面(CLI)命令。它提供了一种简单高效的方法,在多个平台上执行多媒体处理任务,如视频编码、音频提取、格式转换等。该包抽象了与原生 FFMPEG 二进制文件交互的复杂性,使 Flutter 应用程序中也能轻松使用。非常适合需要强大媒体操作功能但又无需编写平台特定代码的开发者。

适合场景

  • 视频格式转换
  • 从视频中提取音频
  • 媒体文件压缩
  • 多媒体文件的批量处理
  • 实时视频编码

主要特点

  • 跨平台支持
  • 简单的 CLI 命令执行
  • 与 Flutter 应用集成
  • 支持所有主要操作系统平台
  • 轻便且易于使用

适合对象

  • 开发媒体密集型应用的开发者
  • 需要视频/音频处理的应用程序
  • 内容创作者工具
  • 涉及多媒体的教育项目
  • 使用Flutter的后端服务

使用建议

  • 目标设备上需要 FFMPEG 二进制文件
  • 可能需要进行平台特定的设置
  • 由于 FFMPEG 依赖导致的大型二进制文件大小
  • 基本用法中的错误处理有限
  • 性能取决于设备硬件

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

FFMPEG CLI - Run FFMPEG CLI commands from Dart

Built by the Flutter Bounty Hunters



Check out our Usage Guide


What is FFMPEG?

FFMPEG is a very popular, longstanding tool for reading, writing, and streaming audio and video content. Most developers use FFMPEG through its command-line interface (CLI), because that's much easier than interfacing with the C code upon which FFMPEG is built.

What is ffmpeg_cli

This package allows you to configure FFMPEG CLI commands with Dart code.

ffmpeg_cli purposefully retains the complexity of FFMPEG commands so that anything the FFMPEG CLI can do, the ffmpeg_cli package can do.

Quickstart

First, make sure that ffmpeg is installed on your device, and is available on your system path.

Compose an FFMPEG command with Dart:

// Define an output stream, which will map the filter
// graph to the video file. The ID names can be whatever
// you'd like.
const outputStream = FfmpegStream(
  videoId: "[final_v]", 
  audioId: "[final_a]",
);

// Compose your desired FFMPEG command, with inputs, filters, arguments,
// and an output location.
final command = FfmpegCommand(
  inputs: [
    FfmpegInput.asset("assets/intro.mp4"),
    FfmpegInput.asset("assets/content.mp4"),
    FfmpegInput.asset("assets/outro.mov"),
  ],
  args: [
    // Map the filter graph to the video file output.
    CliArg(name: 'map', value: outputStream.videoId!),
    CliArg(name: 'map', value: outputStream.audioId!),
    const CliArg(name: 'vsync', value: '2'),
  ],
  filterGraph: FilterGraph(
    chains: [
      FilterChain(
        inputs: [
          // Send all 3 video assets into the concat filter.
          const FfmpegStream(videoId: "[0:v]", audioId: "[0:a]"),
          const FfmpegStream(videoId: "[1:v]", audioId: "[1:a]"),
          const FfmpegStream(videoId: "[2:v]", audioId: "[2:a]"),
        ],
        filters: [
          // Concatenate 3 segments.
          ConcatFilter(
            segmentCount: 3, 
            outputVideoStreamCount: 1, 
            outputAudioStreamCount: 1,
          ),
        ],
        outputs: [
          // Give the output stream the given audio/video IDs
          outputStream,
        ],
      ),
    ],
  ),
  outputFilepath: "/my/output/file.mp4",
);

// Execute command
final process = await Ffmpeg().run(command: command);

How ffprobe support is managed

There are a lot of properties in ffprobe. Many of these properties can present in varying formats, which are not effectively documented.

The approach to ffprobe is to add missing result parameters as they are discovered and to add parsing functionality per property as the various possible formats are discovered. In other words, only do what is necessary in the given moment because the overall scope is too large and difficult to discover.

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目

暂无相关数据。