🎥 Make videos programmatically with React
makes more sense
Jonny Burger822b266fe7fe
diff --git a/packages/docs/docs/lambda/rendermediaonlambda.mdx b/packages/docs/docs/lambda/rendermediaonlambda.mdxindex a7a49c32d2..b7fcc07534 100644--- a/packages/docs/docs/lambda/rendermediaonlambda.mdx+++ b/packages/docs/docs/lambda/rendermediaonlambda.mdx@@ -186,21 +186,21 @@ Renamed to `jpegQuality` in v4.0.0._optional_-<Options id="audio-bitrate"/>+<Options id="audio-bitrate" />### `videoBitrate?`_optional_-<Options id="video-bitrate"/>+<Options id="video-bitrate" />### `bufferSize?`<AvailableFrom v="4.0.78" />-<Options id="buffer-size"/>+<Options id="buffer-size" />### `maxRate?`<AvailableFrom v="4.0.78" />-<Options id="max-rate"/>+<Options id="max-rate" />### `maxRetries`@@ -283,15 +283,14 @@ Results in invalid SSL certificates, such as self-signed ones, being ignored.#### `gl`-<Options id="gl" />+<Options id="gl" />### `overwrite?`_available from v3.2.25_-If a custom out name is specified and a file already exists at this key in the S3 bucket, decide whether that file will be deleted before the render begins. Default `false`.--An existing file at the output S3 key will conflict with the render and must be deleted beforehand. If this setting is `false` and a conflict occurs, an error will be thrown.+If a custom out name is specified and a file already exists at this key in the S3 bucket, decide whether the file should be overwritten. Default `false`.+If the file exists and `overwrite` is `false`, an error will be thrown.### `rendererFunctionName?`@@ -341,7 +340,7 @@ Specify a specific bucket name to be used. [This is not recommended](/docs/lambd### `logLevel?`-<Options id="log"/>+<Options id="log" />If the `logLevel` is set to `verbose`, the Lambda function will not clean up artifacts, to aid debugging. Do not use it unless you are debugging a problem.@@ -355,11 +354,11 @@ If the `logLevel` is set to `verbose`, the Lambda function will not clean up art### `deleteAfter?`<AvailableFrom v="4.0.32"/>-<Options id="delete-after"/>+<Options id="delete-after" />### `preferLossless?`<AvailableFrom v="4.0.123"/>-<Options id="prefer-lossless" />+<Options id="prefer-lossless" />### ~~`dumpBrowserLogs?`~~diff --git a/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts b/packages/lambda/src/functions/helpers/find-output-file-in-bucket.tsindex db38b15d9c..3a7aa29dd5 100644--- a/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts+++ b/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts@@ -1,22 +1,26 @@import {ROLE_NAME} from '../../api/iam-validation/suggested-policy';+import type {AwsRegion} from '../../client';import type {CustomCredentials} from '../../shared/aws-clients';import type {RenderMetadata} from '../../shared/constants';import {getExpectedOutName} from './expected-out-name';import {getOutputUrlFromMetadata} from './get-output-url-from-metadata';+import {lambdaHeadCommand} from './io';export type OutputFileMetadata = {url: string;};-export const findOutputFileInBucket = ({+export const findOutputFileInBucket = async ({+ region,renderMetadata,bucketName,customCredentials,}: {+ region: AwsRegion;renderMetadata: RenderMetadata;bucketName: string;customCredentials: CustomCredentials | null;-}): OutputFileMetadata | null => {+}): Promise<OutputFileMetadata | null> => {if (!renderMetadata) {throw new Error('unexpectedly did not get renderMetadata');}@@ -28,6 +32,12 @@ export const findOutputFileInBucket = ({);try {+ await lambdaHeadCommand({+ bucketName,+ key,+ region,+ customCredentials,+ });return {url: getOutputUrlFromMetadata(renderMetadata,diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.tsindex cb22045605..bb7b584737 100644--- a/packages/lambda/src/functions/launch.ts+++ b/packages/lambda/src/functions/launch.ts@@ -39,7 +39,6 @@ import {getBrowserInstance,} from './helpers/get-browser-instance';import {getCurrentRegionInFunction} from './helpers/get-current-region';-import {lambdaDeleteFile} from './helpers/io';import {mergeChunksAndFinishRender} from './helpers/merge-chunks';import {makeOverallRenderProgress} from './helpers/overall-render-progress';import {streamRendererFunctionWithRetry} from './helpers/stream-renderer';@@ -308,29 +307,16 @@ const innerLaunchHandler = async ({: params.outName?.s3OutputProvider ?? null,);- // TODO: Once we don't check for output file in S3, we can do this asynchronously- const output = findOutputFileInBucket({- bucketName: params.bucketName,- customCredentials,- renderMetadata,- });-- if (output) {- if (params.overwrite) {- console.info(- 'Deleting',- {bucketName: renderBucketName, key},- 'because it already existed and will be overwritten',- );- await lambdaDeleteFile({- bucketName: renderBucketName,- customCredentials,- key,- region: getCurrentRegionInFunction(),- });- } else {+ if (!params.overwrite) {+ const output = await findOutputFileInBucket({+ bucketName: params.bucketName,+ customCredentials,+ renderMetadata,+ region: getCurrentRegionInFunction(),+ });+ if (output) {throw new TypeError(- `Output file "${key}" in bucket "${renderBucketName}" in region "${getCurrentRegionInFunction()}" already exists. Delete it before re-rendering, or use the overwrite option to delete it before render."`,+ `Output file "${key}" in bucket "${renderBucketName}" in region "${getCurrentRegionInFunction()}" already exists. Delete it before re-rendering, or set the 'overwrite' option in renderMediaOnLambda() to overwrite it."`,);}}