Skip to main content

安装 Chrome v4.0.247

🌐 Installing Chrome v4.0.247

Remotion 正在自动将“Chrome 无头浏览器”安装到你的 node_modules 中,以便渲染视频。

🌐 Remotion is automatically installing "Chrome Headless Shell" into your node_modules in order to render videos.

支持的平台

🌐 Supported platforms

支持以下平台:

🌐 The following platforms are supported:

  • macOS(x64 和 arm64)
  • Windows(x64)
  • Linux x64 - 安装 Linux 依赖
  • Linux arm64 - 仅用于“Chrome 无头浏览器”

确保已安装 Chrome

🌐 Ensure Chrome is installed

有两种方法可以确保已安装 Chrome 无头浏览器:

🌐 There are two ways to ensure Chrome Headless Shell is installed:

建议在进行服务器端渲染时调用这些函数。这样,如果有请求想要渲染视频,浏览器已经下载好了并可以直接使用。

🌐 It is recommended use call these functions if you do server-side rendering.
That way, if a request comes in wanting to render a video, the browser is already downloaded and ready to go.

改用 Chrome 进行测试

🌐 Using Chrome for Testing instead

Remotion 可以用来渲染视频的有两种模式("模式"):

🌐 There are two flavors ("modes") that Remotion can use to render videos:

  • Chrome 无头浏览器:对于 CPU 密集型视频渲染更快,并且所需的依赖和设置更少。
  • 用于测试的 Chrome:对于 GPU 受限的视频渲染更快。模拟一个显示表面,因此需要更多的依赖和资源。

你应该仅在希望在 Linux 上设置 GPU 加速渲染环境 时使用 Chrome 进行测试。

🌐 You should use Chrome for Testing only if you want to set up a GPU-accelerated rendering environment on Linux.

为了改用 Chrome 进行测试:

🌐 In order to use Chrome for testing instead:

在 CLI 中:将 --chrome-mode="chrome-for-testing" 传递给 npx remotion rendernpx remotion benchmarknpx remotion compositionsnpx remotion stillnpx remotion gpunpx remotion browser ensure

使用 API:将 chromeMode: 'chrome-for-testing' 传递给你的 renderFrames()renderMedia()renderStill()selectComposition()getComposition()ensureBrowser() 调用。

在工作室中:在“高级”选项卡的“Chrome 模式”下拉菜单中选择“用于测试的 Chrome”。

在配置文件中(仅适用于 CLI 和 Studio):在你的 remotion.config.ts 文件中设置 Config.setChromeMode('chrome-for-testing')

在 Lambda 和 Cloud Run 中:不适用,因为不支持 Chrome for Testing。

下载位置

🌐 Download location

Chrome 无头浏览器将下载到此文件夹:

🌐 Chrome Headless Shell will download to this folder:

node_modules/.remotion/chrome-headless-shell/[platform]/chrome-headless-shell-[platform]

将创建一个可执行文件 ./chrome-headless-shell(在 Windows 上为 .\chrome-headless-shell.exe)。

🌐 An executable ./chrome-headless-shell (.\chrome-headless-shell.exe on Windows) will be created.


用于测试的 Chrome 将下载到此文件夹:

🌐 Chrome for Testing will download to this folder:

node_modules/.remotion/chrome-for-testing/[platform]

此文件夹内的文件结构因操作系统而异。

🌐 The file structure inside this folder varies by OS.


platform 可以是 mac-arm64mac-x64linux64linux-arm64win64

版本跟踪v4.0.415

🌐 Version trackingv4.0.415

Remotion 会在下载文件夹中写入一个 VERSION 文件,以跟踪安装了哪个 Chrome 版本:

🌐 Remotion writes a VERSION file to the download folder to track which Chrome version is installed:

node_modules/.remotion/chrome-headless-shell/VERSION
node_modules/.remotion/chrome-for-testing/VERSION

该文件包含 Chrome 版本字符串,例如 144.0.7559.20

🌐 The file contains the Chrome version string, e.g. 144.0.7559.20.

如果 VERSION 文件缺失(例如从旧版本的 Remotion 升级时)或与预期版本不匹配,Remotion 将删除现有浏览器并下载正确的版本。

🌐 If the VERSION file is missing (e.g. when upgrading from an older version of Remotion) or does not match the expected version, Remotion will delete the existing browser and download the correct version.

自带二进制文件

🌐 Bring your own binary

如果你不希望安装 Chrome Headless Shell 或 Chrome for Testing,或者你的平台不受支持,你需要指定你自己的基于 Chromium 的浏览器:

🌐 If you don't want Chrome Headless Shell or Chrome for Testing to get installed or your platform is not supported, you need to specify your own Chromium-based browser:

LambdaCloud Run 中,已经安装了一个版本的 Chrome,所以你无需做任何操作。

🌐 In Lambda and Cloud Run, a version of Chrome is already installed, so you don't need to do anything.

note

在未来版本的 Chrome 中,桌面浏览器的无头模式将不再受支持,你需要使用 Chrome 无头壳。

为什么 Remotion 要管理 Chrome?

🌐 Why does Remotion manage Chrome?

Remotion 之前使用的是许多用户已经安装的桌面版 Chrome。这个工作流程在某个时候中断了,因为 Chrome 移除了无头模式,并将其提取到了“Chrome Headless Shell”。

🌐 Remotion previously used the desktop version of Chrome that many users had already installed.
This workflow broke at some point, because Chrome removed the headless mode and extracted it to "Chrome Headless Shell".

最佳实践

🌐 Best practices

为了确保你的项目不因即将到来的 Chrome 变更而中断,你应该使用 Remotion 机制,该机制使用并固定 Chrome Headless Shell 的版本。

🌐 To ensure your project does not get disrupted by an upcoming Chrome change, you should use the Remotion mechanisms which uses and pins the version of Chrome Headless Shell.

  • 使用 Remotion v4.0.208 或更高版本,以避免使用外部安装的浏览器。
  • 使用 npx remotion browser ensure 以确保 Chrome Headless Shell 可用。
  • 不要在你的 Dockerfile 中下载 Chrome,但如果你使用的是 Linux,请安装 Linux 依赖
  • 不要使用 --browser-executablebrowserExecutablesetBrowserExecutable() 选项来用不兼容的 Chrome 版本覆盖无头浏览器。
warning

注意:大多数 Linux 发行版不允许你固定 Chrome 软件包。 如果你使用的 Remotion 版本低于 v4.0.208,你的 Chrome 可能会被自动升级到不带无头模式的版本,从而存在风险。

什么是 Chrome 无头模式?

🌐 What is Chrome Headless Shell?

Chrome 以前附带一个 --headless 标志,Remotion 会使用它。

🌐 Chrome used to ship with a --headless flag, which Remotion would use.

截至 Chrome 123,无头模式被划分为:

🌐 As of Chrome 123, the headless mode is split up into:

  • --headless=old,非常适合截图(因此也适合 Remotion)
  • --headless=new,非常适合浏览器测试

--headless=old将在未来版本的Chrome中停止工作。 旧的无头模式正在被提取到“Chrome Headless Shell”中。

因此,我们鼓励你使用 Chrome Headless Shell 来为你的 Remotion 应用做好未来准备。

🌐 Hence we encourage you to use Chrome Headless Shell to future-proof your Remotion application.

版本

🌐 Version

Remotion 将下载经过充分测试的 Chrome 版本:

🌐 Remotion will download a well-tested Chrome version:

Remotion 版本Chrome 版本
从 4.0.414144.0.7559.97
从 4.0.315134.0.6998.35(在 Lambda 上跳过)
从 4.0.274133.0.6943.141
从 4.0.245123.0.6312.86

升级可能会在补丁版本中进行,并会在此处列出。

🌐 Upgrades may happen in a patch release and will be listed here.

更改 Chrome 版本

🌐 Changing the Chrome version

在 Lambda 上,无法更改 Chrome 版本。

🌐 On Lambda, it is not possible to change the Chrome version.

如果你使用 server-side rendering APIs,请在 ensureBrowser() 中使用回调来更改 Chrome 版本。

🌐 If you use the server-side rendering APIs, use the callback in ensureBrowser() to change the Chrome version.

关于 Lambda 和 Cloud Run

🌐 On Lambda and Cloud Run

如果你正在使用 Remotion LambdaCloud Run,你无需担心安装浏览器——它已经包含在运行时中。

🌐 If you are using Remotion Lambda or Cloud Run, you don't need to worry about installing a browser - it is included in the runtime already.

之前的更改

🌐 Previous changes

添加了安装用于测试的 Chrome 选项(v4.0.247)

🌐 Added option to install Chrome for Testing (v4.0.247)

为了在 Linux 上启用 GPU 加速工作负载,Remotion 现在允许你安装用于测试的 Chrome。

🌐 In order to enable GPU-accelerated workloads on Linux, Remotion now allows you to install Chrome for Testing.

已迁移到 Chrome 无头浏览器

🌐 Migrated to Chrome Headless Shell

由于 Chrome 从桌面浏览器中移除了无头模式,Remotion 现在使用 Chrome 无头壳。

🌐 Because Chrome removed the headless mode from the desktop browser, Remotion now uses Chrome Headless Shell.

钍 (v4.0.18 - v4.0.135)

🌐 Thorium (v4.0.18 - v4.0.135)

在这些版本中,如果找不到本地浏览器,则会下载一个 Thorium 实例。

🌐 In these versions, if no local browser can be found, an instance of Thorium is downloaded.

Thorium 是一个免费的开源浏览器,从 Chromium 分支而来,它包含渲染视频所需的编解码器。

🌐 Thorium is a free and open-source browser forked off Chromium, which includes the codecs needed to render videos.

Chromium(v4.0.18 之前)

🌐 Chromium (before v4.0.18)

在以前的版本中,Remotion 会下载 Chromium 的免费版本,该版本不包含专有的 H.264 和 H.265 编解码器。这通常会在使用 <Html5Video> 标签时导致问题。

🌐 In previous versions, Remotion would download the free version of Chromium, which would not include codecs for the proprietary H.264 and H.265 codecs. This would often lead to problems when using the <Html5Video> tag.

另请参阅

🌐 See also