在 Supabase 中使用 Remotion Lambda
此页面展示了如何从 Supabase Edge Function 触发 Remotion Lambda 渲染。
除此之外,使用 Remotion Lambda 的步骤与Remotion Lambda 设置中描述的相同。
🌐 This page shows how to trigger a Remotion Lambda render from a Supabase Edge Function.
Other than that, the steps to use Remotion Lambda are the same as described in the Remotion Lambda setup.
从 Supabase Edge Functions 调用 Remotion Lambda 渲染v4.0.265
🌐 Invoking a Remotion Lambda render from Supabase Edge Functionsv4.0.265
在你的 Supabase Edge Functions 项目中安装 @remotion/lambda-client 包:
🌐 Install the @remotion/lambda-client package in your Supabase Edge Functions project:
deno add @remotion/lambda-client@4.0.265将 4.0.265 替换为你使用的 Remotion 版本。
🌐 Replace 4.0.265 with the version of Remotion you are using.
设置环境变量 AWS_ACCESS_KEY_ID、AWS_SECRET_ACCESS_KEY:
🌐 Set the environment variable AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY:
supabase/functions/.envAWS_ACCESS_KEY_ID=xxx AWS_SECRET_ACCESS_KEY=xxx
supabase/functions/trigger-render.tsimport 'jsr:@supabase/functions-js/edge-runtime.d.ts'; // FIXME: Replace 4.0.265 with the version of Remotion you are using. import {renderMediaOnLambda} from 'npm:@remotion/lambda-client@4.0.265'; Deno.serve(async (req) => { const {props} = await req.json(); try { const response = await renderMediaOnLambda({ serveUrl: 'https://remotion-helloworld.vercel.app', composition: 'HelloWorld', codec: 'h264', // FIXME: Replace with your AWS region region: 'eu-central-1', // FIXME: Add your function specs here functionName: speculateFunctionName({ memorySizeInMb: 2048, diskSizeInMb: 2048, timeoutInSeconds: 120, }), inputProps: props, }); return new Response(JSON.stringify(response), {headers: {'Content-Type': 'application/json'}}); } catch (error) { console.error(error); return new Response(JSON.stringify({error: (error as Error).message}), {headers: {'Content-Type': 'application/json'}, status: 500}); } });
确保解决这三个 FIXME 注释。
🌐 Make sure to resolve the three FIXME comments.
将你的渲染存储在 Supabase 存储中v4.0.259
🌐 Storing your renders in Supabase Storagev4.0.259
创建一个 Supabase 存储桶并设置环境变量 SUPABASE_ACCESS_KEY_ID、SUPABASE_SECRET_ACCESS_KEY。
🌐 Create a Supabase Storage bucket and set the environment variables SUPABASE_ACCESS_KEY_ID, SUPABASE_SECRET_ACCESS_KEY.
使用 s3OutputProvider 将渲染的视频存储在 Supabase Storage 中:
🌐 Use an s3OutputProvider to store the rendered video in Supabase Storage:
const {bucketName , renderId , cloudWatchMainLogs } = await renderMediaOnLambda ({
serveUrl : 'https://remotion-helloworld.vercel.app',
// FIXME: Add your function specs here
functionName : speculateFunctionName ({
diskSizeInMb : 2048,
memorySizeInMb : 2048,
timeoutInSeconds : 120,
}),
composition : 'HelloWorld',
// FIXME: Replace with your AWS region
region : 'eu-central-1',
codec : 'h264',
outName : {
// FIXME: Use the bucket name from your Supabase Storage settings
bucketName : 'remotion-test-bucket',
key : 'out.mp4',
s3OutputProvider : {
// FIXME: Use the endpoint from your Supabase Storage settings
endpoint : 'https://kudbuxgvpedqabsivqjz.supabase.co/storage/v1/s3',
// FIXME: Use the Access Key from your Supabase Storage settings
accessKeyId : process .env .SUPABASE_ACCESS_KEY_ID ?? '',
// FIXME: Use the Secret Access Key from your Supabase Storage settings
secretAccessKey : process .env .SUPABASE_SECRET_ACCESS_KEY ?? '',
// FIXME: Use the region from your Supabase Storage settings
region : 'eu-central-1',
forcePathStyle : true,
},
},
});另请参阅
🌐 See also