🎥 Make videos programmatically with React
Merge remote-tracking branch 'origin/main' into codex/lambda-separate-audio
Jonny Burger8e50642a0839
diff --cc packages/docs/docs/lambda/deleterender.mdxindex c886c5a37b,be0156a2e5..e19c5e3b2f--- a/packages/docs/docs/lambda/deleterender.mdx+++ b/packages/docs/docs/lambda/deleterender.mdx@@@ -6,7 -6,7 +6,7 @@@ slug: /lambda/deleterendecrumb: 'Lambda API'---- Deletes a rendered video, audio or still and its associated metadata. If [`separateAudioTo`](/docs/lambda/rendermediaonlambda#separateaudioto) was used, both output files are deleted, including outputs in custom destinations.-Deletes a rendered video, audio, still, or image sequence and its associated metadata.++Deletes a rendered video, audio, still, or image sequence and its associated metadata. If [`separateAudioTo`](/docs/lambda/rendermediaonlambda#separateaudioto) was used, both output files are deleted, including outputs in custom destinations.```ts twoslashimport {deleteRender} from '@remotion/lambda';diff --cc packages/docs/docs/lambda/downloadmedia.mdxindex f7074a822b,35ef5ca906..1313a4385e--- a/packages/docs/docs/lambda/downloadmedia.mdx+++ b/packages/docs/docs/lambda/downloadmedia.mdx@@@ -45,12 -45,8 +45,12 @@@ The ID of the render. You can retrieve### `outPath`- Where the video should be saved. Pass an absolute path, or it will be resolved relative to your current working directory.+ Where to save the output. Pass a directory for image sequences. Relative paths resolve from your current working directory.+### `output?`<AvailableFrom v="4.0.535" />++Select the output to download: `"main"` (the default) or `"separate-audio"` for a render started with [`separateAudioTo`](/docs/lambda/rendermediaonlambda#separateaudioto). Selecting separate audio for a render without that output throws an error.+### `onProgress?`Callback function that gets called with the following properties:diff --cc packages/docs/docs/lambda/getrenderprogress.mdxindex 08b5053a3c,90671d599a..588ce494c1--- a/packages/docs/docs/lambda/getrenderprogress.mdx+++ b/packages/docs/docs/lambda/getrenderprogress.mdx@@@ -106,30 -109,44 +109,64 @@@ Contains the following information abouIn which bucket the render and other artifacts get saved.+ ### `outputSequence`<AvailableFrom v="4.0.535" />++ For completed [`renderFramesOnLambda()`](/docs/lambda/renderframesonlambda) jobs, an object describing the output sequence. Otherwise, `null`.++ #### `bucketName`++ The destination bucket containing the images and manifest.++ #### `keyPrefix`++ The storage prefix containing the sequence.++ #### `manifestKey`++ The storage key of the JSON manifest.++ #### `manifestUrl`++ The URL of the manifest. Private manifests require storage credentials or a signed URL.++ #### `imageFormat`++ `'png'` or `'jpeg'`.++ #### `frameCount`++ The number of rendered images.++ ### `framesUploaded`<AvailableFrom v="4.0.535" />++ The number of uploaded frames for an image sequence. Retries do not double-count frames. `null` for other renders, or while composition metadata is being resolved.+### `outputFile`+ For image sequences, this is `null`; use `outputSequence`.+`null` if the video is not yet rendered, a `string` containing a URL pointing to the final artifact if the video finished rendering.+### `separateAudio`<AvailableFrom v="4.0.535" />++Details of the audio output when [`separateAudioTo`](/docs/lambda/rendermediaonlambda#separateaudioto) was used. Returns `null` until the render completes, or when no separate audio output was requested. `done` becomes `true` after both outputs have uploaded successfully.++#### `url`++The URL of the audio file. Private outputs require credentials to download.++#### `bucketName`++The bucket containing the audio output.++#### `key`++The storage key of the audio output.++#### `sizeInBytes`++The size of the audio file in bytes. `outputFile` and `outputSizeInBytes` continue to describe the main output.+### `outKey``null` if the video is not yet rendered, a `string` containing the S3 key where the final artifact is stored.diff --cc packages/lambda-client/src/delete-render.tsindex 05f2709c41,51cdef841e..787fd68e18--- a/packages/lambda-client/src/delete-render.ts+++ b/packages/lambda-client/src/delete-render.ts@@@ -53,31 -52,56 +54,73 @@@ export const internalDeleteRender = asycustomCredentials: input.customCredentials ?? null,bucketNamePrefix: REMOTION_BUCKET_PREFIX,});+ const separateAudioOutput =+ (progress.renderMetadata.separateAudioTo ?? null) === null+ ? null+ : getExpectedOutName({+ output: 'separate-audio',+ renderMetadata: progress.renderMetadata,+ bucketName: input.bucketName,+ customCredentials:+ input.separateAudioCredentials ?? input.customCredentials ?? null,+ bucketNamePrefix: REMOTION_BUCKET_PREFIX,+ });+ if (progress.renderMetadata.type === 'sequence') {++ const {renderBucketName, customCredentials} = mainOutput;+ const metadata = progress.renderMetadata;+ const sequence = metadata.outputSequence;+ const frames = Array.from(+ {+ length:+ Math.floor(+ (metadata.frameRange[1] - metadata.frameRange[0]) /+ metadata.everyNthFrame,+ ) + 1,+ },+ (_, index) => metadata.frameRange[0] + index * metadata.everyNthFrame,+ );+ const keys = [+ ...frames.map((frame) =>+ getImageSequenceFrameKey({+ frame,+ keyPrefix: sequence.keyPrefix,+ imageFormat: sequence.imageFormat,+ imageSequencePattern: metadata.imageSequencePattern,+ framePadding: metadata.framePadding,+ }),+ ),+ `${sequence.keyPrefix}.remotion-render.json`,+ ];+ for (let index = 0; index < keys.length; index += 25) {+ await Promise.all(+ keys.slice(index, index + 25).map((frameKey) =>+ input.providerSpecifics.deleteFile({+ bucketName: renderBucketName,+ key: frameKey,+ region: input.region,+ customCredentials,+ forcePathStyle: input.forcePathStyle,+ requestHandler: input.requestHandler,+ }),+ ),+ );+ }+ }+- await input.providerSpecifics.deleteFile({- bucketName: renderBucketName,- customCredentials,- key,- region: input.region,- forcePathStyle: input.forcePathStyle,- requestHandler: input.requestHandler,- });+ for (const {key, renderBucketName, customCredentials} of [+ mainOutput,+ ...(separateAudioOutput === null ? [] : [separateAudioOutput]),+ ]) {+ await input.providerSpecifics.deleteFile({+ bucketName: renderBucketName,+ customCredentials,+ key,+ region: input.region,+ forcePathStyle: input.forcePathStyle,+ requestHandler: input.requestHandler,+ });+ }let files = await input.providerSpecifics.listObjects({bucketName: input.bucketName,diff --cc packages/lambda-client/src/get-output-url-from-metadata.tsindex dc65882fc0,fadbf11d44..d74db99512--- a/packages/lambda-client/src/get-output-url-from-metadata.ts+++ b/packages/lambda-client/src/get-output-url-from-metadata.ts@@@ -20,19 -15,19 +20,29 @@@ export const getOutputUrlFromMetadata:bucketName,customCredentials,bucketNamePrefix: REMOTION_BUCKET_PREFIX,+ output,});+ if (credentials !== null) {+ const url = new URL(credentials.endpoint);+ if (!credentials.forcePathStyle) {+ url.hostname = `${renderBucketName}.${url.hostname}`;+ }++ url.pathname = `${url.pathname.replace(/\/$/, '')}/${credentials.forcePathStyle ? `${renderBucketName}/` : ''}${key.split('/').map(encodeURIComponent).join('/')}`;+ return {url: url.toString(), key};+ }const {dnsSuffix} = getAwsRegionMetadata(currentRegion);+ if (renderMetadata.type === 'sequence') {+ const endpoint =+ customCredentials?.endpoint ?? `https://s3.${currentRegion}.${dnsSuffix}`;+ const url = new URL(endpoint);+ url.pathname =+ url.pathname.replace(/\/$/, '') ++ `/${encodeURIComponent(renderBucketName)}/${key.split('/').map(encodeURIComponent).join('/')}`;+ return {url: url.toString(), key};+ }+return {url: `https://s3.${currentRegion}.${dnsSuffix}/${renderBucketName}/${key}`,key,diff --cc packages/lambda/src/api/download-media.tsindex 0b3c62b3d5,d303311a75..c5a0710ba4--- a/packages/lambda/src/api/download-media.ts+++ b/packages/lambda/src/api/download-media.ts@@@ -7,9 -8,9 +8,10 @@@ import {RenderInternals} from '@remotioimport type {ProviderSpecifics} from '@remotion/serverless';import {getExpectedOutName,+ getImageSequenceFrameKey,getOverallProgressFromStorage,type CustomCredentials,+ type RenderOutput,} from '@remotion/serverless';import type {LambdaReadFileProgress} from '../functions/helpers/read-with-progress';import {lambdaDownloadFileWithProgress} from '../functions/helpers/read-with-progress';diff --cc packages/lambda/src/cli/commands/render/render.tsindex 96dc9435c4,7fca1f013d..9a7af4b5ec--- a/packages/lambda/src/cli/commands/render/render.ts+++ b/packages/lambda/src/cli/commands/render/render.ts@@@ -350,22 -354,21 +355,24 @@@ export const renderCommand = async (s3OutputProvider,});const downloadName = args[2] ?? null;+ const separateAudioTo = separateAudioOption.getValue({+ commandLine: CliInternals.parsedCli,+ }).value;- const {value: codec, source: reason} = videoCodecOption.getValue(- {- commandLine: CliInternals.parsedCli,- },- {- downloadName,- outName: outName ?? null,- configFile: ConfigInternals.getOutputCodecOrUndefined() ?? null,- uiCodec: null,- compositionCodec: null,- },- );+ const {value: codec, source: reason} = shouldOutputImageSequence+ ? {value: null, source: 'image sequence'}+ : videoCodecOption.getValue(+ {+ commandLine: CliInternals.parsedCli,+ },+ {+ downloadName,+ outName: outName ?? null,+ configFile: ConfigInternals.getOutputCodecOrUndefined() ?? null,+ uiCodec: null,+ compositionCodec: null,+ },+ );const imageFormat = BrowserSafeApis.options.videoImageFormatOption.getValue({@@@ -689,24 -714,30 +720,32 @@@);}+ const outputUrl = newStatus.outputSequence+ ? `${LambdaClientInternals.getS3BucketUrl({+ region: getAwsRegion(),+ bucketName: newStatus.outputSequence.bucketName,+ })}&prefix=${encodeURIComponent(newStatus.outputSequence.keyPrefix)}`+ : (newStatus.outputFile as string);+Log.info({indent: false, logLevel});- Log.info(- {indent: false, logLevel},- CliInternals.chalk.blue('+ S3 '.padEnd(CliInternals.LABEL_WIDTH)),- CliInternals.chalk.blue(- CliInternals.makeHyperlink({- fallback: outputUrl,- text:- newStatus.outputSequence?.keyPrefix ??- (newStatus.outKey as string),- url: outputUrl,- }),- ),- CliInternals.chalk.gray(- CliInternals.formatBytes(newStatus.outputSizeInBytes as number),- ),- );+ const separateAudio = newStatus.separateAudio ?? null;+ for (const output of [+ ...(separateAudio === null ? [] : [separateAudio]),+ {- url: newStatus.outputFile as string,- key: newStatus.outKey as string,++ url: outputUrl,++ key:++ newStatus.outputSequence?.keyPrefix ?? (newStatus.outKey as string),+ sizeInBytes: newStatus.outputSizeInBytes as number,+ },+ ]) {+ Log.info(+ {indent: false, logLevel},+ CliInternals.chalk.blue(+ `${(separateAudio === null ? '+ S3' : '+').padEnd(CliInternals.LABEL_WIDTH)} ${CliInternals.makeHyperlink({fallback: output.url, text: output.key, url: output.url})}`,+ ),+ CliInternals.chalk.gray(CliInternals.formatBytes(output.sizeInBytes)),+ );+ }if (downloadOrNothing) {const relativeOutputPath = path.relative(diff --cc packages/lambda/src/cli/help.tsindex 9ffc8eaa82,4f5aca9703..8025d737f4--- a/packages/lambda/src/cli/help.ts+++ b/packages/lambda/src/cli/help.ts@@@ -233,7 -237,9 +237,10 @@@ export const lambdaCommandHelp ='number-of-gif-loops','timeout','out-name',+ 'separate-audio-to',+ 'output-prefix',+ 'sequence',+ 'image-sequence-pattern','s3-output-provider-endpoint','s3-output-provider-region','s3-output-provider-force-path-style',diff --cc packages/lambda/src/test/integration/webhooks.test.tsindex b1806c4146,5f32a4c4dc..671f456e4b--- a/packages/lambda/src/test/integration/webhooks.test.ts+++ b/packages/lambda/src/test/integration/webhooks.test.ts@@@ -139,7 -139,7 +140,8 @@@ testoutputUrl: 'https://s3.mock-region-1.amazonaws.com/bucket/mock.mp4',lambdaErrors: [],outputFile: 'https://s3.mock-region-1.amazonaws.com/bucket/mock.mp4',+ separateAudio: null,+ outputSequence: null,});await close();},diff --cc packages/serverless-client/src/constants.tsindex 77be0fb277,8325e0f9dc..6f6ee86ad7--- a/packages/serverless-client/src/constants.ts+++ b/packages/serverless-client/src/constants.ts@@@ -408,8 -404,8 +416,9 @@@ export const artifactName = (renderId:export type PostRenderData<Provider extends CloudProvider> = {cost: AfterRenderCost;- outputFile: string;+ outputFile: string | null;+ separateAudio: SeparateAudioOutput | null;+ outputSequence: ImageSequenceOutput | null;outputSize: number;renderSize: number;timeToFinish: number;diff --cc packages/serverless-client/src/expected-out-name.tsindex dfc33e01c9,2e45d713be..0581988944--- a/packages/serverless-client/src/expected-out-name.ts+++ b/packages/serverless-client/src/expected-out-name.ts@@@ -43,20 -41,19 +43,32 @@@ export const getExpectedOutName = <ProvbucketName: string;customCredentials: CustomCredentials<Provider> | null;bucketNamePrefix: string;+ output: RenderOutput;}): OutNameOutput<Provider> => {+ if (renderMetadata.type === 'sequence') {++ if (output === 'separate-audio') {++ throw new Error('This render does not have a separate audio output.');++ }+++ return {+ key: renderMetadata.outputSequence.manifestKey,+ renderBucketName: renderMetadata.outputSequence.bucketName,+ customCredentials,+ };+ }+const outNameValue = getCustomOutName({customCredentials,- renderMetadata,+ outName:+ output === 'main'+ ? (renderMetadata.outName ?? null)+ : (renderMetadata.separateAudioTo ?? null),+ privacy: renderMetadata.privacy,});+ const separateAudioFilename =+ typeof renderMetadata.separateAudioTo === 'string'+ ? renderMetadata.separateAudioTo+ : (renderMetadata.separateAudioTo?.key ?? null);if (outNameValue) {validateOutname({outName: outNameValue,diff --cc packages/serverless-client/src/progress.tsindex 01c48f4693,0b0d1daa47..e91d50c42d--- a/packages/serverless-client/src/progress.ts+++ b/packages/serverless-client/src/progress.ts@@@ -107,7 -110,11 +110,12 @@@ export const getProgress = async <ProvifatalErrorEncountered: false,lambdasInvoked: overallProgress.renderMetadata.totalChunks,outputFile: overallProgress.postRenderData.outputFile,+ separateAudio: overallProgress.postRenderData.separateAudio ?? null,+ outputSequence: overallProgress.postRenderData.outputSequence,+ framesUploaded:+ overallProgress.renderMetadata.type === 'sequence'+ ? totalFrameCount+ : null,renderId,timeToFinish: overallProgress.postRenderData.timeToFinish,timeToFinishChunks: overallProgress.postRenderData.timeToRenderChunks,@@@ -164,7 -179,8 +176,9 @@@renderMetadata,bucket: bucketName,outputFile: null,+ separateAudio: null,+ outputSequence: null,+ framesUploaded: null,timeToFinish: null,errors: errorExplanations,fatalErrorEncountered: errorExplanations.some(@@@ -249,9 -270,8 +263,10 @@@Date.now() > renderMetadata.startedDate + timeoutInMilliseconds * 2 + 20000;const shouldCheckForCompletedOutput =+ renderMetadata.type !== 'sequence' &&allChunks &&+ ((renderMetadata.separateAudioTo ?? null) === null ||+ (overallProgress.separateAudio ?? null) !== null) &&!errorExplanations.some((error) => error.isFatal && !error.willRetry) &&(isBeyondTimeoutAndHasStitchTimeout ||(overallProgress.combinedFrames >= frameCount &&@@@ -315,7 -333,8 +330,9 @@@fatalErrorEncountered: false,lambdasInvoked: renderMetadata.totalChunks,outputFile: outputFile.url,+ separateAudio: overallProgress.separateAudio ?? null,+ outputSequence: null,+ framesUploaded: null,renderId,timeToFinish: now - renderMetadata.startedDate,timeToFinishChunks,@@@ -374,7 -396,11 +394,12 @@@renderMetadata,bucket: bucketName,outputFile: null,+ separateAudio: null,+ outputSequence: null,+ framesUploaded:+ renderMetadata?.type === 'sequence'+ ? overallProgress.framesUploaded+ : null,timeToFinish: null,errors: allErrors,fatalErrorEncountered: allErrors.some((f) => f.isFatal && !f.willRetry),diff --cc packages/serverless-client/src/render-progress.tsindex 710c204ab1,d402116d18..eff6a9d6f6--- a/packages/serverless-client/src/render-progress.ts+++ b/packages/serverless-client/src/render-progress.ts@@@ -1,4 -1,4 +1,5 @@@+import type {SeparateAudioOutput} from './constants';+ import type {ImageSequenceOutput} from './image-sequence';import type {ExpensiveChunk} from './most-expensive-chunks';import type {RenderMetadata} from './render-metadata';import type {@@@ -30,7 -30,8 +31,9 @@@ export type GenericRenderProgress<ProvirenderMetadata: RenderMetadata<Provider> | null;bucket: string;outputFile: string | null;+ separateAudio: SeparateAudioOutput | null;+ outputSequence: ImageSequenceOutput | null;+ framesUploaded: number | null;outKey: string | null;outBucket: string | null;timeToFinish: number | null;diff --cc packages/serverless-client/src/webhook-types.tsindex 6efd042989,f8a96ebe2e..83a96f97f0--- a/packages/serverless-client/src/webhook-types.ts+++ b/packages/serverless-client/src/webhook-types.ts@@@ -1,4 -1,5 +1,5 @@@-import type {AfterRenderCost} from './constants';+import type {AfterRenderCost, SeparateAudioOutput} from './constants';+ import type {ImageSequenceOutput} from './image-sequence';import type {EnhancedErrorInfo} from './write-error-to-storage';type StaticWebhookPayload<BucketOwner extends string | null> = {@@@ -24,7 -25,7 +25,8 @@@ export type WebhookSuccessPayload<BuckelambdaErrors: EnhancedErrorInfo[];outputUrl: string | undefined;outputFile: string | undefined;+ separateAudio: SeparateAudioOutput | null;+ outputSequence: ImageSequenceOutput | null;timeToFinish: number | undefined;costs: AfterRenderCost;};diff --cc packages/serverless/src/create-post-render-data.tsindex 4224b6994d,0cb4d48594..361206bdcf--- a/packages/serverless/src/create-post-render-data.ts+++ b/packages/serverless/src/create-post-render-data.ts@@@ -85,8 -88,9 +88,10 @@@ export const createPostRenderData = <Pr},).format(cost)}`,},- outputFile: outputFile.url,+ outputFile: renderMetadata.type === 'sequence' ? null : outputFile.url,+ separateAudio: overallProgress.separateAudio ?? null,+ outputSequence:+ renderMetadata.type === 'sequence' ? renderMetadata.outputSequence : null,timeToFinish,errors: errorExplanations,startTime: renderMetadata.startedDate,diff --cc packages/serverless/src/handlers/launch.tsindex cde61ff809,57b0aacb22..746876d4f7--- a/packages/serverless/src/handlers/launch.ts+++ b/packages/serverless/src/handlers/launch.ts@@@ -79,59 -85,6 +86,68 @@@ const innerLaunchHandler = async <Provithrow new Error('Expected launch type');}- validateCodec(params.codec, 'renderMediaOnLambda', 'codec');++ if (params.codec !== null) {++ validateCodec(params.codec, 'renderMediaOnLambda', 'codec');++ }+ const separateAudioTo = params.separateAudioTo ?? null;++++ if (separateAudioTo !== null && params.codec === null) {++ throw new Error(++ '`separateAudioTo` cannot be used with image sequence renders.',++ );++ }+++ const separateAudioFilename =+ typeof separateAudioTo === 'string'+ ? separateAudioTo+ : (separateAudioTo?.key ?? null);+ const audioCodec =- separateAudioFilename === null++ separateAudioFilename === null || params.codec === null+ ? params.audioCodec+ : RenderInternals.resolveAudioCodec({+ codec: params.codec,+ setting: params.audioCodec,+ preferLossless: params.preferLossless,+ separateAudioTo: separateAudioFilename.toLowerCase(),+ });+ if (separateAudioTo !== null) {+ if (NoReactAPIs.isAudioCodec(params.codec)) {+ throw new Error(+ '`separateAudioTo` was set, but this render was audio-only. This option is meant to be used for video renders.',+ );+ }++ if (params.muted || audioCodec === null) {+ throw new Error(+ '`separateAudioTo` requires audio output. Audio output is disabled by the muted option or selected codec.',+ );+ }++ const extension =+ RenderInternals.getExtensionOfFilename(+ separateAudioFilename,+ )?.toLowerCase() ?? null;+ if (+ extension !== RenderInternals.getExtensionFromAudioCodec(audioCodec) &&+ !(+ audioCodec === 'aac' &&+ RenderInternals.getMp4BrandForExtension(extension)+ )+ ) {+ throw new Error(+ '`separateAudioTo` must use a supported audio extension: .wav, .aac, .mp3, .opus, .m4a, .m4b or .3gp.',+ );+ }++ validateOutname({+ outName: separateAudioTo,+ codec: null,+ audioCodecSetting: audioCodec,+ separateAudioTo: null,+ bucketNamePrefix: providerSpecifics.getBucketPrefix(),+ });+ }+const startedDate = Date.now();const chromiumParams = insideFunctionSpecifics.normalizeChromiumOptions?.({@@@ -252,12 -301,16 +364,12 @@@});validateOutname({- outName: params.outName,+ outName,codec: params.codec,- audioCodecSetting: params.audioCodec,- separateAudioTo: null,+ audioCodecSetting: audioCodec,+ separateAudioTo: separateAudioFilename?.toLowerCase() ?? null,bucketNamePrefix: providerSpecifics.getBucketPrefix(),});- if (params.codec !== null) {- validateCodec(params.codec, 'renderMediaOnLambda', 'codec');- }-validatePrivacy(params.privacy, true);RenderInternals.validatePuppeteerTimeout(params.timeoutInMilliseconds);@@@ -453,87 -509,50 +579,93 @@@};const {key, renderBucketName, customCredentials} = getExpectedOutName({+ output: 'main',renderMetadata,bucketName: params.bucketName,- customCredentials:- typeof params.outName === 'string' ||- typeof params.outName === 'undefined'- ? null- : (params.outName?.s3OutputProvider ?? null),+ customCredentials: getCredentialsFromOutName(outName),bucketNamePrefix: providerSpecifics.getBucketPrefix(),});+ const separateAudioDestination =+ separateAudioTo === null+ ? null+ : getExpectedOutName({+ output: 'separate-audio',+ renderMetadata,+ bucketName: params.bucketName,+ customCredentials: getCredentialsFromOutName(separateAudioTo),+ bucketNamePrefix: providerSpecifics.getBucketPrefix(),+ });+ if (+ separateAudioDestination !== null &&+ separateAudioDestination.key === key &&+ separateAudioDestination.renderBucketName === renderBucketName &&+ (separateAudioDestination.customCredentials?.endpoint ?? null) ===+ (customCredentials?.endpoint ?? null)+ ) {+ throw new Error(+ '`outName` and `separateAudioTo` must point to different output files.',+ );+ }+ if (outputSequence !== null) {+ outputSequence.manifestUrl = providerSpecifics.getOutputUrl({++ output: 'main',+ bucketName: params.bucketName,+ currentRegion: insideFunctionSpecifics.getCurrentRegionInFunction(),+ customCredentials,+ renderMetadata,+ }).url;+ }+if (!params.overwrite) {const findOutputFile = insideFunctionSpecifics.timer('Checking if output file already exists',params.logLevel,);- const output = await findOutputFileInBucket({- bucketName: params.bucketName,- customCredentials,- renderMetadata,- region: insideFunctionSpecifics.getCurrentRegionInFunction(),- currentRegion: insideFunctionSpecifics.getCurrentRegionInFunction(),- providerSpecifics,- forcePathStyle: params.forcePathStyle,- requestHandler: null,- }).catch((err) => {- if (- err instanceof OutputFileAccessDeniedError &&- renderMetadata.outputFileIsConditional- ) {- // The final conditional upload still enforces overwrite: false.- return null;- }+ for (const destination of [+ {+ output: 'main' as const,+ key,+ renderBucketName,+ customCredentials,+ conditional: renderMetadata.outputFileIsConditional,+ },+ ...(separateAudioDestination === null+ ? []+ : [+ {+ output: 'separate-audio' as const,+ ...separateAudioDestination,+ conditional: renderMetadata.separateAudioOutputFileIsConditional,+ },+ ]),+ ]) {+ const output = await findOutputFileInBucket({+ output: destination.output,+ bucketName: params.bucketName,+ customCredentials: destination.customCredentials,+ renderMetadata,+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),+ currentRegion: insideFunctionSpecifics.getCurrentRegionInFunction(),+ providerSpecifics,+ forcePathStyle: params.forcePathStyle,+ requestHandler: null,+ }).catch((err) => {+ if (+ err instanceof OutputFileAccessDeniedError &&+ destination.conditional+ ) {+ // The final conditional upload still enforces overwrite: false.+ return null;+ }- throw err;- });- if (output) {- throw new TypeError(- `Output file "${key}" in bucket "${renderBucketName}" in region "${insideFunctionSpecifics.getCurrentRegionInFunction()}" already exists. Delete it before re-rendering, or set the 'overwrite' option in ${params.output.type === 'sequence' ? 'renderFramesOnLambda()' : 'renderMediaOnLambda()'} to overwrite it.`,- );+ throw err;+ });+ if (output) {+ throw new TypeError(- `Output file "${destination.key}" in bucket "${destination.renderBucketName}" in region "${insideFunctionSpecifics.getCurrentRegionInFunction()}" already exists. Delete it before re-rendering, or set the 'overwrite' option in renderMediaOnLambda() to overwrite it."`,++ `Output file "${destination.key}" in bucket "${destination.renderBucketName}" in region "${insideFunctionSpecifics.getCurrentRegionInFunction()}" already exists. Delete it before re-rendering, or set the 'overwrite' option in ${params.output.type === 'sequence' ? 'renderFramesOnLambda()' : 'renderMediaOnLambda()'} to overwrite it.`,+ );+ }}findOutputFile.end();@@@ -616,9 -710,108 +823,108 @@@};let postRenderData: PostRenderData<Provider>;- if (shouldRenderDirectly) {+ if (+ rendererOutput.type === 'sequence' &&+ renderMetadata.type === 'sequence'+ ) {+ const sequenceDestination = rendererOutput;+ const outdir = RenderInternals.tmpDir(CONCAT_FOLDER_TOKEN);+ await Promise.all(+ lambdaPayloads.map((payload) =>+ renderRendererFunctionWithRetry({+ payload,+ files: [],+ functionName: rendererFunctionName,+ outdir,+ overallProgress,+ logLevel: params.logLevel,+ onArtifact,+ providerSpecifics,+ insideFunctionSpecifics,+ requestHandler: null,+ expectedBucketOwner: options.expectedBucketOwner,+ }),+ ),+ );+ await Promise.all(artifactUploads);+ const progress = overallProgress.get();+ if (+ progress.framesUploaded !== frameCount.length ||+ progress.chunks.length !== chunks.length+ ) {+ throw new Error(+ 'Cannot finish the image sequence before every chunk has uploaded all its frames',+ );+ }++ const manifest: ImageSequenceManifest = {+ renderId: params.renderId,+ imageFormat: rendererOutput.imageFormat,+ width: renderMetadata.dimensions.width,+ height: renderMetadata.dimensions.height,+ fps: comp.fps,+ frameRange: realFrameRange,+ everyNthFrame: params.everyNthFrame,+ frames: frameCount.map((frame) => ({+ frame,+ key: getImageSequenceFrameKey({+ ...sequenceDestination,+ frame,+ }),+ })),+ };+ const manifestBody = JSON.stringify(manifest);+ await providerSpecifics.writeFile({+ bucketName: renderBucketName,+ key,+ body: manifestBody,+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),+ privacy: params.privacy,+ expectedBucketOwner: options.expectedBucketOwner,+ downloadBehavior: {type: 'play-in-browser'},+ customCredentials,+ forcePathStyle: params.forcePathStyle,+ storageClass: params.storageClass,+ requestHandler: null,+ });+ const cleanup = await cleanupProps({+ inputProps: params.inputProps,+ serializedResolvedProps,+ providerSpecifics,+ forcePathStyle: params.forcePathStyle,+ insideFunctionSpecifics,+ });+ postRenderData = createPostRenderData({+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),+ memorySizeInMb: insideFunctionSpecifics.getCurrentMemorySizeInMb(),+ renderMetadata,+ errorExplanations: inspectErrors({errors: progress.errors}),+ timeToDelete: cleanup.reduce((max, time) => Math.max(max, time), 0),+ outputFile: {+ url: renderMetadata.outputSequence.manifestUrl,+ sizeInBytes: Buffer.byteLength(manifestBody),+ },+ timeToCombine: null,+ overallProgress: progress,+ timeToFinish: Date.now() - startTime,+ outputSize:+ progress.uploadedSizeInBytes + Buffer.byteLength(manifestBody),+ providerSpecifics,+ });+ await overallProgress.setPostRenderData(postRenderData);+ await providerSpecifics+ .deleteFile({+ bucketName: renderBucketName,+ key: `${rendererOutput.keyPrefix}.remotion-render.json`,+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),+ customCredentials,+ forcePathStyle: params.forcePathStyle,+ requestHandler: null,+ })+ .catch(() => undefined);+ } else if (shouldRenderDirectly) {const directRender = await renderWithSingleFunction({- params,+ params: {...params, audioCodec},composition: comp,serializedInputPropsWithCustomSchema,frameRange: realFrameRange,@@@ -998,10 -1188,10 +1308,11 @@@ export const launchHandler = async <ProexpectedBucketOwner: options.expectedBucketOwner,bucketName: params.bucketName,customData: params.webhook.customData ?? null,- outputUrl: postRenderData.outputFile,+ outputUrl: postRenderData.outputFile ?? undefined,lambdaErrors: postRenderData.errors,- outputFile: postRenderData.outputFile,+ outputFile: postRenderData.outputFile ?? undefined,+ separateAudio: postRenderData.separateAudio,+ outputSequence: postRenderData.outputSequence,timeToFinish: postRenderData.timeToFinish,costs: postRenderData.cost,},diff --cc packages/serverless/src/render-with-single-function.tsindex 76b3ec4cd7,3fc5f1e10e..d5d4b613d3--- a/packages/serverless/src/render-with-single-function.ts+++ b/packages/serverless/src/render-with-single-function.ts@@@ -48,10 -48,9 +48,10 @@@ export const renderWithSingleFunctioninsideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}): Promise<{outputFile: string;+ separateAudioFile: string | null;cleanup: () => Promise<void>;}> => {- if (params.type !== ServerlessRoutines.launch) {+ if (params.type !== ServerlessRoutines.launch || params.codec === null) {throw new Error('Expected launch type');}