Skip to main content

自定义 Lambda 输出目的地

默认情况下,渲染产物会保存到与站点所在相同的 S3 存储桶中,键为 renders/${renderId}/out.{extension}(例如:renders/hy0k2siao8/out.mp4

🌐 By default a render artifact is saved into the same S3 bucket as where the site is located under the key renders/${renderId}/out.{extension} (for example: renders/hy0k2siao8/out.mp4)

你可以通过传递不同的文件名、将其写入不同的存储桶,甚至上传到不同的兼容 S3 的提供商来修改输出目标。

🌐 You can modify the output destination by passing a different filename, writing it into a different bucket or even upload it to a different S3-compatible provider.

自定义输出名称

🌐 Customizing the output name

要自定义输出文件名,请将 outName: "my-filename.mp4" 传递给 renderMediaOnLambda()renderStillOnLambda()

🌐 To customize the output filename, pass outName: "my-filename.mp4" to renderMediaOnLambda() or renderStillOnLambda().

在 CLI 上,使用 --out-name 标志。

🌐 On the CLI, use the --out-name flag.

输出名称必须与 /^([0-9a-zA-Z-!_.*'()/]+)$/g 匹配。

🌐 The output name must match /^([0-9a-zA-Z-!_.*'()/]+)$/g.

自定义输出存储桶

🌐 Customizing the output bucket

要渲染到不同的存储桶,请在 renderMediaOnLambda()renderStillOnLambda() 中指定 outName 选项,并传入一个包含 keybucketName 值的对象:

🌐 To render into a different bucket, specify the outName option to renderMediaOnLambda() or renderStillOnLambda() and pass an object with the key and bucketName values:


const {bucketName, renderId} = await renderMediaOnLambda({
  region: 'us-east-1',
  functionName: 'remotion-render-bds9aab',
  composition: 'MyVideo',
  serveUrl: 'https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw',
  inputProps: {},
  codec: 'h264',
  imageFormat: 'jpeg',
  maxRetries: 1,
  privacy: 'public',
  outName: {
    key: 'my-output',
    bucketName: 'output-bucket',
  },
});

如果你想使用此功能:

🌐 If you like to use this feature:

  • 你必须扩展 默认 Remotion 角色策略(而不是用户策略),以允许对该存储桶的读写访问。
  • 桶必须在同一地区。
  • 在调用诸如 downloadMedia()getRenderProgress() 的 API 时,你必须传入 bucketName,即站点所在的位置,而不是视频保存的存储桶。
  • key 必须与 /^([0-9a-zA-Z-!_.*'()/]+)$/g 匹配
  • bucketName 必须匹配 /^(?=^.{3,63}$)(?!^(\d+\.)+\d+$)(^(([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])$)/

此功能在命令行接口中不受支持。

🌐 This feature is not supported from the CLI.

保存到另一个云v3.2.23

🌐 Saving to another cloudv3.2.23

你可以将文件上传到另一个支持 S3 的提供商。

🌐 You can upload the file to another S3-compatible provider.

  • 工作提供者列表(不完全):

    • Supabase

    • Cloudflare

    • ✅ DigitalOcean 空间

    • ✅ 谷歌云存储 关于谷歌云存储的备注:

      • GCP 确实支持在存储桶名称中使用下划线,但我们会对此进行验证。请不要在存储桶名称中使用下划线。
      • 该存储桶需要具有统一的访问控制,而不是细粒度的访问控制。
      • 要获取你的 accessKeyIdsecretAccessKey,请创建一个具有 Cloud Storage 读写权限的服务账号。然后运行以下命令:
      gcloud storage hmac create insert_google_service_account_email --project=insert_project_id
  • 不支持的提供商列表(非详尽):

    • Azure Blob 存储(不兼容 S3)

你必须提交一个 outName 如上所述,并且还需要提供一个像下面示例中的 s3OutputProvider

🌐 You must pass an outName as specified above and also provide an s3OutputProvider like in the example below.


const {bucketName, renderId} = await renderMediaOnLambda({
  region: 'us-east-1',
  functionName: 'remotion-render-bds9aab',
  composition: 'MyVideo',
  serveUrl: 'https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw',
  inputProps: {},
  codec: 'h264',
  imageFormat: 'jpeg',
  maxRetries: 1,
  privacy: 'no-acl',
  outName: {
    key: 'my-output',
    bucketName: 'output-bucket',
    s3OutputProvider: {
      endpoint: 'https://fra1.digitaloceanspaces.com',
      accessKeyId: '<DIGITAL_OCEAN_ACCESS_KEY_ID>',
      secretAccessKey: '<DIGITAL_OCEAN_SECRET_ACCESS_KEY>',
    },
  },
});

在此示例中,输出文件将被上传到 DigitalOcean Spaces。云提供商将提供给你端点和凭证。

🌐 In this example, the output file will be uploaded to DigitalOcean Spaces. The cloud provider will give you the endpoint and credentials.

如果你想使用此功能,请注意以下事项:

🌐 If you want to use this feature, note the following:

此功能在命令行接口中不受支持。

🌐 This feature is not supported from the CLI.

保存到另一个 AWS 区域v4.0.112

🌐 Saving to another AWS regionv4.0.112

如果你计划将数据保存到 AWS S3 的另一个存储桶,并且希望使用不同的凭证,你可以在 s3OutputProvider 对象中指定 region

🌐 If you plan on saving to another bucket on AWS S3 and would like to use different credentials, you can specify the region in the s3OutputProvider object.

{
  "s3OutputProvider": {
    "endpoint": "https://s3.us-west-1.amazonaws.com",
    "accessKeyId": "<AWS_ACCESS_KEY_ID>",
    "secretAccessKey": "<AWS_SECRET_ACCESS_KEY>",
    "region": "us-west-1"
  }
}

请注意,如果你想使用已经分配给 Lambda 的相同角色,则无需提供自定义 s3OutputProvider
你可能需要扩展你的 角色策略 以允许写入此存储桶。

🌐 Note that it is not necessary to provide a custom s3OutputProvider if you want to use the same role as you already gave to the Lambda.
You may need to extend your role policy to allow writing to this bucket.

另请参阅

🌐 See also