Skip to main content

服务端渲染

Remotion 的渲染引擎是用 Node.JS 构建的,这使得在云端渲染视频变得容易。

🌐 Remotion's rendering engine is built with Node.JS, which makes it easy to render a video in the cloud.

查看SSR 选项比较以帮助你决定哪种选项最适合你。

🌐 See the Comparison of SSR options to help you decide which option is best for you.

在 AWS Lambda 上渲染视频

🌐 Render a video on AWS Lambda

在云端渲染视频最快的方法是使用 @remotion/lambda

🌐 The fastest way to render videos in the cloud is to use @remotion/lambda.

使用 Vercel Sandbox 渲染

🌐 Render using Vercel Sandbox

最简单的方法,特别是对于 Vercel 的客户,是使用 Vercel Sandbox

🌐 The easiest way, especially for Vercel customers is to use Vercel Sandbox.

使用 Node.js API 渲染视频

🌐 Render a video using Node.js APIs

我们提供一套使用 Node.js 和 Bun 渲染视频的 API。
更多信息请参见示例API参考

🌐 We provide a set of APIs to render videos using Node.js and Bun.
See an example or the API reference for more information.

使用 GitHub Actions 渲染

🌐 Render using GitHub Actions

你可以在 GitHub Actions 上渲染视频。以下工作流程假设作曲 ID 为 MyComp

🌐 You can render a video on GitHub actions. The following workflow assumes a composition ID of MyComp

name: Render video
on:
  workflow_dispatch:
jobs:
  render:
    name: Render video
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main
      - uses: actions/setup-node@main
      - run: npm i
      - run: npx remotion render MyComp out/video.mp4
      - uses: actions/upload-artifact@v4
        with:
          name: out.mp4
          path: out/video.mp4

带输入属性

🌐 With input props

如果你有属性,你可以使用 GitHub Actions 的输入字段来请求它们。
这里我们假设形状为 {titleText: string; titleColor: string}

🌐 If you have props, you can ask for them using the GitHub Actions input fields.
Here we assume a shape of {titleText: string; titleColor: string}.

name: Render video
on:
  workflow_dispatch:
    inputs:
      titleText:
        description: 'Which text should it say?'
        required: true
        default: 'Welcome to Remotion'
      titleColor:
        description: 'Which color should it be in?'
        required: true
        default: 'black'
jobs:
  render:
    name: Render video
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main
      - uses: actions/setup-node@main
      - run: npm i
      - run: echo $WORKFLOW_INPUT > input-props.json
        env:
          WORKFLOW_INPUT: ${{ toJson(github.event.inputs) }}
      - run: npx remotion render MyComp out/video.mp4 --props="./input-props.json"
      - uses: actions/upload-artifact@v4
        with:
          name: out.mp4
          path: out/video.mp4

将模板提交到 GitHub 仓库。
2
在 GitHub 上,点击 Actions 标签。
3
在左侧选择 Render video 工作流。
4
应该会出现一个 Run workflow 按钮。点击它。
5
填写根组件的属性,然后点击 Run workflow
6
渲染完成后,你可以在 Artifacts 下下载视频。

请注意,运行工作流可能会产生费用。然而,工作流只有在你主动触发时才会运行。

🌐 Note that running the workflow may incur costs. However, the workflow will only run if you actively trigger it.

另请参阅:在 GitHub Actions 中传递输入参数

🌐 See also: Passing input props in GitHub Actions

使用 Docker 渲染视频

🌐 Render a video using Docker

参见:将 Remotion 项目容器化

🌐 See: Dockerizing a Remotion project

使用 GCP Cloud Run(Alpha)渲染视频

🌐 Render a video using GCP Cloud Run (Alpha)

查看实验性的 Cloud Run 包。 注意:它目前没有积极开发——我们的计划是将 Lambda 运行时移植到 Cloud Run,而不是维护一个单独的实现。

🌐 Check out the experimental Cloud Run package.
Note: It not actively being developed - our plan is to port the Lambda runtime to Cloud Run instead of maintaining a separate implementation.

API 参考

🌐 API reference