@remotion/lambda 4.1.0-alpha3 → 4.1.0-alpha5

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.
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCompositionsOnLambda = void 0;
4
- const renderer_1 = require("@remotion/renderer");
5
4
  const version_1 = require("remotion/version");
6
5
  const defaults_1 = require("../defaults");
7
6
  const call_lambda_1 = require("../shared/call-lambda");
8
- const serialize_input_props_1 = require("../shared/serialize-input-props");
7
+ const serialize_props_1 = require("../shared/serialize-props");
9
8
  /**
10
9
  * @description Returns the compositions from a serveUrl
11
10
  * @see [Documentation](https://remotion.dev/docs/lambda/getcompositionsonlambda)
@@ -21,11 +20,13 @@ const serialize_input_props_1 = require("../shared/serialize-input-props");
21
20
  */
22
21
  const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inputProps, functionName, envVariables, logLevel, timeoutInMilliseconds, forceBucketName: bucketName, dumpBrowserLogs, }) => {
23
22
  var _a;
24
- const serializedInputProps = await (0, serialize_input_props_1.serializeInputProps)({
25
- inputProps,
23
+ const stringifiedInputProps = (0, serialize_props_1.serializeOrThrow)(inputProps, 'input-props');
24
+ const serializedInputProps = await (0, serialize_props_1.serializeInputProps)({
25
+ stringifiedInputProps,
26
26
  region,
27
- type: 'still',
28
27
  userSpecifiedBucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
28
+ propsType: 'input-props',
29
+ needsToUpload: (0, serialize_props_1.getNeedsToUpload)('video-or-audio', stringifiedInputProps),
29
30
  });
30
31
  try {
31
32
  const res = await (0, call_lambda_1.callLambda)({
@@ -36,9 +37,7 @@ const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inpu
36
37
  serveUrl,
37
38
  envVariables,
38
39
  inputProps: serializedInputProps,
39
- logLevel: dumpBrowserLogs
40
- ? 'verbose'
41
- : logLevel !== null && logLevel !== void 0 ? logLevel : renderer_1.RenderInternals.getLogLevel(),
40
+ logLevel: dumpBrowserLogs ? 'verbose' : logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
42
41
  timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : 30000,
43
42
  version: version_1.VERSION,
44
43
  bucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRenderProgressPayload = exports.makeLambdaRenderMediaPayload = void 0;
4
4
  const version_1 = require("remotion/version");
5
5
  const defaults_1 = require("../defaults");
6
- const serialize_input_props_1 = require("../shared/serialize-input-props");
6
+ const serialize_props_1 = require("../shared/serialize-props");
7
7
  const validate_download_behavior_1 = require("../shared/validate-download-behavior");
8
8
  const validate_frames_per_lambda_1 = require("../shared/validate-frames-per-lambda");
9
9
  const validate_lambda_codec_1 = require("../shared/validate-lambda-codec");
10
10
  const validate_serveurl_1 = require("../shared/validate-serveurl");
11
- const renderer_1 = require("@remotion/renderer");
12
11
  const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, downloadBehavior, muted, overwrite, dumpBrowserLogs, jpegQuality, quality, }) => {
13
12
  if (quality) {
14
13
  throw new Error('quality has been renamed to jpegQuality. Please rename the option.');
@@ -20,18 +19,20 @@ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange,
20
19
  durationInFrames: 1,
21
20
  });
22
21
  (0, validate_download_behavior_1.validateDownloadBehavior)(downloadBehavior);
23
- const serializedInputProps = await (0, serialize_input_props_1.serializeInputProps)({
24
- inputProps: inputProps !== null && inputProps !== void 0 ? inputProps : {},
22
+ const stringifiedInputProps = (0, serialize_props_1.serializeOrThrow)(inputProps !== null && inputProps !== void 0 ? inputProps : {}, 'input-props');
23
+ const serialized = await (0, serialize_props_1.serializeInputProps)({
24
+ stringifiedInputProps,
25
25
  region,
26
- type: 'video-or-audio',
26
+ needsToUpload: (0, serialize_props_1.getNeedsToUpload)('video-or-audio', stringifiedInputProps),
27
27
  userSpecifiedBucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
28
+ propsType: 'input-props',
28
29
  });
29
30
  return {
30
31
  rendererFunctionName: rendererFunctionName !== null && rendererFunctionName !== void 0 ? rendererFunctionName : null,
31
32
  framesPerLambda: framesPerLambda !== null && framesPerLambda !== void 0 ? framesPerLambda : null,
32
33
  composition,
33
34
  serveUrl,
34
- inputProps: serializedInputProps,
35
+ inputProps: serialized,
35
36
  codec: actualCodec,
36
37
  imageFormat: imageFormat !== null && imageFormat !== void 0 ? imageFormat : 'jpeg',
37
38
  crf,
@@ -41,9 +42,7 @@ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange,
41
42
  jpegQuality,
42
43
  maxRetries: maxRetries !== null && maxRetries !== void 0 ? maxRetries : 1,
43
44
  privacy: privacy !== null && privacy !== void 0 ? privacy : 'public',
44
- logLevel: dumpBrowserLogs
45
- ? 'verbose'
46
- : logLevel !== null && logLevel !== void 0 ? logLevel : renderer_1.RenderInternals.getLogLevel(),
45
+ logLevel: dumpBrowserLogs ? 'verbose' : logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
47
46
  frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
48
47
  outName: outName !== null && outName !== void 0 ? outName : null,
49
48
  timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : 30000,
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderStillOnLambda = void 0;
4
- const renderer_1 = require("@remotion/renderer");
5
4
  const version_1 = require("remotion/version");
6
5
  const call_lambda_1 = require("../shared/call-lambda");
7
6
  const constants_1 = require("../shared/constants");
8
7
  const get_aws_urls_1 = require("../shared/get-aws-urls");
9
- const serialize_input_props_1 = require("../shared/serialize-input-props");
8
+ const serialize_props_1 = require("../shared/serialize-props");
10
9
  /**
11
10
  * @description Renders a still frame on Lambda
12
11
  * @link https://remotion.dev/docs/lambda/renderstillonlambda
@@ -28,11 +27,13 @@ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFo
28
27
  if (quality) {
29
28
  throw new Error('The `quality` option is deprecated. Use `jpegQuality` instead.');
30
29
  }
31
- const serializedInputProps = await (0, serialize_input_props_1.serializeInputProps)({
32
- inputProps,
30
+ const stringifiedInputProps = (0, serialize_props_1.serializeOrThrow)(inputProps, 'input-props');
31
+ const serializedInputProps = await (0, serialize_props_1.serializeInputProps)({
32
+ stringifiedInputProps,
33
33
  region,
34
- type: 'still',
34
+ needsToUpload: (0, serialize_props_1.getNeedsToUpload)('still', stringifiedInputProps),
35
35
  userSpecifiedBucketName: forceBucketName !== null && forceBucketName !== void 0 ? forceBucketName : null,
36
+ propsType: 'input-props',
36
37
  });
37
38
  try {
38
39
  const res = await (0, call_lambda_1.callLambda)({
@@ -49,9 +50,7 @@ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFo
49
50
  frame: frame !== null && frame !== void 0 ? frame : 0,
50
51
  privacy,
51
52
  attempt: 1,
52
- logLevel: dumpBrowserLogs
53
- ? 'verbose'
54
- : logLevel !== null && logLevel !== void 0 ? logLevel : renderer_1.RenderInternals.getLogLevel(),
53
+ logLevel: dumpBrowserLogs ? 'verbose' : logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
55
54
  outName: outName !== null && outName !== void 0 ? outName : null,
56
55
  timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : 30000,
57
56
  chromiumOptions: chromiumOptions !== null && chromiumOptions !== void 0 ? chromiumOptions : {},
package/dist/cli/log.d.ts CHANGED
@@ -2,19 +2,19 @@ export declare const Log: {
2
2
  verbose: (message?: any, ...optionalParams: any[]) => void;
3
3
  verboseAdvanced: (options: {
4
4
  indent: boolean;
5
- logLevel: "error" | "verbose" | "info" | "warn";
5
+ logLevel: "warn" | "error" | "verbose" | "info";
6
6
  } & {
7
7
  tag?: string | undefined;
8
8
  }, message?: any, ...optionalParams: any[]) => void;
9
9
  info: (message?: any, ...optionalParams: any[]) => void;
10
10
  infoAdvanced: (options: {
11
11
  indent: boolean;
12
- logLevel: "error" | "verbose" | "info" | "warn";
12
+ logLevel: "warn" | "error" | "verbose" | "info";
13
13
  }, message?: any, ...optionalParams: any[]) => void;
14
14
  warn: (message?: any, ...optionalParams: any[]) => void;
15
15
  warnAdvanced: (options: {
16
16
  indent: boolean;
17
- logLevel: "error" | "verbose" | "info" | "warn";
17
+ logLevel: "warn" | "error" | "verbose" | "info";
18
18
  }, message?: any, ...optionalParams: any[]) => void;
19
19
  error: (message?: any, ...optionalParams: any[]) => void;
20
20
  };
@@ -3,5 +3,8 @@ export declare const planFrameRanges: ({ framesPerLambda, frameRange, everyNthFr
3
3
  frameRange: [number, number];
4
4
  everyNthFrame: number;
5
5
  }) => {
6
- chunks: [number, number][];
6
+ chunks: [
7
+ number,
8
+ number
9
+ ][];
7
10
  };
@@ -3,6 +3,6 @@ type Options = {
3
3
  expectedBucketOwner: string;
4
4
  };
5
5
  export declare const compositionsHandler: (lambdaParams: LambdaPayload, options: Options) => Promise<{
6
- compositions: import("remotion").AnyCompMetadata[];
6
+ compositions: import("remotion").VideoConfig[];
7
7
  }>;
8
8
  export {};
@@ -6,9 +6,9 @@ const version_1 = require("remotion/version");
6
6
  const get_or_create_bucket_1 = require("../api/get-or-create-bucket");
7
7
  const defaults_1 = require("../defaults");
8
8
  const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
9
- const deserialize_input_props_1 = require("../shared/deserialize-input-props");
10
9
  const get_browser_instance_1 = require("./helpers/get-browser-instance");
11
10
  const get_current_region_1 = require("./helpers/get-current-region");
11
+ const serialize_props_1 = require("../shared/serialize-props");
12
12
  const compositionsHandler = async (lambdaParams, options) => {
13
13
  var _a, _b, _c;
14
14
  if (lambdaParams.type !== defaults_1.LambdaRoutines.compositions) {
@@ -27,11 +27,12 @@ const compositionsHandler = async (lambdaParams, options) => {
27
27
  }).then((b) => b.bucketName),
28
28
  (0, get_browser_instance_1.getBrowserInstance)(lambdaParams.logLevel, false, (_b = lambdaParams.chromiumOptions) !== null && _b !== void 0 ? _b : {}),
29
29
  ]);
30
- const inputProps = await (0, deserialize_input_props_1.deserializeInputProps)({
30
+ const inputProps = await (0, serialize_props_1.deserializeInputProps)({
31
31
  bucketName,
32
32
  expectedBucketOwner: options.expectedBucketOwner,
33
33
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
34
34
  serialized: lambdaParams.inputProps,
35
+ propsType: 'input-props',
35
36
  });
36
37
  const realServeUrl = (0, convert_to_serve_url_1.convertToServeUrl)({
37
38
  urlOrId: lambdaParams.serveUrl,
@@ -1 +1 @@
1
- export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "ap-south-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "sa-east-1" | "eu-south-1" | "af-south-1" | "ap-east-1" | "me-south-1";
1
+ export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-south-1" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "af-south-1" | "ap-south-1" | "ap-east-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "me-south-1" | "sa-east-1";
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.printCloudwatchHelper = void 0;
4
+ const renderer_1 = require("@remotion/renderer");
4
5
  const printCloudwatchHelper = (type, data) => {
5
6
  const d = Object.keys(data).reduce((a, b) => {
6
7
  return [...a, `${b}=${data[b]}`];
7
8
  }, []);
8
9
  const msg = [`method=${type}`, ...d].join(',');
9
- console.log(msg);
10
+ renderer_1.RenderInternals.Log.info(msg);
10
11
  };
11
12
  exports.printCloudwatchHelper = printCloudwatchHelper;
@@ -1,5 +1,5 @@
1
1
  import type { ChromiumOptions, LogLevel, openBrowser, RemotionServer } from '@remotion/renderer';
2
- import type { AnyCompMetadata } from 'remotion';
2
+ import type { VideoConfig } from 'remotion';
3
3
  import type { Await } from '../../shared/await';
4
4
  type ValidateCompositionOptions = {
5
5
  serveUrl: string;
@@ -15,5 +15,5 @@ type ValidateCompositionOptions = {
15
15
  logLevel: LogLevel;
16
16
  server: RemotionServer | undefined;
17
17
  };
18
- export declare const validateComposition: ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }: ValidateCompositionOptions) => Promise<AnyCompMetadata>;
18
+ export declare const validateComposition: ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }: ValidateCompositionOptions) => Promise<VideoConfig>;
19
19
  export {};
@@ -4,7 +4,7 @@ exports.validateComposition = void 0;
4
4
  const renderer_1 = require("@remotion/renderer");
5
5
  const get_chromium_executable_path_1 = require("./get-chromium-executable-path");
6
6
  const validateComposition = async ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }) => {
7
- const comp = await renderer_1.RenderInternals.internalSelectComposition({
7
+ const { metadata: comp } = await renderer_1.RenderInternals.internalSelectComposition({
8
8
  id: composition,
9
9
  puppeteerInstance: browserInstance,
10
10
  inputProps,
@@ -23,6 +23,8 @@ const validateComposition = async ({ serveUrl, composition, browserInstance, inp
23
23
  ...comp,
24
24
  height: forceHeight !== null && forceHeight !== void 0 ? forceHeight : comp.height,
25
25
  width: forceWidth !== null && forceWidth !== void 0 ? forceWidth : comp.width,
26
+ defaultProps: comp.defaultProps,
27
+ props: comp.props,
26
28
  };
27
29
  };
28
30
  exports.validateComposition = validateComposition;
@@ -79,7 +79,7 @@ exports.handler = (0, streamify_response_1.streamifyResponse)(async (params, res
79
79
  renderId: params.renderId,
80
80
  chunk: String(params.chunk),
81
81
  dumpLogs: String(renderer_1.RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose')),
82
- inputProps: JSON.stringify(params.inputProps),
82
+ resolvedProps: JSON.stringify(params.resolvedProps),
83
83
  isWarm,
84
84
  });
85
85
  await (0, renderer_2.rendererHandler)(params, {
@@ -33,7 +33,6 @@ const version_1 = require("remotion/version");
33
33
  const aws_clients_1 = require("../shared/aws-clients");
34
34
  const cleanup_serialized_input_props_1 = require("../shared/cleanup-serialized-input-props");
35
35
  const constants_1 = require("../shared/constants");
36
- const deserialize_input_props_1 = require("../shared/deserialize-input-props");
37
36
  const docs_url_1 = require("../shared/docs-url");
38
37
  const invoke_webhook_1 = require("../shared/invoke-webhook");
39
38
  const make_s3_url_1 = require("../shared/make-s3-url");
@@ -57,6 +56,7 @@ const timer_1 = require("./helpers/timer");
57
56
  const validate_composition_1 = require("./helpers/validate-composition");
58
57
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
59
58
  const write_post_render_data_1 = require("./helpers/write-post-render-data");
59
+ const serialize_props_1 = require("../shared/serialize-props");
60
60
  const callFunctionWithRetry = async ({ payload, retries, functionName, }) => {
61
61
  try {
62
62
  await (0, aws_clients_1.getLambdaClient)((0, get_current_region_1.getCurrentRegionInFunction)()).send(new client_lambda_1.InvokeCommand({
@@ -136,11 +136,12 @@ const innerLaunchHandler = async (params, options) => {
136
136
  }
137
137
  }, Math.max(options.getRemainingTimeInMillis() - 1000, 1000));
138
138
  const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(params.logLevel, false, params.chromiumOptions);
139
- const inputPropsPromise = (0, deserialize_input_props_1.deserializeInputProps)({
139
+ const inputPropsPromise = (0, serialize_props_1.deserializeInputProps)({
140
140
  bucketName: params.bucketName,
141
141
  expectedBucketOwner: options.expectedBucketOwner,
142
142
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
143
143
  serialized: params.inputProps,
144
+ propsType: 'input-props',
144
145
  });
145
146
  const comp = await (0, validate_composition_1.validateComposition)({
146
147
  serveUrl: params.serveUrl,
@@ -188,6 +189,25 @@ const innerLaunchHandler = async (params, options) => {
188
189
  });
189
190
  const sortedChunks = chunks.slice().sort((a, b) => a[0] - b[0]);
190
191
  const reqSend = (0, timer_1.timer)('sending off requests');
192
+ const serializedResolved = (0, serialize_props_1.serializeOrThrow)(comp.props, 'resolved-props');
193
+ const serializedDefault = (0, serialize_props_1.serializeOrThrow)(comp.defaultProps, 'default-props');
194
+ const needsToUpload = (0, serialize_props_1.getNeedsToUpload)('video-or-audio', serializedResolved + serializedDefault);
195
+ const [serializedResolvedProps, serializedDefaultProps] = await Promise.all([
196
+ (0, serialize_props_1.serializeInputProps)({
197
+ propsType: 'resolved-props',
198
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
199
+ stringifiedInputProps: serializedResolved,
200
+ userSpecifiedBucketName: params.bucketName,
201
+ needsToUpload,
202
+ }),
203
+ (0, serialize_props_1.serializeInputProps)({
204
+ propsType: 'default-props',
205
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
206
+ stringifiedInputProps: serializedDefault,
207
+ userSpecifiedBucketName: params.bucketName,
208
+ needsToUpload,
209
+ }),
210
+ ]);
191
211
  const lambdaPayloads = chunks.map((chunkPayload) => {
192
212
  var _a;
193
213
  const payload = {
@@ -225,6 +245,8 @@ const innerLaunchHandler = async (params, options) => {
225
245
  launchFunctionConfig: {
226
246
  version: version_1.VERSION,
227
247
  },
248
+ resolvedProps: serializedResolvedProps,
249
+ defaultProps: serializedDefaultProps,
228
250
  };
229
251
  return payload;
230
252
  });
@@ -12,12 +12,12 @@ const version_1 = require("remotion/version");
12
12
  const aws_clients_1 = require("../shared/aws-clients");
13
13
  const chunk_progress_1 = require("../shared/chunk-progress");
14
14
  const constants_1 = require("../shared/constants");
15
- const deserialize_input_props_1 = require("../shared/deserialize-input-props");
16
15
  const get_browser_instance_1 = require("./helpers/get-browser-instance");
17
16
  const get_chromium_executable_path_1 = require("./helpers/get-chromium-executable-path");
18
17
  const get_current_region_1 = require("./helpers/get-current-region");
19
18
  const io_1 = require("./helpers/io");
20
19
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
20
+ const serialize_props_1 = require("../shared/serialize-props");
21
21
  const renderHandler = async (params, options, logs) => {
22
22
  var _a;
23
23
  if (params.type !== constants_1.LambdaRoutines.renderer) {
@@ -26,11 +26,26 @@ const renderHandler = async (params, options, logs) => {
26
26
  if (params.launchFunctionConfig.version !== version_1.VERSION) {
27
27
  throw new Error(`The version of the function that was specified as "rendererFunctionName" is ${version_1.VERSION} but the version of the function that invoked the render is ${params.launchFunctionConfig.version}. Please make sure that the version of the function that is specified as "rendererFunctionName" is the same as the version of the function that is invoked.`);
28
28
  }
29
- const inputPropsPromise = (0, deserialize_input_props_1.deserializeInputProps)({
29
+ const inputPropsPromise = (0, serialize_props_1.deserializeInputProps)({
30
30
  bucketName: params.bucketName,
31
31
  expectedBucketOwner: options.expectedBucketOwner,
32
32
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
33
33
  serialized: params.inputProps,
34
+ propsType: 'input-props',
35
+ });
36
+ const resolvedPropsPromise = (0, serialize_props_1.deserializeInputProps)({
37
+ bucketName: params.bucketName,
38
+ expectedBucketOwner: options.expectedBucketOwner,
39
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
40
+ serialized: params.resolvedProps,
41
+ propsType: 'resolved-props',
42
+ });
43
+ const defaultPropsPromise = (0, serialize_props_1.deserializeInputProps)({
44
+ bucketName: params.bucketName,
45
+ expectedBucketOwner: options.expectedBucketOwner,
46
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
47
+ serialized: params.defaultProps,
48
+ propsType: 'default-props',
34
49
  });
35
50
  const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(params.logLevel, false, (_a = params.chromiumOptions) !== null && _a !== void 0 ? _a : {});
36
51
  const outputPath = renderer_1.RenderInternals.tmpDir('remotion-render-');
@@ -57,6 +72,8 @@ const renderHandler = async (params, options, logs) => {
57
72
  }))}`);
58
73
  const downloads = {};
59
74
  const inputProps = await inputPropsPromise;
75
+ const resolvedProps = await resolvedPropsPromise;
76
+ const defaultProps = await defaultPropsPromise;
60
77
  await new Promise((resolve, reject) => {
61
78
  var _a, _b, _c, _d;
62
79
  renderer_1.RenderInternals.internalRenderMedia({
@@ -66,6 +83,8 @@ const renderHandler = async (params, options, logs) => {
66
83
  fps: params.fps,
67
84
  height: params.height,
68
85
  width: params.width,
86
+ props: resolvedProps,
87
+ defaultProps,
69
88
  },
70
89
  imageFormat: params.imageFormat,
71
90
  inputProps,
@@ -15,7 +15,6 @@ const aws_clients_1 = require("../shared/aws-clients");
15
15
  const cleanup_serialized_input_props_1 = require("../shared/cleanup-serialized-input-props");
16
16
  const constants_1 = require("../shared/constants");
17
17
  const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
18
- const deserialize_input_props_1 = require("../shared/deserialize-input-props");
19
18
  const make_s3_url_1 = require("../shared/make-s3-url");
20
19
  const random_hash_1 = require("../shared/random-hash");
21
20
  const validate_download_behavior_1 = require("../shared/validate-download-behavior");
@@ -30,6 +29,7 @@ const get_output_url_from_metadata_1 = require("./helpers/get-output-url-from-me
30
29
  const io_1 = require("./helpers/io");
31
30
  const validate_composition_1 = require("./helpers/validate-composition");
32
31
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
32
+ const serialize_props_1 = require("../shared/serialize-props");
33
33
  const innerStillHandler = async (lambdaParams, renderId, options) => {
34
34
  var _a, _b, _c, _d, _e, _f;
35
35
  if (lambdaParams.type !== constants_1.LambdaRoutines.still) {
@@ -54,11 +54,12 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
54
54
  const outputDir = renderer_1.RenderInternals.tmpDir('remotion-render-');
55
55
  const outputPath = node_path_1.default.join(outputDir, 'output');
56
56
  const region = (0, get_current_region_1.getCurrentRegionInFunction)();
57
- const inputProps = await (0, deserialize_input_props_1.deserializeInputProps)({
57
+ const inputProps = await (0, serialize_props_1.deserializeInputProps)({
58
58
  bucketName,
59
59
  expectedBucketOwner: options.expectedBucketOwner,
60
60
  region,
61
61
  serialized: lambdaParams.inputProps,
62
+ propsType: 'input-props',
62
63
  });
63
64
  const serveUrl = (0, convert_to_serve_url_1.convertToServeUrl)({
64
65
  urlOrId: lambdaParams.serveUrl,
@@ -79,7 +79,9 @@ export declare const outName: (renderId: string, extension: string) => string;
79
79
  export declare const outStillName: (renderId: string, imageFormat: StillImageFormat) => string;
80
80
  export declare const customOutName: (renderId: string, bucketName: string, name: OutNameInput) => OutNameOutput;
81
81
  export declare const postRenderDataKey: (renderId: string) => string;
82
+ export declare const defaultPropsKey: (hash: string) => string;
82
83
  export declare const inputPropsKey: (hash: string) => string;
84
+ export declare const resolvedPropsKey: (hash: string) => string;
83
85
  export declare const RENDERER_PATH_TOKEN = "remotion-bucket";
84
86
  export declare const CONCAT_FOLDER_TOKEN = "remotion-concat";
85
87
  export declare const REMOTION_CONCATED_TOKEN = "remotion-concated-token";
@@ -102,7 +104,7 @@ export type SerializedInputProps = {
102
104
  hash: string;
103
105
  } | {
104
106
  type: 'payload';
105
- payload: unknown;
107
+ payload: string;
106
108
  };
107
109
  export type LambdaStartPayload = {
108
110
  rendererFunctionName: string | null;
@@ -218,6 +220,8 @@ export type LambdaPayloads = {
218
220
  logLevel: LogLevel;
219
221
  timeoutInMilliseconds: number;
220
222
  chromiumOptions: ChromiumOptions;
223
+ resolvedProps: SerializedInputProps;
224
+ defaultProps: SerializedInputProps;
221
225
  scale: number;
222
226
  everyNthFrame: number;
223
227
  muted: boolean;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LAMBDA_BURST_LIMIT_QUOTA = exports.LAMBDA_CONCURRENCY_LIMIT_QUOTA = exports.LambdaRoutines = exports.REMOTION_FILELIST_TOKEN = exports.REMOTION_CONCATED_TOKEN = exports.CONCAT_FOLDER_TOKEN = exports.RENDERER_PATH_TOKEN = exports.inputPropsKey = exports.postRenderDataKey = exports.customOutName = exports.outStillName = exports.outName = exports.getSitesKey = exports.getErrorFileName = exports.getErrorKeyPrefix = exports.chunkKeyForIndex = exports.chunkKey = exports.lambdaTimingsKey = exports.lambdaLogsPrefix = exports.lambdaTimingsPrefixForChunk = exports.lambdaTimingsPrefix = exports.lambdaChunkInitializedKey = exports.lambdaChunkInitializedPrefix = exports.initalizedMetadataKey = exports.renderMetadataKey = exports.encodingProgressKey = exports.rendersPrefix = exports.LOG_GROUP_PREFIX = exports.RENDER_FN_PREFIX = exports.REMOTION_BUCKET_PREFIX = exports.ENCODING_PROGRESS_STEP_SIZE = exports.DEFAULT_CLOUDWATCH_RETENTION_PERIOD = exports.DEFAULT_OUTPUT_PRIVACY = exports.MAX_EPHEMERAL_STORAGE_IN_MB = exports.MIN_EPHEMERAL_STORAGE_IN_MB = exports.DEFAULT_EPHEMERAL_STORAGE_IN_MB = exports.MAX_FUNCTIONS_PER_RENDER = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_REGION = exports.COMMAND_NOT_FOUND = exports.BINARY_NAME = exports.DEFAULT_FRAMES_PER_LAMBDA = exports.MINIMUM_FRAMES_PER_LAMBDA = exports.MAX_TIMEOUT = exports.MIN_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.DEFAULT_MEMORY_SIZE = exports.MAX_MEMORY = exports.MIN_MEMORY = void 0;
3
+ exports.LAMBDA_CONCURRENCY_LIMIT_QUOTA = exports.LambdaRoutines = exports.REMOTION_FILELIST_TOKEN = exports.REMOTION_CONCATED_TOKEN = exports.CONCAT_FOLDER_TOKEN = exports.RENDERER_PATH_TOKEN = exports.resolvedPropsKey = exports.inputPropsKey = exports.defaultPropsKey = exports.postRenderDataKey = exports.customOutName = exports.outStillName = exports.outName = exports.getSitesKey = exports.getErrorFileName = exports.getErrorKeyPrefix = exports.chunkKeyForIndex = exports.chunkKey = exports.lambdaTimingsKey = exports.lambdaLogsPrefix = exports.lambdaTimingsPrefixForChunk = exports.lambdaTimingsPrefix = exports.lambdaChunkInitializedKey = exports.lambdaChunkInitializedPrefix = exports.initalizedMetadataKey = exports.renderMetadataKey = exports.encodingProgressKey = exports.rendersPrefix = exports.LOG_GROUP_PREFIX = exports.RENDER_FN_PREFIX = exports.REMOTION_BUCKET_PREFIX = exports.ENCODING_PROGRESS_STEP_SIZE = exports.DEFAULT_CLOUDWATCH_RETENTION_PERIOD = exports.DEFAULT_OUTPUT_PRIVACY = exports.MAX_EPHEMERAL_STORAGE_IN_MB = exports.MIN_EPHEMERAL_STORAGE_IN_MB = exports.DEFAULT_EPHEMERAL_STORAGE_IN_MB = exports.MAX_FUNCTIONS_PER_RENDER = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_REGION = exports.COMMAND_NOT_FOUND = exports.BINARY_NAME = exports.DEFAULT_FRAMES_PER_LAMBDA = exports.MINIMUM_FRAMES_PER_LAMBDA = exports.MAX_TIMEOUT = exports.MIN_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.DEFAULT_MEMORY_SIZE = exports.MAX_MEMORY = exports.MIN_MEMORY = void 0;
4
+ exports.LAMBDA_BURST_LIMIT_QUOTA = void 0;
4
5
  exports.MIN_MEMORY = 512;
5
6
  exports.MAX_MEMORY = 10240;
6
7
  exports.DEFAULT_MEMORY_SIZE = 2048;
@@ -77,10 +78,18 @@ const postRenderDataKey = (renderId) => {
77
78
  return `${(0, exports.rendersPrefix)(renderId)}/post-render-metadata.json`;
78
79
  };
79
80
  exports.postRenderDataKey = postRenderDataKey;
81
+ const defaultPropsKey = (hash) => {
82
+ return `default-props/${hash}.json`;
83
+ };
84
+ exports.defaultPropsKey = defaultPropsKey;
80
85
  const inputPropsKey = (hash) => {
81
86
  return `input-props/${hash}.json`;
82
87
  };
83
88
  exports.inputPropsKey = inputPropsKey;
89
+ const resolvedPropsKey = (hash) => {
90
+ return `resolved-props/${hash}.json`;
91
+ };
92
+ exports.resolvedPropsKey = resolvedPropsKey;
84
93
  exports.RENDERER_PATH_TOKEN = 'remotion-bucket';
85
94
  exports.CONCAT_FOLDER_TOKEN = 'remotion-concat';
86
95
  exports.REMOTION_CONCATED_TOKEN = 'remotion-concated-token';
@@ -0,0 +1,20 @@
1
+ import type { AwsRegion } from '../client';
2
+ import type { SerializedInputProps } from './constants';
3
+ type PropsType = 'input-props' | 'resolved-props' | 'default-props';
4
+ export declare const serializeOrThrow: (inputProps: Record<string, unknown>, propsType: PropsType) => string;
5
+ export declare const getNeedsToUpload: (type: 'still' | 'video-or-audio', stringifiedInputProps: string) => boolean;
6
+ export declare const serializeInputProps: ({ stringifiedInputProps, region, userSpecifiedBucketName, propsType, needsToUpload, }: {
7
+ stringifiedInputProps: string;
8
+ region: AwsRegion;
9
+ userSpecifiedBucketName: string | null;
10
+ propsType: PropsType;
11
+ needsToUpload: boolean;
12
+ }) => Promise<SerializedInputProps>;
13
+ export declare const deserializeInputProps: ({ serialized, region, bucketName, expectedBucketOwner, propsType, }: {
14
+ serialized: SerializedInputProps;
15
+ region: AwsRegion;
16
+ bucketName: string;
17
+ expectedBucketOwner: string;
18
+ propsType: PropsType;
19
+ }) => Promise<Record<string, unknown>>;
20
+ export {};
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeInputProps = exports.serializeInputProps = exports.getNeedsToUpload = exports.serializeOrThrow = void 0;
4
+ const get_or_create_bucket_1 = require("../api/get-or-create-bucket");
5
+ const io_1 = require("../functions/helpers/io");
6
+ const constants_1 = require("./constants");
7
+ const random_hash_1 = require("./random-hash");
8
+ const stream_to_string_1 = require("./stream-to-string");
9
+ const serializeOrThrow = (inputProps, propsType) => {
10
+ try {
11
+ const payload = JSON.stringify(inputProps);
12
+ return payload;
13
+ }
14
+ catch (err) {
15
+ throw new Error(`Error serializing ${propsType}. Check it has no circular references or reduce the size if the object is big.`);
16
+ }
17
+ };
18
+ exports.serializeOrThrow = serializeOrThrow;
19
+ const getNeedsToUpload = (type, stringifiedInputProps) => {
20
+ const MAX_INLINE_PAYLOAD_SIZE = type === 'still' ? 5000000 : 200000;
21
+ if (stringifiedInputProps.length > MAX_INLINE_PAYLOAD_SIZE) {
22
+ console.warn(`Warning: The props are over ${Math.round(MAX_INLINE_PAYLOAD_SIZE / 1000)}KB (${Math.ceil(stringifiedInputProps.length / 1024)}KB) in size. Uploading them to S3 to circumvent AWS Lambda payload size, which may lead to slowdown.`);
23
+ return true;
24
+ }
25
+ return false;
26
+ };
27
+ exports.getNeedsToUpload = getNeedsToUpload;
28
+ const serializeInputProps = async ({ stringifiedInputProps, region, userSpecifiedBucketName, propsType, needsToUpload, }) => {
29
+ const hash = (0, random_hash_1.randomHash)();
30
+ if (needsToUpload) {
31
+ const bucketName = userSpecifiedBucketName !== null && userSpecifiedBucketName !== void 0 ? userSpecifiedBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
32
+ region,
33
+ })).bucketName;
34
+ await (0, io_1.lambdaWriteFile)({
35
+ body: stringifiedInputProps,
36
+ bucketName,
37
+ region,
38
+ customCredentials: null,
39
+ downloadBehavior: null,
40
+ expectedBucketOwner: null,
41
+ key: makeKey(propsType, hash),
42
+ privacy: 'public',
43
+ });
44
+ return {
45
+ type: 'bucket-url',
46
+ hash,
47
+ };
48
+ }
49
+ return {
50
+ type: 'payload',
51
+ payload: stringifiedInputProps,
52
+ };
53
+ };
54
+ exports.serializeInputProps = serializeInputProps;
55
+ const deserializeInputProps = async ({ serialized, region, bucketName, expectedBucketOwner, propsType, }) => {
56
+ if (serialized.type === 'payload') {
57
+ return JSON.parse(serialized.payload);
58
+ }
59
+ try {
60
+ const response = await (0, io_1.lambdaReadFile)({
61
+ bucketName,
62
+ expectedBucketOwner,
63
+ key: makeKey(propsType, serialized.hash),
64
+ region,
65
+ });
66
+ const body = await (0, stream_to_string_1.streamToString)(response);
67
+ const payload = JSON.parse(body);
68
+ return payload;
69
+ }
70
+ catch (err) {
71
+ throw new Error(`Failed to parse input props that were serialized: ${err.stack}`);
72
+ }
73
+ };
74
+ exports.deserializeInputProps = deserializeInputProps;
75
+ const makeKey = (type, hash) => {
76
+ if (type === 'input-props') {
77
+ return (0, constants_1.inputPropsKey)(hash);
78
+ }
79
+ if (type === 'default-props') {
80
+ return (0, constants_1.defaultPropsKey)(hash);
81
+ }
82
+ return (0, constants_1.resolvedPropsKey)(hash);
83
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.1.0-alpha3",
3
+ "version": "4.1.0-alpha5",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -25,10 +25,10 @@
25
25
  "@aws-sdk/s3-request-presigner": "3.338.0",
26
26
  "aws-policies": "^1.0.1",
27
27
  "mime-types": "2.1.34",
28
- "@remotion/bundler": "4.1.0-alpha3",
29
- "@remotion/cli": "4.1.0-alpha3",
30
- "@remotion/renderer": "4.1.0-alpha3",
31
- "remotion": "4.1.0-alpha3"
28
+ "@remotion/bundler": "4.1.0-alpha5",
29
+ "@remotion/renderer": "4.1.0-alpha5",
30
+ "@remotion/cli": "4.1.0-alpha5",
31
+ "remotion": "4.1.0-alpha5"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@jonny/eslint-config": "3.0.266",
@@ -43,11 +43,11 @@
43
43
  "typescript": "4.9.5",
44
44
  "vitest": "0.31.1",
45
45
  "zip-lib": "^0.7.2",
46
- "@remotion/bundler": "4.1.0-alpha3",
47
- "@remotion/compositor-linux-arm64-gnu": "4.1.0-alpha3"
46
+ "@remotion/bundler": "4.1.0-alpha5",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.1.0-alpha5"
48
48
  },
49
49
  "peerDependencies": {
50
- "@remotion/bundler": "4.1.0-alpha3"
50
+ "@remotion/bundler": "4.1.0-alpha5"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
Binary file
Binary file
@@ -1,8 +0,0 @@
1
- import type { AwsRegion } from '../client';
2
- import type { SerializedInputProps } from './constants';
3
- export declare const deserializeInputProps: ({ serialized, region, bucketName, expectedBucketOwner, }: {
4
- serialized: SerializedInputProps;
5
- region: AwsRegion;
6
- bucketName: string;
7
- expectedBucketOwner: string;
8
- }) => Promise<Record<string, unknown>>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deserializeInputProps = void 0;
4
- const io_1 = require("../functions/helpers/io");
5
- const constants_1 = require("./constants");
6
- const stream_to_string_1 = require("./stream-to-string");
7
- const deserializeInputProps = async ({ serialized, region, bucketName, expectedBucketOwner, }) => {
8
- if (serialized.type === 'payload') {
9
- return JSON.parse(serialized.payload);
10
- }
11
- try {
12
- const response = await (0, io_1.lambdaReadFile)({
13
- bucketName,
14
- expectedBucketOwner,
15
- key: (0, constants_1.inputPropsKey)(serialized.hash),
16
- region,
17
- });
18
- const body = await (0, stream_to_string_1.streamToString)(response);
19
- const payload = JSON.parse(body);
20
- return payload;
21
- }
22
- catch (err) {
23
- throw new Error(`Failed to parse input props that were serialized: ${err.stack}`);
24
- }
25
- };
26
- exports.deserializeInputProps = deserializeInputProps;
@@ -1,8 +0,0 @@
1
- import type { AwsRegion } from '../client';
2
- import type { SerializedInputProps } from './constants';
3
- export declare const serializeInputProps: ({ inputProps, region, type, userSpecifiedBucketName, }: {
4
- inputProps: Record<string, unknown>;
5
- region: AwsRegion;
6
- type: 'still' | 'video-or-audio';
7
- userSpecifiedBucketName: string | null;
8
- }) => Promise<SerializedInputProps>;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeInputProps = void 0;
4
- const get_or_create_bucket_1 = require("../api/get-or-create-bucket");
5
- const io_1 = require("../functions/helpers/io");
6
- const constants_1 = require("./constants");
7
- const random_hash_1 = require("./random-hash");
8
- const serializeInputProps = async ({ inputProps = {}, region, type, userSpecifiedBucketName, }) => {
9
- try {
10
- const payload = JSON.stringify(inputProps);
11
- const hash = (0, random_hash_1.randomHash)();
12
- const MAX_INLINE_PAYLOAD_SIZE = type === 'still' ? 5000000 : 200000;
13
- if (payload.length > MAX_INLINE_PAYLOAD_SIZE) {
14
- console.warn(`Warning: inputProps are over ${Math.round(MAX_INLINE_PAYLOAD_SIZE / 1000)}KB (${Math.ceil(payload.length / 1024)}KB) in size. Uploading them to S3 to circumvent AWS Lambda payload size.`);
15
- const bucketName = userSpecifiedBucketName !== null && userSpecifiedBucketName !== void 0 ? userSpecifiedBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
16
- region,
17
- })).bucketName;
18
- await (0, io_1.lambdaWriteFile)({
19
- body: payload,
20
- bucketName,
21
- region,
22
- customCredentials: null,
23
- downloadBehavior: null,
24
- expectedBucketOwner: null,
25
- key: (0, constants_1.inputPropsKey)(hash),
26
- privacy: 'public',
27
- });
28
- return {
29
- type: 'bucket-url',
30
- hash,
31
- };
32
- }
33
- return {
34
- type: 'payload',
35
- payload,
36
- };
37
- }
38
- catch (err) {
39
- throw new Error('Error serializing inputProps. Check it has no circular references or reduce the size if the object is big.');
40
- }
41
- };
42
- exports.serializeInputProps = serializeInputProps;