@remotion/lambda 3.2.24 → 3.2.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,6 +30,7 @@ export declare type RenderMediaOnLambdaInput = {
30
30
  concurrencyPerLambda?: number;
31
31
  downloadBehavior?: DownloadBehavior | null;
32
32
  muted?: boolean;
33
+ overwrite?: boolean;
33
34
  };
34
35
  export declare type RenderMediaOnLambdaOutput = {
35
36
  renderId: string;
@@ -54,8 +55,8 @@ export declare type RenderMediaOnLambdaOutput = {
54
55
  * @param params.logLevel Level of logging that Lambda function should perform. Default "info".
55
56
  * @returns {Promise<RenderMediaOnLambdaOutput>} See documentation for detailed structure
56
57
  */
57
- export declare const renderMediaOnLambda: ({ functionName, serveUrl, inputProps, codec, imageFormat, crf, envVariables, pixelFormat, proResProfile, quality, region, maxRetries, composition, framesPerLambda, privacy, logLevel, frameRange, outName, timeoutInMilliseconds, chromiumOptions, scale, numberOfGifLoops, everyNthFrame, concurrencyPerLambda, downloadBehavior, muted, }: RenderMediaOnLambdaInput) => Promise<RenderMediaOnLambdaOutput>;
58
+ export declare const renderMediaOnLambda: ({ functionName, serveUrl, inputProps, codec, imageFormat, crf, envVariables, pixelFormat, proResProfile, quality, region, maxRetries, composition, framesPerLambda, privacy, logLevel, frameRange, outName, timeoutInMilliseconds, chromiumOptions, scale, numberOfGifLoops, everyNthFrame, concurrencyPerLambda, downloadBehavior, muted, overwrite, }: RenderMediaOnLambdaInput) => Promise<RenderMediaOnLambdaOutput>;
58
59
  /**
59
60
  * @deprecated Renamed to renderMediaOnLambda()
60
61
  */
61
- export declare const renderVideoOnLambda: ({ functionName, serveUrl, inputProps, codec, imageFormat, crf, envVariables, pixelFormat, proResProfile, quality, region, maxRetries, composition, framesPerLambda, privacy, logLevel, frameRange, outName, timeoutInMilliseconds, chromiumOptions, scale, numberOfGifLoops, everyNthFrame, concurrencyPerLambda, downloadBehavior, muted, }: RenderMediaOnLambdaInput) => Promise<RenderMediaOnLambdaOutput>;
62
+ export declare const renderVideoOnLambda: ({ functionName, serveUrl, inputProps, codec, imageFormat, crf, envVariables, pixelFormat, proResProfile, quality, region, maxRetries, composition, framesPerLambda, privacy, logLevel, frameRange, outName, timeoutInMilliseconds, chromiumOptions, scale, numberOfGifLoops, everyNthFrame, concurrencyPerLambda, downloadBehavior, muted, overwrite, }: RenderMediaOnLambdaInput) => Promise<RenderMediaOnLambdaOutput>;
@@ -28,7 +28,7 @@ const validate_serveurl_1 = require("../shared/validate-serveurl");
28
28
  * @param params.logLevel Level of logging that Lambda function should perform. Default "info".
29
29
  * @returns {Promise<RenderMediaOnLambdaOutput>} See documentation for detailed structure
30
30
  */
31
- const renderMediaOnLambda = async ({ functionName, serveUrl, inputProps, codec, imageFormat, crf, envVariables, pixelFormat, proResProfile, quality, region, maxRetries, composition, framesPerLambda, privacy, logLevel, frameRange, outName, timeoutInMilliseconds, chromiumOptions, scale, numberOfGifLoops, everyNthFrame, concurrencyPerLambda, downloadBehavior, muted, }) => {
31
+ const renderMediaOnLambda = async ({ functionName, serveUrl, inputProps, codec, imageFormat, crf, envVariables, pixelFormat, proResProfile, quality, region, maxRetries, composition, framesPerLambda, privacy, logLevel, frameRange, outName, timeoutInMilliseconds, chromiumOptions, scale, numberOfGifLoops, everyNthFrame, concurrencyPerLambda, downloadBehavior, muted, overwrite, }) => {
32
32
  var _a;
33
33
  const actualCodec = (0, validate_lambda_codec_1.validateLambdaCodec)(codec);
34
34
  (0, validate_serveurl_1.validateServeUrl)(serveUrl);
@@ -68,6 +68,7 @@ const renderMediaOnLambda = async ({ functionName, serveUrl, inputProps, codec,
68
68
  downloadBehavior: downloadBehavior !== null && downloadBehavior !== void 0 ? downloadBehavior : { type: 'play-in-browser' },
69
69
  muted: muted !== null && muted !== void 0 ? muted : false,
70
70
  version: version_1.VERSION,
71
+ overwrite: overwrite !== null && overwrite !== void 0 ? overwrite : false,
71
72
  },
72
73
  region,
73
74
  });
@@ -37,7 +37,7 @@ const renderCommand = async (args) => {
37
37
  (0, quit_1.quit)(1);
38
38
  }
39
39
  const outName = (_a = args[2]) !== null && _a !== void 0 ? _a : null;
40
- const { chromiumOptions, codec, crf, envVariables, frameRange, imageFormat, inputProps, logLevel, pixelFormat, proResProfile, puppeteerTimeout, quality, scale, everyNthFrame, numberOfGifLoops, muted, } = await cli_1.CliInternals.getCliOptions({
40
+ const { chromiumOptions, codec, crf, envVariables, frameRange, imageFormat, inputProps, logLevel, pixelFormat, proResProfile, puppeteerTimeout, quality, scale, everyNthFrame, numberOfGifLoops, muted, overwrite, } = await cli_1.CliInternals.getCliOptions({
41
41
  type: 'series',
42
42
  isLambda: true,
43
43
  });
@@ -75,6 +75,7 @@ const renderCommand = async (args) => {
75
75
  everyNthFrame,
76
76
  concurrencyPerLambda: args_1.parsedLambdaCli['concurrency-per-lambda'],
77
77
  muted,
78
+ overwrite,
78
79
  });
79
80
  const totalSteps = outName ? 5 : 4;
80
81
  const progressBar = cli_1.CliInternals.createOverwriteableCliOutput(cli_1.CliInternals.quietFlagProvided());
@@ -6,6 +6,9 @@ export declare const planFrameRanges: ({ framesPerLambda, optimization, shouldUs
6
6
  frameRange: [number, number];
7
7
  everyNthFrame: number;
8
8
  }) => {
9
- chunks: [number, number][];
9
+ chunks: [
10
+ number,
11
+ number
12
+ ][];
10
13
  didUseOptimization: boolean;
11
14
  };
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findOutputFileInBucket = void 0;
4
- const client_s3_1 = require("@aws-sdk/client-s3");
5
4
  const suggested_policy_1 = require("../../api/iam-validation/suggested-policy");
6
- const aws_clients_1 = require("../../shared/aws-clients");
7
5
  const expected_out_name_1 = require("./expected-out-name");
8
6
  const get_output_url_from_metadata_1 = require("./get-output-url-from-metadata");
7
+ const io_1 = require("./io");
9
8
  const findOutputFileInBucket = async ({ region, renderMetadata, bucketName, customCredentials, }) => {
10
9
  var _a;
11
10
  if (!renderMetadata) {
@@ -13,10 +12,11 @@ const findOutputFileInBucket = async ({ region, renderMetadata, bucketName, cust
13
12
  }
14
13
  const { renderBucketName, key } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName, null);
15
14
  try {
16
- const head = await (0, aws_clients_1.getS3Client)(region, customCredentials).send(new client_s3_1.HeadObjectCommand({
17
- Bucket: renderBucketName,
18
- Key: key,
19
- }));
15
+ const head = await (0, io_1.lambdaHeadCommand)({
16
+ bucketName,
17
+ key,
18
+ region,
19
+ });
20
20
  return {
21
21
  lastModified: (_a = head.LastModified) === null || _a === void 0 ? void 0 : _a.getTime(),
22
22
  size: head.ContentLength,
@@ -36,3 +36,11 @@ export declare const lambdaReadFile: ({ bucketName, key, region, expectedBucketO
36
36
  region: AwsRegion;
37
37
  expectedBucketOwner: string;
38
38
  }) => Promise<Readable>;
39
+ export declare const lambdaHeadCommand: ({ bucketName, key, region, }: {
40
+ bucketName: string;
41
+ key: string;
42
+ region: AwsRegion;
43
+ }) => Promise<{
44
+ LastModified?: Date | undefined;
45
+ ContentLength?: number | undefined;
46
+ }>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.lambdaReadFile = exports.lambdaWriteFile = exports.lambdaDeleteFile = exports.lambdaLs = void 0;
6
+ exports.lambdaHeadCommand = exports.lambdaReadFile = exports.lambdaWriteFile = exports.lambdaDeleteFile = exports.lambdaLs = void 0;
7
7
  const client_s3_1 = require("@aws-sdk/client-s3");
8
8
  const mime_types_1 = __importDefault(require("mime-types"));
9
9
  const aws_clients_1 = require("../../shared/aws-clients");
@@ -79,3 +79,11 @@ const lambdaReadFile = async ({ bucketName, key, region, expectedBucketOwner, })
79
79
  return Body;
80
80
  };
81
81
  exports.lambdaReadFile = lambdaReadFile;
82
+ const lambdaHeadCommand = async ({ bucketName, key, region, }) => {
83
+ const head = await (0, aws_clients_1.getS3Client)(region, null).send(new client_s3_1.HeadObjectCommand({
84
+ Bucket: bucketName,
85
+ Key: key,
86
+ }));
87
+ return head;
88
+ };
89
+ exports.lambdaHeadCommand = lambdaHeadCommand;
@@ -29,6 +29,7 @@ const concat_videos_1 = require("./helpers/concat-videos");
29
29
  const create_post_render_data_1 = require("./helpers/create-post-render-data");
30
30
  const delete_chunks_1 = require("./helpers/delete-chunks");
31
31
  const expected_out_name_1 = require("./helpers/expected-out-name");
32
+ const find_output_file_in_bucket_1 = require("./helpers/find-output-file-in-bucket");
32
33
  const get_browser_instance_1 = require("./helpers/get-browser-instance");
33
34
  const get_current_region_1 = require("./helpers/get-current-region");
34
35
  const get_files_to_delete_1 = require("./helpers/get-files-to-delete");
@@ -183,6 +184,29 @@ const innerLaunchHandler = async (params, options) => {
183
184
  outName: (_b = params.outName) !== null && _b !== void 0 ? _b : undefined,
184
185
  privacy: params.privacy,
185
186
  };
187
+ const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, params.bucketName, typeof params.outName === 'string' || typeof params.outName === 'undefined'
188
+ ? null
189
+ : (_d = (_c = params.outName) === null || _c === void 0 ? void 0 : _c.s3OutputProvider) !== null && _d !== void 0 ? _d : null);
190
+ const output = await (0, find_output_file_in_bucket_1.findOutputFileInBucket)({
191
+ bucketName: params.bucketName,
192
+ customCredentials,
193
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
194
+ renderMetadata,
195
+ });
196
+ if (output) {
197
+ if (params.overwrite) {
198
+ console.info('Deleting', { bucketName: renderBucketName, key }, 'because it already existed and will be overwritten');
199
+ await (0, io_1.lambdaDeleteFile)({
200
+ bucketName: renderBucketName,
201
+ customCredentials,
202
+ key,
203
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
204
+ });
205
+ }
206
+ else {
207
+ throw new TypeError(`Output file "${key}" in bucket "${renderBucketName}" in region "${(0, get_current_region_1.getCurrentRegionInFunction)()}" already exists. Delete it before re-rendering, or use the overwrite option to delete it before render."`);
208
+ }
209
+ }
186
210
  await (0, io_1.lambdaWriteFile)({
187
211
  bucketName: params.bucketName,
188
212
  key: (0, constants_1.renderMetadataKey)(params.renderId),
@@ -263,9 +287,6 @@ const innerLaunchHandler = async (params, options) => {
263
287
  if (!encodingStop) {
264
288
  encodingStop = Date.now();
265
289
  }
266
- const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, params.bucketName, typeof params.outName === 'string' || typeof params.outName === 'undefined'
267
- ? null
268
- : (_d = (_c = params.outName) === null || _c === void 0 ? void 0 : _c.s3OutputProvider) !== null && _d !== void 0 ? _d : null);
269
290
  const outputSize = fs_1.default.statSync(outfile);
270
291
  await (0, io_1.lambdaWriteFile)({
271
292
  bucketName: renderBucketName,
@@ -62,6 +62,7 @@ const startHandler = async (params, options) => {
62
62
  concurrencyPerLambda: params.concurrencyPerLambda,
63
63
  downloadBehavior: params.downloadBehavior,
64
64
  muted: params.muted,
65
+ overwrite: params.overwrite,
65
66
  };
66
67
  await (0, aws_clients_1.getLambdaClient)((0, get_current_region_1.getCurrentRegionInFunction)()).send(new client_lambda_1.InvokeCommand({
67
68
  FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
@@ -124,6 +124,7 @@ export declare type LambdaPayloads = {
124
124
  downloadBehavior: DownloadBehavior;
125
125
  muted: boolean;
126
126
  version: string;
127
+ overwrite: boolean;
127
128
  };
128
129
  launch: {
129
130
  type: LambdaRoutines.launch;
@@ -153,6 +154,7 @@ export declare type LambdaPayloads = {
153
154
  concurrencyPerLambda: number;
154
155
  downloadBehavior: DownloadBehavior;
155
156
  muted: boolean;
157
+ overwrite: boolean;
156
158
  };
157
159
  status: {
158
160
  type: LambdaRoutines.status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "3.2.24",
3
+ "version": "3.2.25",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -32,12 +32,12 @@
32
32
  "@aws-sdk/client-service-quotas": "3.58.0",
33
33
  "@aws-sdk/lib-storage": "3.58.0",
34
34
  "@aws-sdk/s3-request-presigner": "3.58.0",
35
- "@remotion/bundler": "3.2.24",
36
- "@remotion/cli": "3.2.24",
37
- "@remotion/renderer": "3.2.24",
35
+ "@remotion/bundler": "3.2.25",
36
+ "@remotion/cli": "3.2.25",
37
+ "@remotion/renderer": "3.2.25",
38
38
  "aws-policies": "^1.0.1",
39
39
  "mime-types": "2.1.34",
40
- "remotion": "3.2.24"
40
+ "remotion": "3.2.25"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": ">=16.8.0",
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "gitHead": "1f11ef8d122eadb6d6f6aa0570ffc4936d43a886"
65
+ "gitHead": "8e51d998e16f062336d65469cbfc9266068b7701"
66
66
  }
Binary file