Skip to main content

getRenderProgress()

获取通过 renderMediaOnLambda() 启动的渲染的当前状态。调用此函数会触发一次 Lambda 调用。

🌐 Gets the current status of a render initiated via renderMediaOnLambda().
Calling this function results in a Lambda invocation.

对于通过 renderStillOnLambda() 启动的渲染,请不要使用此功能。相反,结果会立即返回。

🌐 For renders initiated via renderStillOnLambda(), do not use this function. Instead, the result is returned immediately.

示例

🌐 Example

import {getRenderProgress} from '@remotion/lambda/client';

const progress = await getRenderProgress({
  renderId: 'd7nlc2y',
  bucketName: 'remotionlambda-d9mafgx',
  functionName: 'remotion-render-la8ffw',
  region: 'us-east-1',
});
note

最好从 @remotion/lambda/client 导入这个函数,以避免 在无服务器函数中 出现问题。

note

在渲染 still 时,你不需要调用这个函数。一旦你从 renderStillOnLambda() 中获得了 renderId,渲染应该已经完成了!

应用编程接口

🌐 API

通过传递具有以下属性的对象来调用该函数:

🌐 Call the function by passing an object with the following properties:

renderId

你想要获取进度的渲染的唯一标识符。你可以从renderMediaOnLambda()的返回值中获取renderId。

🌐 The unique identifier for the render that you want to get the progress for. You can get the renderId from the return value of renderMediaOnLambda().

bucketName

保存关于渲染信息的存储桶。你可以从 renderMediaOnLambda() 的返回值中获取存储桶名称。

🌐 The bucket in which information about the render is saved. You can get the bucket name from the return value of renderMediaOnLambda().

region

Lambda 函数所在的区域。

🌐 The region in which the Lambda function is located in.

functionName

触发渲染的函数名称。

🌐 The name of the function that triggered the render.

customCredentials?v3.2.23

如果渲染将要保存到不同的云,请传递一个包含与你传递给renderMediaOnLambda()renderStillOnLambda()相同的 endpointaccessKeyIdsecretAccessKey 的对象。

🌐 If the render is going to be saved to a different cloud, pass an object with the same endpoint, accessKeyId and secretAccessKey as you passed to renderMediaOnLambda() or renderStillOnLambda().

forcePathStyle?v4.0.202

forcePathStyle 传递给 AWS S3 客户端。如果你不知道这是什么,你很可能用不到它。

🌐 Passes forcePathStyle to the AWS S3 client. If you don't know what this is, you probably don't need it.

skipLambdaInvocation?v4.0.218

不要调用将从 S3 获取进度的 Lambda 函数,而是直接调用 S3。
这样更便宜也更快,但函数名必须遵循函数命名规范

🌐 Instead of calling a Lambda function which will get the progress from S3, make the S3 call directly.
This is cheaper and faster, but the function name must follow the function name convention.

Response

返回一个解析为具有以下属性的对象的 Promise:

🌐 Returns a promise resolving to an object with the following properties:

overallProgress

介于0和1之间的数字,表示渲染的近似进度。

🌐 A number between 0 and 1 indicating the approximate progress of the render.

chunks

到目前为止已经完全渲染了多少块。

🌐 How many chunks have been fully rendered so far.

done

true 如果视频已成功渲染并且所有进程已完成。否则为 false

encodingStatus

如果并非所有块都已渲染,则为 null,或者为一个具有签名 {framesEncoded: number} 的对象,用于说明在编码过程中已经编码了多少帧。

🌐 Either null if not all chunks have been rendered yet or an object with the signature {framesEncoded: number} that tells how many frames have been encoded so far in the encoding process.

renderId

镜像已作为输入传入的 renderId

🌐 Mirrors the renderId that has been passed as an input

renderMetadata

包含关于渲染的以下信息:

🌐 Contains the following information about the render:

  • frameRange:正在渲染的第一个和最后一个帧(使用 frameRange[1] - frameRange[0] + 1 获取渲染的总帧数)。
  • startedDate:渲染过程开始的时间戳。
  • totalChunks:渲染被分成多少部分。
  • estimatedTotalLambdaInvokations:总计 Lambda 函数调用的估计数量,不包括对 getRenderProgress() 的调用。
  • estimatedRenderLambdaInvokations:预计将渲染视频片段的 Lambda 数量。
  • compositionId:正在渲染的作品的ID。
  • codec:视频被编码成的所选编解码器。
  • dimensions:应用任何 scale 后,输出视频的尺寸。(从 v4.0.222 起可用)

bucket

渲染和其他资源会保存到哪个存储桶中。

🌐 In which bucket the render and other artifacts get saved.

outputFile

null 如果视频尚未渲染,string 如果视频渲染完成则包含指向最终产物的URL。

outKey

null 如果视频尚未渲染,则为包含最终工件存储的 S3 键的 string

timeToFinish

null 是视频尚未渲染,number 描述渲染完成所花费的时间(以毫秒为单位)。

errors

包含发生错误的数组。

🌐 An array which contains errors that occurred.

fatalErrorEncountered

true 如果发生错误且视频无法渲染。你应该停止轮询进度并检查 errors 数组。

currentTime

Lambda 函数响应进度请求的当前时间。

🌐 The current time at which the Lambda function responded to the progress request.

renderSize

由于此次渲染,已经向 S3 存储桶保存了多少字节。
从 v4.0.165 开始,由于未将 progress.json 文件计入,此值可能略有低报。

🌐 How many bytes have been saved to the S3 bucket as a result of this render.
From v4.0.165, this might be slightly underreported as the progress.json file is not factored in.

outputSizeInBytes

从 v.3.3.9 起可用

🌐 available from v.3.3.9

输出产物的大小(以字节为单位)。

🌐 The size of the output artifact in bytes.

lambdasInvoked

已经被调用并开始渲染某个块的 lambda 数量是多少。

🌐 How many lambdas that render a chunk have been invoked yet and have started rendering.

framesRendered

从 v3.3.8 起可用

🌐 available from v3.3.8

到目前为止已经渲染了多少帧,近似为可以被5整除的数字。

🌐 How many frames have been rendered so far, approximated to a number divisible by 5.

costs

一个描述到目前为止渲染成本的对象。如果渲染尚未完成,成本可能会增加。仅估算 AWS Lambda 的成本,而不包括 S3 存储费用。这是一个尽力而为的估算,但不提供任何保证。该对象具有以下属性:

🌐 An object describing the costs of the render so far. The cost may increase if the render has not finished yet. Only costs for AWS Lambda are estimated, not for S3 storage. It is a best-effort estimation, but without any guarantees. The object has the following properties:

  • accruedSoFar:成本为浮动数字。
  • currency:费用的货币。
  • displayCost:以字符串格式表示的成本。
  • disclaimer:文字免责声明,消除任何保证存在的疑虑。

estimatedBillingDurationInMillisecondsv4.0.74

所有被调用的 Lambda 函数总预计运行时间,单位为毫秒。随着渲染的进行,这个数字会增加。

🌐 The estimated total runtime of all invoked Lambda functions combined, in milliseconds. As the render goes on, this number increases.

mostExpensiveFrameRanges

如果渲染正在进行中,这是 null。如果渲染完成,它将是以下形状的 5 个最昂贵块的数组:

🌐 If the render is in progress, this is null. If the render is done, it is an array of the 5 most expensive chunks in the following shape:

  • chunk:块的索引(从0开始)
  • timeInMilliseconds:渲染那个块所花的时间
  • frameRange:一个包含该块中渲染的第一个和最后一个帧的元组。

artifactsv4.0.176

在渲染期间迄今为止创建的工件。在这里查看处理字段的示例。

🌐 Artifacts that were created so far during the render. See here for an example of dealing with field.

另请参阅

🌐 See also