@remotion/lambda 3.2.24 → 3.2.27

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.
@@ -8,16 +8,16 @@ export declare type RenderMediaOnLambdaInput = {
8
8
  functionName: string;
9
9
  serveUrl: string;
10
10
  composition: string;
11
- inputProps: unknown;
11
+ inputProps?: unknown;
12
12
  codec: LambdaCodec;
13
- imageFormat: ImageFormat;
13
+ imageFormat?: ImageFormat;
14
14
  crf?: number | undefined;
15
15
  envVariables?: Record<string, string>;
16
16
  pixelFormat?: PixelFormat;
17
17
  proResProfile?: ProResProfile;
18
- privacy: Privacy;
18
+ privacy?: Privacy;
19
19
  quality?: number;
20
- maxRetries: number;
20
+ maxRetries?: number;
21
21
  framesPerLambda?: number;
22
22
  logLevel?: LogLevel;
23
23
  frameRange?: FrameRange;
@@ -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;
@@ -44,18 +45,18 @@ export declare type RenderMediaOnLambdaOutput = {
44
45
  * @param params.composition The ID of the composition which should be rendered.
45
46
  * @param params.inputProps The input props that should be passed to the composition.
46
47
  * @param params.codec The media codec which should be used for encoding.
47
- * @param params.imageFormat In which image format the frames should be rendered.
48
+ * @param params.imageFormat In which image format the frames should be rendered. Default "jpeg"
48
49
  * @param params.crf The constant rate factor to be used during encoding.
49
50
  * @param params.envVariables Object containing environment variables to be inserted into the video environment
50
51
  * @param params.proResProfile The ProRes profile if rendering a ProRes video
51
52
  * @param params.quality JPEG quality if JPEG was selected as the image format.
52
53
  * @param params.region The AWS region in which the media should be rendered.
53
- * @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted.
54
+ * @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted. Default "1"
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>;
@@ -18,17 +18,17 @@ const validate_serveurl_1 = require("../shared/validate-serveurl");
18
18
  * @param params.composition The ID of the composition which should be rendered.
19
19
  * @param params.inputProps The input props that should be passed to the composition.
20
20
  * @param params.codec The media codec which should be used for encoding.
21
- * @param params.imageFormat In which image format the frames should be rendered.
21
+ * @param params.imageFormat In which image format the frames should be rendered. Default "jpeg"
22
22
  * @param params.crf The constant rate factor to be used during encoding.
23
23
  * @param params.envVariables Object containing environment variables to be inserted into the video environment
24
24
  * @param params.proResProfile The ProRes profile if rendering a ProRes video
25
25
  * @param params.quality JPEG quality if JPEG was selected as the image format.
26
26
  * @param params.region The AWS region in which the media should be rendered.
27
- * @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted.
27
+ * @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted. Default "1"
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);
@@ -46,16 +46,16 @@ const renderMediaOnLambda = async ({ functionName, serveUrl, inputProps, codec,
46
46
  framesPerLambda: framesPerLambda !== null && framesPerLambda !== void 0 ? framesPerLambda : null,
47
47
  composition,
48
48
  serveUrl: realServeUrl,
49
- inputProps,
49
+ inputProps: inputProps !== null && inputProps !== void 0 ? inputProps : {},
50
50
  codec: actualCodec,
51
- imageFormat,
51
+ imageFormat: imageFormat !== null && imageFormat !== void 0 ? imageFormat : 'jpeg',
52
52
  crf,
53
53
  envVariables,
54
54
  pixelFormat,
55
55
  proResProfile,
56
56
  quality,
57
- maxRetries,
58
- privacy,
57
+ maxRetries: maxRetries !== null && maxRetries !== void 0 ? maxRetries : 1,
58
+ privacy: privacy !== null && privacy !== void 0 ? privacy : 'public',
59
59
  logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
60
60
  frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
61
61
  outName: outName !== null && outName !== void 0 ? outName : null,
@@ -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());
@@ -0,0 +1,8 @@
1
+ import type { AwsRegion } from '../../client';
2
+ import type { LambdaRoutines } from '../../shared/constants';
3
+ export declare const getCloudwatchStreamUrl: ({ region, functionName, method, renderId, }: {
4
+ region: AwsRegion;
5
+ functionName: string;
6
+ method: LambdaRoutines;
7
+ renderId: string;
8
+ }) => string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCloudwatchStreamUrl = void 0;
4
+ const getCloudwatchStreamUrl = ({ region, functionName, method, renderId, }) => {
5
+ return `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#logsV2:log-groups/log-group/$252Faws$252Flambda$252F${functionName}/log-events$3FfilterPattern$3D$2522method$253D${method}$252CrenderId$253D${renderId}$2522`;
6
+ };
7
+ exports.getCloudwatchStreamUrl = getCloudwatchStreamUrl;
package/dist/cli/index.js CHANGED
@@ -133,7 +133,7 @@ AWS returned an "TooManyRequestsException" error message which could mean you re
133
133
  };
134
134
  exports.executeCommand = executeCommand;
135
135
  const cli = async () => {
136
- await cli_1.CliInternals.initializeRenderCli(cli_1.CliInternals.findRemotionRoot(), 'lambda');
136
+ await cli_1.CliInternals.initializeCli(cli_1.CliInternals.findRemotionRoot());
137
137
  await (0, exports.executeCommand)(args_1.parsedLambdaCli._);
138
138
  };
139
139
  exports.cli = cli;
@@ -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,
@@ -397,6 +418,9 @@ const launchHandler = async (params, options) => {
397
418
  await innerLaunchHandler(params, options);
398
419
  }
399
420
  catch (err) {
421
+ if (process.env.NODE_ENV === 'test') {
422
+ throw err;
423
+ }
400
424
  console.log('Error occurred', err);
401
425
  await (0, write_lambda_error_1.writeLambdaError)({
402
426
  bucketName: params.bucketName,
@@ -187,6 +187,9 @@ const rendererHandler = async (params, options) => {
187
187
  await renderHandler(params, options, logs);
188
188
  }
189
189
  catch (err) {
190
+ if (process.env.NODE_ENV === 'test') {
191
+ throw err;
192
+ }
190
193
  // If this error is encountered, we can just retry as it
191
194
  // is a very rare error to occur
192
195
  const isBrowserError = err.message.includes('FATAL:zygote_communication_linux.cc') ||
@@ -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,
@@ -101,7 +101,10 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
101
101
  serveUrl: lambdaParams.serveUrl,
102
102
  dumpBrowserLogs: false,
103
103
  envVariables: lambdaParams.envVariables,
104
- frame: lambdaParams.frame,
104
+ frame: renderer_1.RenderInternals.convertToPositiveFrameIndex({
105
+ frame: lambdaParams.frame,
106
+ durationInFrames: composition.durationInFrames,
107
+ }),
105
108
  imageFormat: lambdaParams.imageFormat,
106
109
  inputProps: lambdaParams.inputProps,
107
110
  overwrite: false,
@@ -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.27",
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.27",
36
+ "@remotion/cli": "3.2.27",
37
+ "@remotion/renderer": "3.2.27",
38
38
  "aws-policies": "^1.0.1",
39
39
  "mime-types": "2.1.34",
40
- "remotion": "3.2.24"
40
+ "remotion": "3.2.27"
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": "662c69bcb2fee4d51553b2f8e61635fb4d6688b1"
66
66
  }
Binary file