🎥 Make videos programmatically with React
less options
Jonny Burger591a5e984af4
diff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda/src/api/render-media-on-lambda.tsindex e6e226bb46..0008ee447d 100644--- a/packages/lambda/src/api/render-media-on-lambda.ts+++ b/packages/lambda/src/api/render-media-on-lambda.ts@@ -118,38 +118,10 @@ export const internalRenderMediaOnLambdaRaw = async (}};-/**- * @description Triggers a render on a lambda given a composition and a lambda function.- * @see [Documentation](https://remotion.dev/docs/lambda/rendermediaonlambda)- * @param params.functionName The name of the Lambda function that should be used- * @param params.serveUrl The URL of the deployed project- * @param params.composition The ID of the composition which should be rendered.- * @param params.inputProps The input props that should be passed to the composition.- * @param params.codec The media codec which should be used for encoding.- * @param params.imageFormat In which image format the frames should be rendered. Default "jpeg"- * @param params.crf The constant rate factor to be used during encoding.- * @param params.envVariables Object containing environment variables to be inserted into the video environment- * @param params.proResProfile The ProRes profile if rendering a ProRes video- * @param params.jpegQuality JPEG quality if JPEG was selected as the image format.- * @param params.region The AWS region in which the media should be rendered.- * @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted. Default "1"- * @param params.logLevel Level of logging that Lambda function should perform. Default "info".- * @param params.webhook Configuration for webhook called upon completion or timeout of the render.- * @returns {Promise<RenderMediaOnLambdaOutput>} See documentation for detailed structure- */-export const renderMediaOnLambda = (+export const renderMediaOnLambdaOptionalToRequired = (options: RenderMediaOnLambdaInput,-): Promise<RenderMediaOnLambdaOutput> => {- const wrapped = NoReactAPIs.wrapWithErrorHandling(- internalRenderMediaOnLambdaRaw,- );- if (options.quality) {- throw new Error(- 'quality has been renamed to jpegQuality. Please rename the option.',- );- }-- return wrapped({+): InnerRenderMediaOnLambdaInput => {+ return {audioBitrate: options.audioBitrate ?? null,audioCodec: options.audioCodec ?? null,chromiumOptions: options.chromiumOptions ?? {},@@ -193,7 +165,41 @@ export const renderMediaOnLambda = (x264Preset: options.x264Preset ?? null,deleteAfter: options.deleteAfter ?? null,preferLossless: options.preferLossless ?? false,- });+ };+};++/**+ * @description Triggers a render on a lambda given a composition and a lambda function.+ * @see [Documentation](https://remotion.dev/docs/lambda/rendermediaonlambda)+ * @param params.functionName The name of the Lambda function that should be used+ * @param params.serveUrl The URL of the deployed project+ * @param params.composition The ID of the composition which should be rendered.+ * @param params.inputProps The input props that should be passed to the composition.+ * @param params.codec The media codec which should be used for encoding.+ * @param params.imageFormat In which image format the frames should be rendered. Default "jpeg"+ * @param params.crf The constant rate factor to be used during encoding.+ * @param params.envVariables Object containing environment variables to be inserted into the video environment+ * @param params.proResProfile The ProRes profile if rendering a ProRes video+ * @param params.jpegQuality JPEG quality if JPEG was selected as the image format.+ * @param params.region The AWS region in which the media should be rendered.+ * @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted. Default "1"+ * @param params.logLevel Level of logging that Lambda function should perform. Default "info".+ * @param params.webhook Configuration for webhook called upon completion or timeout of the render.+ * @returns {Promise<RenderMediaOnLambdaOutput>} See documentation for detailed structure+ */+export const renderMediaOnLambda = (+ options: RenderMediaOnLambdaInput,+): Promise<RenderMediaOnLambdaOutput> => {+ const wrapped = NoReactAPIs.wrapWithErrorHandling(+ internalRenderMediaOnLambdaRaw,+ );+ if (options.quality) {+ throw new Error(+ 'quality has been renamed to jpegQuality. Please rename the option.',+ );+ }++ return wrapped(renderMediaOnLambdaOptionalToRequired(options));};/**diff --git a/packages/lambda/src/test/integration/renders/gif.test.ts b/packages/lambda/src/test/integration/renders/gif.test.tsindex 62ff13cc9d..3e1a51a194 100644--- a/packages/lambda/src/test/integration/renders/gif.test.ts+++ b/packages/lambda/src/test/integration/renders/gif.test.ts@@ -4,6 +4,8 @@ import {tmpdir} from 'node:os';import path from 'node:path';import {VERSION} from 'remotion/version';import {afterAll, expect, test} from 'vitest';+import {makeLambdaRenderMediaPayload} from '../../../api/make-lambda-payload';+import {renderMediaOnLambdaOptionalToRequired} from '../../../api/render-media-on-lambda';import {LambdaRoutines} from '../../../defaults';import {lambdaReadFile} from '../../../functions/helpers/io';import {callLambda} from '../../../shared/call-lambda';@@ -17,54 +19,24 @@ test('Should make a distributed GIF', async () => {const res = await callLambda({type: LambdaRoutines.start,- payload: {- serveUrl:- 'https://64d3734a6bb69052c34d3616--spiffy-kelpie-71657b.netlify.app/',- chromiumOptions: {},- codec: 'gif',- composition: 'framer',- crf: 9,- envVariables: {},- // 61 frames, which is uneven, to challenge the frame planner- frameRange: [0, 60],- framesPerLambda: 8,- imageFormat: 'png',- inputProps: {- type: 'payload',- payload: '{}',- },- logLevel: 'error',- maxRetries: 3,- outName: 'out.gif',- pixelFormat: 'yuv420p',- privacy: 'public',- proResProfile: undefined,- x264Preset: null,- jpegQuality: undefined,- scale: 1,- timeoutInMilliseconds: 12000,- numberOfGifLoops: null,- everyNthFrame: 2,- concurrencyPerLambda: 1,- downloadBehavior: {type: 'play-in-browser'},- muted: false,- version: VERSION,- overwrite: true,- webhook: null,- audioBitrate: null,- videoBitrate: null,- encodingBufferSize: null,- encodingMaxRate: null,- forceHeight: null,- forceWidth: null,- rendererFunctionName: null,- bucketName: null,- audioCodec: null,- offthreadVideoCacheSizeInBytes: null,- deleteAfter: null,- colorSpace: 'default',- preferLossless: false,- },+ payload: await makeLambdaRenderMediaPayload(+ renderMediaOnLambdaOptionalToRequired({+ serveUrl:+ 'https://64d3734a6bb69052c34d3616--spiffy-kelpie-71657b.netlify.app/',+ codec: 'gif',+ composition: 'framer',+ // 61 frames, which is uneven, to challenge the frame planner+ frameRange: [0, 60],+ framesPerLambda: 8,+ imageFormat: 'png',+ logLevel: 'error',+ outName: 'out.gif',+ timeoutInMilliseconds: 12000,+ everyNthFrame: 2,+ functionName: 'remotion-dev-lambda',+ region: 'eu-central-1',+ }),+ ),functionName: 'remotion-dev-lambda',receivedStreamingPayload: () => undefined,region: 'eu-central-1',