downloadMedia()
从调用此 API 的机器上的磁盘下载渲染的视频、音频或静态图像。
如果您想让用户将结果下载到他们的机器上,请改用renderMediaOnLambda()
-> downloadBehavior
。
ts
import {downloadMedia } from "@remotion/lambda";const {outputPath ,sizeInBytes } = awaitdownloadMedia ({bucketName : "remotionlambda-r42fs9fk",region : "us-east-1",renderId : "8hfxlw",outPath : "out.mp4",onProgress : ({totalSize ,downloaded ,percent }) => {console .log (`Download progress: ${totalSize }/${downloaded } bytes (${(percent * 100).toFixed (0)}%)`);},});console .log (outputPath ); // "/Users/yourname/remotion-project/out.mp4"console .log (sizeInBytes ); // 21249541
ts
import {downloadMedia } from "@remotion/lambda";const {outputPath ,sizeInBytes } = awaitdownloadMedia ({bucketName : "remotionlambda-r42fs9fk",region : "us-east-1",renderId : "8hfxlw",outPath : "out.mp4",onProgress : ({totalSize ,downloaded ,percent }) => {console .log (`Download progress: ${totalSize }/${downloaded } bytes (${(percent * 100).toFixed (0)}%)`);},});console .log (outputPath ); // "/Users/yourname/remotion-project/out.mp4"console .log (sizeInBytes ); // 21249541
参数
一个具有以下属性的对象:
region
执行渲染的 AWS 区域。
bucketName
存储渲染的存储桶名称。这应该与您用于 renderMediaOnLambda()
或 renderStillOnLambda()
的相同变量。
renderId
渲染的 ID。您可以通过调用 renderMediaOnLambda()
或 renderStillOnLambda()
来检索此 ID。
outPath
视频应保存的位置。传递绝对路径,否则将相对于当前工作目录解析。
onProgress
可选
回调函数,带有以下属性:
totalSize
字节downloaded
下载的字节数percent
0 到 1 之间的相对进度
customCredentials
可选,从 v3.2.23 开始可用
如果渲染保存到不同的云,请传递一个具有与您传递给 renderMediaOnLambda()
或 renderStillOnLambda()
相同的 endpoint
、accessKeyId
和 secretAccessKey
的对象。
返回值
返回一个解析为具有以下属性的对象的 Promise:
outputPath
文件保存的绝对路径。
sizeInBytes
文件的字节大小。
参见
I'm ready to start the translation whenever you paste the Markdown content.