downloadMedia()
将渲染的视频、音频或静态图片下载到调用此 API 的机器的磁盘上。
🌐 Downloads a rendered video, audio or still to the disk of the machine this API is called from.
如果你想让用户将结果下载到他们的机器上,请改用 renderMediaOnLambda() -> downloadBehavior。
🌐 If you want to let the user download a result to their machine, use renderMediaOnLambda() -> downloadBehavior instead.
import {downloadMedia } from '@remotion/lambda';
const {outputPath , sizeInBytes } = await downloadMedia ({
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参数
🌐 Arguments
一个具有以下属性的对象:
🌐 An object with the following properties:
region
渲染执行所在的AWS区域。
🌐 The AWS region in which the render has performed.
bucketName
渲染存储的桶名称。这应该是你用于 renderMediaOnLambda() 或 renderStillOnLambda() 的相同变量。
🌐 The bucket name in which the render was stored. This should be the same variable you used for renderMediaOnLambda() or renderStillOnLambda().
renderId
渲染的ID。你可以通过调用renderMediaOnLambda()或renderStillOnLambda()来获取此ID。
🌐 The ID of the render. You can retrieve this ID by calling renderMediaOnLambda() or renderStillOnLambda().
outPath
视频应该保存的位置。传递一个绝对路径,否则它将相对于你当前的工作目录解析。
🌐 Where the video should be saved. Pass an absolute path, or it will be resolved relative to your current working directory.
onProgress?
回调函数,会使用以下属性被调用:
🌐 Callback function that gets called with the following properties:
totalSize字节downloaded字节已下载percent相对进度介于 0 和 1 之间
customCredentials?v3.2.23
如果渲染保存到了不同的云,请传递一个具有与传递给renderMediaOnLambda()或renderStillOnLambda()相同的endpoint、accessKeyId和secretAccessKey的对象。
🌐 If the render was saved to a different cloud, pass an object with the same endpoint, accessKeyId and secretAccessKey as you passed to renderMediaOnLambda() or renderStillOnLambda().
signal?v4.0.406
一个AbortSignal,允许取消下载。
🌐 An AbortSignal that allows the download to be cancelled.
返回值
🌐 Return value
返回一个解析为具有以下属性的对象的 Promise:
🌐 Returns a promise resolving to an object with the following properties:
outputPath
文件保存的绝对路径。
🌐 The absolute path of where the file got saved.
sizeInBytes
文件的字节大小。
🌐 The size of the file in bytes.
兼容性
🌐 Compatibility
| Browsers | Servers | Environments | |||||||
|---|---|---|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | Node.js | Bun | Serverless Functions | ||||
另请参阅
🌐 See also