@remotion/lambda 4.1.0-alpha3 → 4.1.0-alpha8

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.
Files changed (34) hide show
  1. package/dist/api/get-compositions-on-lambda.d.ts +2 -2
  2. package/dist/api/get-compositions-on-lambda.js +7 -8
  3. package/dist/api/make-lambda-payload.js +8 -9
  4. package/dist/api/render-still-on-lambda.js +7 -8
  5. package/dist/cli/commands/render/render.js +8 -3
  6. package/dist/cli/commands/still.js +8 -3
  7. package/dist/cli/log.d.ts +3 -3
  8. package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +4 -1
  9. package/dist/functions/compositions.d.ts +1 -1
  10. package/dist/functions/compositions.js +4 -3
  11. package/dist/functions/helpers/get-current-region.d.ts +1 -1
  12. package/dist/functions/helpers/get-progress.js +0 -6
  13. package/dist/functions/helpers/make-timeout-message.js +2 -0
  14. package/dist/functions/helpers/print-cloudwatch-helper.js +2 -1
  15. package/dist/functions/helpers/validate-composition.d.ts +3 -3
  16. package/dist/functions/helpers/validate-composition.js +3 -3
  17. package/dist/functions/index.js +1 -1
  18. package/dist/functions/launch.js +18 -5
  19. package/dist/functions/renderer.js +14 -4
  20. package/dist/functions/still.js +15 -4
  21. package/dist/shared/compress-props.d.ts +20 -0
  22. package/dist/shared/compress-props.js +85 -0
  23. package/dist/shared/constants.d.ts +6 -3
  24. package/dist/shared/constants.js +10 -1
  25. package/dist/shared/invoke-webhook.d.ts +0 -2
  26. package/dist/shared/serialize-props.d.ts +14 -0
  27. package/dist/shared/serialize-props.js +36 -0
  28. package/package.json +8 -8
  29. package/remotionlambda-arm64.zip +0 -0
  30. package/remotionlambda-x64.zip +0 -0
  31. package/dist/shared/deserialize-input-props.d.ts +0 -8
  32. package/dist/shared/deserialize-input-props.js +0 -26
  33. package/dist/shared/serialize-input-props.d.ts +0 -8
  34. package/dist/shared/serialize-input-props.js +0 -42
@@ -1,5 +1,5 @@
1
1
  import type { ChromiumOptions, LogLevel } from '@remotion/renderer';
2
- import type { AnyCompMetadata } from 'remotion';
2
+ import type { VideoConfig } from 'remotion';
3
3
  import type { AwsRegion } from '../client';
4
4
  export type GetCompositionsOnLambdaInput = {
5
5
  chromiumOptions?: ChromiumOptions;
@@ -16,7 +16,7 @@ export type GetCompositionsOnLambdaInput = {
16
16
  */
17
17
  dumpBrowserLogs?: boolean;
18
18
  };
19
- export type GetCompositionsOnLambdaOutput = AnyCompMetadata[];
19
+ export type GetCompositionsOnLambdaOutput = VideoConfig[];
20
20
  /**
21
21
  * @description Returns the compositions from a serveUrl
22
22
  * @see [Documentation](https://remotion.dev/docs/lambda/getcompositionsonlambda)
@@ -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 compress_props_1 = require("../shared/compress-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, compress_props_1.serializeOrThrow)(inputProps, 'input-props');
24
+ const serializedInputProps = await (0, compress_props_1.compressInputProps)({
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, compress_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 compress_props_1 = require("../shared/compress-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, compress_props_1.serializeOrThrow)(inputProps !== null && inputProps !== void 0 ? inputProps : {}, 'input-props');
23
+ const serialized = await (0, compress_props_1.compressInputProps)({
24
+ stringifiedInputProps,
25
25
  region,
26
- type: 'video-or-audio',
26
+ needsToUpload: (0, compress_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 compress_props_1 = require("../shared/compress-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, compress_props_1.serializeOrThrow)(inputProps, 'input-props');
31
+ const serializedInputProps = await (0, compress_props_1.compressInputProps)({
32
+ stringifiedInputProps,
33
33
  region,
34
- type: 'still',
34
+ needsToUpload: (0, compress_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 : {},
@@ -19,6 +19,7 @@ const find_function_name_1 = require("../../helpers/find-function-name");
19
19
  const quit_1 = require("../../helpers/quit");
20
20
  const log_1 = require("../../log");
21
21
  const progress_1 = require("./progress");
22
+ const remotion_1 = require("remotion");
22
23
  exports.RENDER_COMMAND = 'render';
23
24
  const renderCommand = async (args, remotionRoot) => {
24
25
  var _a, _b, _c, _d, _e, _f, _g;
@@ -40,7 +41,7 @@ const renderCommand = async (args, remotionRoot) => {
40
41
  if (!composition) {
41
42
  log_1.Log.info('No compositions passed. Fetching compositions...');
42
43
  (0, validate_serveurl_1.validateServeUrl)(serveUrl);
43
- const server = renderer_1.RenderInternals.prepareServer({
44
+ const server = await renderer_1.RenderInternals.prepareServer({
44
45
  concurrency: 1,
45
46
  indent: false,
46
47
  port,
@@ -56,14 +57,18 @@ const renderCommand = async (args, remotionRoot) => {
56
57
  envVariables,
57
58
  height,
58
59
  indent: false,
59
- inputProps,
60
+ serializedInputPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
61
+ indent: undefined,
62
+ staticBase: null,
63
+ data: inputProps,
64
+ }).serializedString,
60
65
  port,
61
66
  puppeteerInstance: undefined,
62
67
  serveUrlOrWebpackUrl: serveUrl,
63
68
  timeoutInMilliseconds: puppeteerTimeout,
64
69
  logLevel,
65
70
  width,
66
- server: await server,
71
+ server,
67
72
  });
68
73
  composition = compositionId;
69
74
  }
@@ -15,6 +15,7 @@ const get_aws_region_1 = require("../get-aws-region");
15
15
  const find_function_name_1 = require("../helpers/find-function-name");
16
16
  const quit_1 = require("../helpers/quit");
17
17
  const log_1 = require("../log");
18
+ const remotion_1 = require("remotion");
18
19
  exports.STILL_COMMAND = 'still';
19
20
  const stillCommand = async (args, remotionRoot) => {
20
21
  var _a, _b, _c, _d, _e, _f;
@@ -36,7 +37,7 @@ const stillCommand = async (args, remotionRoot) => {
36
37
  if (!composition) {
37
38
  log_1.Log.info('No compositions passed. Fetching compositions...');
38
39
  (0, validate_serveurl_1.validateServeUrl)(serveUrl);
39
- const server = renderer_1.RenderInternals.prepareServer({
40
+ const server = await renderer_1.RenderInternals.prepareServer({
40
41
  concurrency: 1,
41
42
  indent: false,
42
43
  port,
@@ -53,13 +54,17 @@ const stillCommand = async (args, remotionRoot) => {
53
54
  browserExecutable,
54
55
  chromiumOptions,
55
56
  envVariables,
56
- inputProps,
57
+ serializedInputPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
58
+ indent: undefined,
59
+ staticBase: null,
60
+ data: inputProps,
61
+ }).serializedString,
57
62
  port,
58
63
  puppeteerInstance: undefined,
59
64
  timeoutInMilliseconds: puppeteerTimeout,
60
65
  height,
61
66
  width,
62
- server: await server,
67
+ server,
63
68
  });
64
69
  composition = compositionId;
65
70
  }
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: "verbose" | "info" | "warn" | "error";
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: "verbose" | "info" | "warn" | "error";
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: "verbose" | "info" | "warn" | "error";
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 compress_props_1 = require("../shared/compress-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 serializedInputPropsWithCustomSchema = await (0, compress_props_1.decompressInputProps)({
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,
@@ -41,7 +42,7 @@ const compositionsHandler = async (lambdaParams, options) => {
41
42
  const compositions = await renderer_1.RenderInternals.internalGetCompositions({
42
43
  serveUrlOrWebpackUrl: realServeUrl,
43
44
  puppeteerInstance: browserInstance,
44
- inputProps,
45
+ serializedInputPropsWithCustomSchema,
45
46
  envVariables: (_c = lambdaParams.envVariables) !== null && _c !== void 0 ? _c : {},
46
47
  timeoutInMilliseconds: lambdaParams.timeoutInMilliseconds,
47
48
  chromiumOptions: lambdaParams.chromiumOptions,
@@ -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";
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getProgress = void 0;
4
4
  const renderer_1 = require("@remotion/renderer");
5
5
  const remotion_1 = require("remotion");
6
- const chunk_progress_1 = require("../../shared/chunk-progress");
7
6
  const constants_1 = require("../../shared/constants");
8
7
  const calculate_chunk_times_1 = require("./calculate-chunk-times");
9
8
  const calculate_price_from_bucket_1 = require("./calculate-price-from-bucket");
@@ -140,11 +139,6 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
140
139
  renderId,
141
140
  })
142
141
  : 0;
143
- console.log('etags', contents
144
- .filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaChunkInitializedPrefix)(renderId)); })
145
- .map((c) => {
146
- return (0, chunk_progress_1.getProgressOfChunk)(c.ETag);
147
- }));
148
142
  const allChunks = chunks.length === ((_f = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _f !== void 0 ? _f : Infinity);
149
143
  const renderSize = contents
150
144
  .map((c) => { var _a; return (_a = c.Size) !== null && _a !== void 0 ? _a : 0; })
@@ -25,6 +25,8 @@ const makeTimeoutMessage = ({ timeoutInMilliseconds, missingChunks, renderMetada
25
25
  makeChunkMissingMessage({ missingChunks, renderMetadata }),
26
26
  `You can use the "--timeout" parameter when deploying a function via CLI, or the "timeoutInSeconds" parameter when using the deployFunction() API.`,
27
27
  `${docs_url_1.DOCS_URL}/docs/lambda/cli/functions#deploy`,
28
+ 'Get help on debugging this error:',
29
+ `${docs_url_1.DOCS_URL}/docs/lambda/troubleshooting/debug`,
28
30
  ].join('\n');
29
31
  return message;
30
32
  };
@@ -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,11 +1,11 @@
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;
6
6
  composition: string;
7
7
  browserInstance: Await<ReturnType<typeof openBrowser>>;
8
- inputProps: Record<string, unknown>;
8
+ serializedInputPropsWithCustomSchema: string;
9
9
  envVariables: Record<string, string>;
10
10
  timeoutInMilliseconds: number;
11
11
  chromiumOptions: ChromiumOptions;
@@ -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, serializedInputPropsWithCustomSchema, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }: ValidateCompositionOptions) => Promise<VideoConfig>;
19
19
  export {};
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  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
- const validateComposition = async ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }) => {
7
- const comp = await renderer_1.RenderInternals.internalSelectComposition({
6
+ const validateComposition = async ({ serveUrl, composition, browserInstance, serializedInputPropsWithCustomSchema, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }) => {
7
+ const { metadata: comp } = await renderer_1.RenderInternals.internalSelectComposition({
8
8
  id: composition,
9
9
  puppeteerInstance: browserInstance,
10
- inputProps,
10
+ serializedInputPropsWithCustomSchema,
11
11
  envVariables,
12
12
  timeoutInMilliseconds,
13
13
  chromiumOptions,
@@ -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 compress_props_1 = require("../shared/compress-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,17 +136,20 @@ 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, compress_props_1.decompressInputProps)({
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
  });
146
+ const serializedInputPropsWithCustomSchema = await inputPropsPromise;
147
+ renderer_1.RenderInternals.Log.info('Validating composition, input props:', serializedInputPropsWithCustomSchema);
145
148
  const comp = await (0, validate_composition_1.validateComposition)({
146
149
  serveUrl: params.serveUrl,
147
150
  composition: params.composition,
148
151
  browserInstance,
149
- inputProps: await inputPropsPromise,
152
+ serializedInputPropsWithCustomSchema,
150
153
  envVariables: (_b = params.envVariables) !== null && _b !== void 0 ? _b : {},
151
154
  timeoutInMilliseconds: params.timeoutInMilliseconds,
152
155
  chromiumOptions: params.chromiumOptions,
@@ -156,8 +159,8 @@ const innerLaunchHandler = async (params, options) => {
156
159
  logLevel: params.logLevel,
157
160
  server: undefined,
158
161
  });
159
- remotion_1.Internals.validateDurationInFrames({
160
- durationInFrames: comp.durationInFrames,
162
+ renderer_1.RenderInternals.Log.info('Composition validated, resolved props', comp.props);
163
+ remotion_1.Internals.validateDurationInFrames(comp.durationInFrames, {
161
164
  component: 'passed to a Lambda render',
162
165
  allowFloats: false,
163
166
  });
@@ -188,6 +191,15 @@ const innerLaunchHandler = async (params, options) => {
188
191
  });
189
192
  const sortedChunks = chunks.slice().sort((a, b) => a[0] - b[0]);
190
193
  const reqSend = (0, timer_1.timer)('sending off requests');
194
+ const serializedResolved = (0, compress_props_1.serializeOrThrow)(comp.props, 'resolved-props');
195
+ const needsToUpload = (0, compress_props_1.getNeedsToUpload)('video-or-audio', serializedResolved + params.inputProps);
196
+ const serializedResolvedProps = await (0, compress_props_1.compressInputProps)({
197
+ propsType: 'resolved-props',
198
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
199
+ stringifiedInputProps: serializedResolved,
200
+ userSpecifiedBucketName: params.bucketName,
201
+ needsToUpload,
202
+ });
191
203
  const lambdaPayloads = chunks.map((chunkPayload) => {
192
204
  var _a;
193
205
  const payload = {
@@ -225,6 +237,7 @@ const innerLaunchHandler = async (params, options) => {
225
237
  launchFunctionConfig: {
226
238
  version: version_1.VERSION,
227
239
  },
240
+ resolvedProps: serializedResolvedProps,
228
241
  };
229
242
  return payload;
230
243
  });
@@ -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 compress_props_1 = require("../shared/compress-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,19 @@ 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, compress_props_1.decompressInputProps)({
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, compress_props_1.decompressInputProps)({
37
+ bucketName: params.bucketName,
38
+ expectedBucketOwner: options.expectedBucketOwner,
39
+ region: (0, get_current_region_1.getCurrentRegionInFunction)(),
40
+ serialized: params.resolvedProps,
41
+ propsType: 'resolved-props',
34
42
  });
35
43
  const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(params.logLevel, false, (_a = params.chromiumOptions) !== null && _a !== void 0 ? _a : {});
36
44
  const outputPath = renderer_1.RenderInternals.tmpDir('remotion-render-');
@@ -56,7 +64,8 @@ const renderHandler = async (params, options, logs) => {
56
64
  preferLossless: true,
57
65
  }))}`);
58
66
  const downloads = {};
59
- const inputProps = await inputPropsPromise;
67
+ const resolvedProps = await resolvedPropsPromise;
68
+ const serializedInputPropsWithCustomSchema = await inputPropsPromise;
60
69
  await new Promise((resolve, reject) => {
61
70
  var _a, _b, _c, _d;
62
71
  renderer_1.RenderInternals.internalRenderMedia({
@@ -68,7 +77,7 @@ const renderHandler = async (params, options, logs) => {
68
77
  width: params.width,
69
78
  },
70
79
  imageFormat: params.imageFormat,
71
- inputProps,
80
+ serializedInputPropsWithCustomSchema,
72
81
  frameRange: params.frameRange,
73
82
  onProgress: ({ renderedFrames, encodedFrames, stitchStage }) => {
74
83
  if (renderedFrames % 5 === 0 &&
@@ -157,6 +166,7 @@ const renderHandler = async (params, options, logs) => {
157
166
  indent: false,
158
167
  onCtrlCExit: () => undefined,
159
168
  server: undefined,
169
+ serializedResolvedPropsWithCustomSchema: resolvedProps,
160
170
  })
161
171
  .then(({ slowestFrames }) => {
162
172
  console.log(`Slowest frames:`);
@@ -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,8 @@ 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 compress_props_1 = require("../shared/compress-props");
33
+ const remotion_1 = require("remotion");
33
34
  const innerStillHandler = async (lambdaParams, renderId, options) => {
34
35
  var _a, _b, _c, _d, _e, _f;
35
36
  if (lambdaParams.type !== constants_1.LambdaRoutines.still) {
@@ -54,11 +55,12 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
54
55
  const outputDir = renderer_1.RenderInternals.tmpDir('remotion-render-');
55
56
  const outputPath = node_path_1.default.join(outputDir, 'output');
56
57
  const region = (0, get_current_region_1.getCurrentRegionInFunction)();
57
- const inputProps = await (0, deserialize_input_props_1.deserializeInputProps)({
58
+ const serializedInputPropsWithCustomSchema = await (0, compress_props_1.decompressInputProps)({
58
59
  bucketName,
59
60
  expectedBucketOwner: options.expectedBucketOwner,
60
61
  region,
61
62
  serialized: lambdaParams.inputProps,
63
+ propsType: 'input-props',
62
64
  });
63
65
  const serveUrl = (0, convert_to_serve_url_1.convertToServeUrl)({
64
66
  urlOrId: lambdaParams.serveUrl,
@@ -77,7 +79,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
77
79
  serveUrl,
78
80
  browserInstance,
79
81
  composition: lambdaParams.composition,
80
- inputProps,
82
+ serializedInputPropsWithCustomSchema,
81
83
  envVariables: (_c = lambdaParams.envVariables) !== null && _c !== void 0 ? _c : {},
82
84
  chromiumOptions: lambdaParams.chromiumOptions,
83
85
  timeoutInMilliseconds: lambdaParams.timeoutInMilliseconds,
@@ -130,7 +132,11 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
130
132
  durationInFrames: composition.durationInFrames,
131
133
  }),
132
134
  imageFormat: lambdaParams.imageFormat,
133
- inputProps,
135
+ serializedInputPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
136
+ data: lambdaParams.inputProps,
137
+ indent: undefined,
138
+ staticBase: null,
139
+ }).serializedString,
134
140
  overwrite: false,
135
141
  puppeteerInstance: browserInstance,
136
142
  jpegQuality: (_f = lambdaParams.jpegQuality) !== null && _f !== void 0 ? _f : renderer_1.RenderInternals.DEFAULT_JPEG_QUALITY,
@@ -145,6 +151,11 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
145
151
  port: null,
146
152
  server,
147
153
  logLevel: lambdaParams.logLevel,
154
+ serializedResolvedPropsWithCustomSchema: remotion_1.Internals.serializeJSONWithDate({
155
+ indent: undefined,
156
+ staticBase: null,
157
+ data: composition.props,
158
+ }).serializedString,
148
159
  });
149
160
  const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName, (0, expected_out_name_1.getCredentialsFromOutName)(lambdaParams.outName));
150
161
  const { size } = await node_fs_1.default.promises.stat(outputPath);
@@ -0,0 +1,20 @@
1
+ import type { AwsRegion } from '../client';
2
+ import type { SerializedInputProps } from './constants';
3
+ type PropsType = 'input-props' | 'resolved-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 compressInputProps: ({ 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 decompressInputProps: ({ serialized, region, bucketName, expectedBucketOwner, propsType, }: {
14
+ serialized: SerializedInputProps;
15
+ region: AwsRegion;
16
+ bucketName: string;
17
+ expectedBucketOwner: string;
18
+ propsType: PropsType;
19
+ }) => Promise<string>;
20
+ export {};
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decompressInputProps = exports.compressInputProps = 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 serialize_props_1 = require("./serialize-props");
10
+ const serializeOrThrow = (inputProps, propsType) => {
11
+ try {
12
+ const payload = (0, serialize_props_1.serializeJSONWithDate)({
13
+ indent: undefined,
14
+ staticBase: null,
15
+ data: inputProps,
16
+ });
17
+ return payload.serializedString;
18
+ }
19
+ catch (err) {
20
+ throw new Error(`Error serializing ${propsType}. Check it has no circular references or reduce the size if the object is big.`);
21
+ }
22
+ };
23
+ exports.serializeOrThrow = serializeOrThrow;
24
+ const getNeedsToUpload = (type, stringifiedInputProps) => {
25
+ const MAX_INLINE_PAYLOAD_SIZE = type === 'still' ? 5000000 : 200000;
26
+ if (stringifiedInputProps.length > MAX_INLINE_PAYLOAD_SIZE) {
27
+ 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.`);
28
+ return true;
29
+ }
30
+ return false;
31
+ };
32
+ exports.getNeedsToUpload = getNeedsToUpload;
33
+ const compressInputProps = async ({ stringifiedInputProps, region, userSpecifiedBucketName, propsType, needsToUpload, }) => {
34
+ const hash = (0, random_hash_1.randomHash)();
35
+ if (needsToUpload) {
36
+ const bucketName = userSpecifiedBucketName !== null && userSpecifiedBucketName !== void 0 ? userSpecifiedBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
37
+ region,
38
+ })).bucketName;
39
+ await (0, io_1.lambdaWriteFile)({
40
+ body: stringifiedInputProps,
41
+ bucketName,
42
+ region,
43
+ customCredentials: null,
44
+ downloadBehavior: null,
45
+ expectedBucketOwner: null,
46
+ key: makeKey(propsType, hash),
47
+ privacy: 'public',
48
+ });
49
+ return {
50
+ type: 'bucket-url',
51
+ hash,
52
+ };
53
+ }
54
+ return {
55
+ type: 'payload',
56
+ payload: stringifiedInputProps,
57
+ };
58
+ };
59
+ exports.compressInputProps = compressInputProps;
60
+ const decompressInputProps = async ({ serialized, region, bucketName, expectedBucketOwner, propsType, }) => {
61
+ if (serialized.type === 'payload') {
62
+ return serialized.payload;
63
+ }
64
+ try {
65
+ const response = await (0, io_1.lambdaReadFile)({
66
+ bucketName,
67
+ expectedBucketOwner,
68
+ key: makeKey(propsType, serialized.hash),
69
+ region,
70
+ });
71
+ const body = await (0, stream_to_string_1.streamToString)(response);
72
+ const payload = body;
73
+ return payload;
74
+ }
75
+ catch (err) {
76
+ throw new Error(`Failed to parse input props that were serialized: ${err.stack}`);
77
+ }
78
+ };
79
+ exports.decompressInputProps = decompressInputProps;
80
+ const makeKey = (type, hash) => {
81
+ if (type === 'input-props') {
82
+ return (0, constants_1.inputPropsKey)(hash);
83
+ }
84
+ return (0, constants_1.resolvedPropsKey)(hash);
85
+ };
@@ -1,5 +1,5 @@
1
1
  import type { AudioCodec, ChromiumOptions, Codec, FrameRange, LogLevel, PixelFormat, ProResProfile, StillImageFormat, VideoImageFormat } from '@remotion/renderer';
2
- import type { AnyCompMetadata } from 'remotion';
2
+ import type { VideoConfig } from 'remotion';
3
3
  import type { ChunkRetry } from '../functions/helpers/get-retry-stats';
4
4
  import type { EnhancedErrorInfo } from '../functions/helpers/write-lambda-error';
5
5
  import type { AwsRegion } from '../pricing/aws-regions';
@@ -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,7 @@ export type LambdaPayloads = {
218
220
  logLevel: LogLevel;
219
221
  timeoutInMilliseconds: number;
220
222
  chromiumOptions: ChromiumOptions;
223
+ resolvedProps: SerializedInputProps;
221
224
  scale: number;
222
225
  everyNthFrame: number;
223
226
  muted: boolean;
@@ -275,7 +278,7 @@ type Discriminated = {
275
278
  };
276
279
  export type RenderMetadata = Discriminated & {
277
280
  siteId: string;
278
- videoConfig: AnyCompMetadata;
281
+ videoConfig: VideoConfig;
279
282
  startedDate: number;
280
283
  totalChunks: number;
281
284
  estimatedTotalLambdaInvokations: number;
@@ -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';
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import https from 'https';
4
2
  import http from 'node:http';
5
3
  import type { EnhancedErrorInfo } from '../functions/helpers/write-lambda-error';
@@ -0,0 +1,14 @@
1
+ type SerializedJSONWithCustomFields = {
2
+ serializedString: string;
3
+ customDateUsed: boolean;
4
+ customFileUsed: boolean;
5
+ mapUsed: boolean;
6
+ setUsed: boolean;
7
+ };
8
+ export declare const FILE_TOKEN = "remotion-file:";
9
+ export declare const serializeJSONWithDate: ({ data, indent, staticBase, }: {
10
+ data: Record<string, unknown>;
11
+ indent: number | undefined;
12
+ staticBase: string | null;
13
+ }) => SerializedJSONWithCustomFields;
14
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ // Must keep this file in sync with the one in packages/core/src/input-props-serialization.ts!
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.serializeJSONWithDate = exports.FILE_TOKEN = void 0;
5
+ const DATE_TOKEN = 'remotion-date:';
6
+ exports.FILE_TOKEN = 'remotion-file:';
7
+ const serializeJSONWithDate = ({ data, indent, staticBase, }) => {
8
+ let customDateUsed = false;
9
+ let customFileUsed = false;
10
+ let mapUsed = false;
11
+ let setUsed = false;
12
+ const serializedString = JSON.stringify(data, function (key, value) {
13
+ const item = this[key];
14
+ if (item instanceof Date) {
15
+ customDateUsed = true;
16
+ return `${DATE_TOKEN}${item.toISOString()}`;
17
+ }
18
+ if (item instanceof Map) {
19
+ mapUsed = true;
20
+ return value;
21
+ }
22
+ if (item instanceof Set) {
23
+ setUsed = true;
24
+ return value;
25
+ }
26
+ if (typeof item === 'string' &&
27
+ staticBase !== null &&
28
+ item.startsWith(staticBase)) {
29
+ customFileUsed = true;
30
+ return `${exports.FILE_TOKEN}${item.replace(staticBase + '/', '')}`;
31
+ }
32
+ return value;
33
+ }, indent);
34
+ return { serializedString, customDateUsed, customFileUsed, mapUsed, setUsed };
35
+ };
36
+ exports.serializeJSONWithDate = serializeJSONWithDate;
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-alpha8",
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-alpha8",
29
+ "@remotion/cli": "4.1.0-alpha8",
30
+ "@remotion/renderer": "4.1.0-alpha8",
31
+ "remotion": "4.1.0-alpha8"
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-alpha8",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.1.0-alpha8"
48
48
  },
49
49
  "peerDependencies": {
50
- "@remotion/bundler": "4.1.0-alpha3"
50
+ "@remotion/bundler": "4.1.0-alpha8"
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;