Skip to main content

安装 FFmpeg

info

自 Remotion v4.0 起,Remotion 内置了轻量版的 FFmpeg。无需再单独安装 FFmpeg。

Remotion V3 中的 FFmpeg

🌐 FFmpeg in V3 of Remotion

以下文档是关于 FFmpeg 在 v3.0 版本中工作方式的档案记录。

Remotion 需要 FFmpeg 来编码视频。从 v3.3 起,你无需手动安装 FFmpeg。本页面记录了 Remotion 的行为,供需要高级控制的开发者参考。

🌐 Remotion requires FFmpeg to encode videos. Since v3.3, you do not need to install FFmpeg manually. This page documents the behavior of Remotion for developers needing advanced control.

ffmpegffprobe

🌐 ffmpeg and ffprobe

Remotion 需要两个二进制文件:ffmpegffprobe。在文档中提到 FFmpeg 时,也可能指 FFprobe。

🌐 Two binaries are required for Remotion: ffmpeg and ffprobe. When talking about FFmpeg in the documentation, it may also refer to FFprobe.

自动安装

🌐 Auto-install

当渲染视频时,如果找不到二进制文件,Remotion 会从互联网下载它们并将其放入你的 node_modules 文件夹中。该二进制文件不会被添加到你的 PATH,所以如果你在终端中输入 ffmpeg,可能找不到它。然而,Remotion 仍然可以使用它

🌐 When rendering a video and binaries are not found, Remotion will download them from the internet and put it inside your node_modules folder. The binary will not get added to your PATH, so if you type in ffmpeg into your Terminal, it may not be found. However, Remotion will be able to use it

支持的架构

🌐 Supported architectures

以下平台支持自动安装:

🌐 Auto-install is supported on the following platforms:

  • Linux,x86_64,
  • macOS,英特尔
  • macOS,Apple Silicon
  • Windows,x86_64

对于其他平台,你需要提供自己的二进制文件。

🌐 For other platforms, you need to supply your own binaries.

触发自动安装

🌐 Triggering auto-install

通过渲染视频,将自动触发 FFmpeg 的下载。

🌐 By rendering a video, the download of FFmpeg will be triggered automatically.

在服务器上,在第一次渲染之前安装二进制文件可能会有用,这样在第一次渲染开始后就不会浪费时间。

🌐 On servers, it might be of use to install the binaries before the first render, so no time is wasted once the first render begins.

  • 使用 CLI,你可以运行 npx remotion install ffmpegnpx remotion install ffprobe 来触发二进制文件的自动安装。如果二进制文件已存在,该命令将不执行任何操作。这需要安装 @remotion/cli
  • [@remotion/renderer](/docs/renderer) 包暴露了 [ensureFfmpeg()](/docs/renderer/ensure-ffmpeg)[ensureFfprobe()](/docs/renderer/ensure-ffprobe) 函数

优先顺序

🌐 Order of priority

如果提供了多个二进制文件,它们的优先顺序如下:

🌐 In case of multiple binaries being supplied, they priority order is the following:

  • 如果使用 ffmpegExecutableffprobeExecutable 选项提供了二进制文件,将会使用它。
  • 如果 ffmpegffprobePATH 中,它将被使用。
  • 如果二进制文件之前被 Remotion 安装到 node_modules,它将被使用。
  • 如果可以从互联网上下载二进制文件,Remotion 将会下载并使用它。
  • 如果使用上述逻辑未找到二进制文件,则失败。