@remotion/lambda 4.0.22 → 4.0.23

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/estimate-price.d.ts +11 -3
  2. package/dist/api/estimate-price.js +14 -11
  3. package/dist/api/get-compositions-on-lambda.d.ts +4 -3
  4. package/dist/api/get-compositions-on-lambda.js +2 -1
  5. package/dist/api/make-lambda-payload.d.ts +1 -1
  6. package/dist/api/make-lambda-payload.js +2 -1
  7. package/dist/api/render-media-on-lambda.d.ts +3 -2
  8. package/dist/api/render-still-on-lambda.d.ts +4 -3
  9. package/dist/api/render-still-on-lambda.js +2 -1
  10. package/dist/cli/commands/render/render.js +3 -1
  11. package/dist/cli/commands/still.js +3 -1
  12. package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +4 -1
  13. package/dist/functions/compositions.js +1 -0
  14. package/dist/functions/helpers/calculate-price-from-bucket.js +1 -1
  15. package/dist/functions/helpers/create-post-render-data.js +1 -1
  16. package/dist/functions/helpers/validate-composition.d.ts +2 -1
  17. package/dist/functions/helpers/validate-composition.js +2 -1
  18. package/dist/functions/launch.js +2 -0
  19. package/dist/functions/renderer.js +1 -0
  20. package/dist/functions/start.js +1 -0
  21. package/dist/functions/still.js +4 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/internals.d.ts +1 -1
  24. package/dist/pricing/aws-regions.d.ts +1 -1
  25. package/dist/shared/constants.d.ts +5 -0
  26. package/dist/shared/deserialize-input-props.d.ts +8 -0
  27. package/dist/shared/deserialize-input-props.js +26 -0
  28. package/dist/shared/invoke-webhook.d.ts +0 -2
  29. package/dist/shared/read-dir.js +4 -2
  30. package/dist/shared/serialize-input-props.d.ts +14 -0
  31. package/dist/shared/serialize-input-props.js +63 -0
  32. package/dist/shared/validate-lambda-codec.d.ts +1 -1
  33. package/package.json +9 -9
  34. package/remotionlambda-arm64.zip +0 -0
@@ -1,15 +1,23 @@
1
1
  import type { AwsRegion } from '../pricing/aws-regions';
2
+ type Miliseconds = {
3
+ /**
4
+ * @deprecated Typo in property name. Use `durationInMilliseconds` instead.
5
+ */
6
+ durationInMiliseconds: number;
7
+ } | {
8
+ durationInMilliseconds: number;
9
+ };
2
10
  export type EstimatePriceInput = {
3
11
  region: AwsRegion;
4
- durationInMiliseconds: number;
5
12
  memorySizeInMb: number;
6
13
  diskSizeInMb: number;
7
14
  lambdasInvoked: number;
8
- };
15
+ } & Miliseconds;
9
16
  /**
10
17
  *
11
18
  * @description Calculates the AWS costs incurred for AWS Lambda given the region, execution duration and memory size.
12
19
  * @see [Documentation](https://remotion.dev/docs/lambda/estimateprice)
13
20
  * @returns {number} Price in USD
14
21
  */
15
- export declare const estimatePrice: ({ region, durationInMiliseconds, memorySizeInMb, diskSizeInMb, lambdasInvoked, }: EstimatePriceInput) => number;
22
+ export declare const estimatePrice: ({ region, memorySizeInMb, diskSizeInMb, lambdasInvoked, ...other }: EstimatePriceInput) => number;
23
+ export {};
@@ -12,32 +12,35 @@ const validate_memory_size_1 = require("../shared/validate-memory-size");
12
12
  * @see [Documentation](https://remotion.dev/docs/lambda/estimateprice)
13
13
  * @returns {number} Price in USD
14
14
  */
15
- const estimatePrice = ({ region, durationInMiliseconds, memorySizeInMb, diskSizeInMb, lambdasInvoked, }) => {
15
+ const estimatePrice = ({ region, memorySizeInMb, diskSizeInMb, lambdasInvoked, ...other }) => {
16
16
  (0, validate_memory_size_1.validateMemorySize)(memorySizeInMb);
17
17
  (0, validate_aws_region_1.validateAwsRegion)(region);
18
18
  (0, validate_disk_size_in_mb_1.validateDiskSizeInMb)(diskSizeInMb);
19
- if (typeof durationInMiliseconds !== 'number') {
20
- throw new TypeError(`Parameter 'durationInMiliseconds' must be a number but got ${typeof durationInMiliseconds}`);
19
+ const durationInMilliseconds = 'durationInMiliseconds' in other
20
+ ? other.durationInMiliseconds
21
+ : other.durationInMilliseconds;
22
+ if (typeof durationInMilliseconds !== 'number') {
23
+ throw new TypeError(`Parameter 'durationInMilliseconds' must be a number but got ${typeof durationInMilliseconds}`);
21
24
  }
22
- if (Number.isNaN(durationInMiliseconds)) {
23
- throw new TypeError(`Parameter 'durationInMiliseconds' must not be NaN but it is.`);
25
+ if (Number.isNaN(durationInMilliseconds)) {
26
+ throw new TypeError(`Parameter 'durationInMilliseconds' must not be NaN but it is.`);
24
27
  }
25
- if (!Number.isFinite(durationInMiliseconds)) {
26
- throw new TypeError(`Parameter 'durationInMiliseconds' must be finite but it is ${durationInMiliseconds}`);
28
+ if (!Number.isFinite(durationInMilliseconds)) {
29
+ throw new TypeError(`Parameter 'durationInMilliseconds' must be finite but it is ${durationInMilliseconds}`);
27
30
  }
28
- if (durationInMiliseconds < 0) {
29
- throw new TypeError(`Parameter 'durationInMiliseconds' must be over 0 but it is ${durationInMiliseconds}.`);
31
+ if (durationInMilliseconds < 0) {
32
+ throw new TypeError(`Parameter 'durationInMilliseconds' must be over 0 but it is ${durationInMilliseconds}.`);
30
33
  }
31
34
  const durationPrice = price_per_1_s_1.pricing[region]['Lambda Duration-ARM'].price;
32
35
  // In GB-second
33
36
  const timeCostDollars = Number(durationPrice) *
34
- ((memorySizeInMb * durationInMiliseconds) / 1000 / 1024);
37
+ ((memorySizeInMb * durationInMilliseconds) / 1000 / 1024);
35
38
  const diskSizePrice = price_per_1_s_1.pricing[region]['Lambda Storage-Duration-ARM'].price;
36
39
  const chargedDiskSize = Math.max(0, diskSizeInMb - defaults_1.MIN_EPHEMERAL_STORAGE_IN_MB);
37
40
  // In GB-second
38
41
  const diskSizeDollars = chargedDiskSize *
39
42
  Number(diskSizePrice) *
40
- (durationInMiliseconds / 1000 / 1024);
43
+ (durationInMilliseconds / 1000 / 1024);
41
44
  const invocationCost = Number(price_per_1_s_1.pricing[region]['Lambda Requests'].price) * lambdasInvoked;
42
45
  return Number((timeCostDollars + diskSizeDollars + invocationCost).toFixed(5));
43
46
  };
@@ -1,4 +1,5 @@
1
- import type { ChromiumOptions, LogLevel } from '@remotion/renderer';
1
+ import type { ChromiumOptions, LogLevel, ToOptions } from '@remotion/renderer';
2
+ import type { BrowserSafeApis } from '@remotion/renderer/client';
2
3
  import type { VideoConfig } from 'remotion';
3
4
  import type { AwsRegion } from '../client';
4
5
  export type GetCompositionsOnLambdaInput = {
@@ -15,7 +16,7 @@ export type GetCompositionsOnLambdaInput = {
15
16
  * @deprecated in favor of `logLevel`: true
16
17
  */
17
18
  dumpBrowserLogs?: boolean;
18
- };
19
+ } & Partial<ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnLambda>>;
19
20
  export type GetCompositionsOnLambdaOutput = VideoConfig[];
20
21
  /**
21
22
  * @description Returns the compositions from a serveUrl
@@ -30,4 +31,4 @@ export type GetCompositionsOnLambdaOutput = VideoConfig[];
30
31
  * @param params.chromiumOptions The options to pass to Chromium
31
32
  * @returns The compositions
32
33
  */
33
- export declare const getCompositionsOnLambda: ({ chromiumOptions, serveUrl, region, inputProps, functionName, envVariables, logLevel, timeoutInMilliseconds, forceBucketName: bucketName, dumpBrowserLogs, }: GetCompositionsOnLambdaInput) => Promise<GetCompositionsOnLambdaOutput>;
34
+ export declare const getCompositionsOnLambda: ({ chromiumOptions, serveUrl, region, inputProps, functionName, envVariables, logLevel, timeoutInMilliseconds, forceBucketName: bucketName, dumpBrowserLogs, offthreadVideoCacheSizeInBytes, }: GetCompositionsOnLambdaInput) => Promise<GetCompositionsOnLambdaOutput>;
@@ -18,7 +18,7 @@ const compress_props_1 = require("../shared/compress-props");
18
18
  * @param params.chromiumOptions The options to pass to Chromium
19
19
  * @returns The compositions
20
20
  */
21
- const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inputProps, functionName, envVariables, logLevel, timeoutInMilliseconds, forceBucketName: bucketName, dumpBrowserLogs, }) => {
21
+ const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inputProps, functionName, envVariables, logLevel, timeoutInMilliseconds, forceBucketName: bucketName, dumpBrowserLogs, offthreadVideoCacheSizeInBytes, }) => {
22
22
  var _a;
23
23
  const stringifiedInputProps = (0, compress_props_1.serializeOrThrow)(inputProps, 'input-props');
24
24
  const serializedInputProps = await (0, compress_props_1.compressInputProps)({
@@ -43,6 +43,7 @@ const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inpu
43
43
  timeoutInMilliseconds: timeoutInMilliseconds !== null && timeoutInMilliseconds !== void 0 ? timeoutInMilliseconds : 30000,
44
44
  version: version_1.VERSION,
45
45
  bucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
46
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes !== null && offthreadVideoCacheSizeInBytes !== void 0 ? offthreadVideoCacheSizeInBytes : null,
46
47
  },
47
48
  region,
48
49
  receivedStreamingPayload: () => undefined,
@@ -1,5 +1,5 @@
1
1
  import type { LambdaStartPayload, LambdaStatusPayload } from '../defaults';
2
2
  import type { GetRenderProgressInput } from './get-render-progress';
3
3
  import type { RenderMediaOnLambdaInput } from './render-media-on-lambda';
4
- export declare const makeLambdaRenderMediaPayload: ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, x264Preset, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, downloadBehavior, muted, overwrite, dumpBrowserLogs, jpegQuality, quality, }: RenderMediaOnLambdaInput) => Promise<LambdaStartPayload>;
4
+ export declare const makeLambdaRenderMediaPayload: ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, x264Preset, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, downloadBehavior, muted, overwrite, dumpBrowserLogs, jpegQuality, quality, offthreadVideoCacheSizeInBytes, }: RenderMediaOnLambdaInput) => Promise<LambdaStartPayload>;
5
5
  export declare const getRenderProgressPayload: ({ bucketName, renderId, s3OutputProvider, }: GetRenderProgressInput) => LambdaStatusPayload;
@@ -8,7 +8,7 @@ const validate_download_behavior_1 = require("../shared/validate-download-behavi
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 makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, x264Preset, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, downloadBehavior, muted, overwrite, dumpBrowserLogs, jpegQuality, quality, }) => {
11
+ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, x264Preset, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, downloadBehavior, muted, overwrite, dumpBrowserLogs, jpegQuality, quality, offthreadVideoCacheSizeInBytes, }) => {
12
12
  if (quality) {
13
13
  throw new Error('quality has been renamed to jpegQuality. Please rename the option.');
14
14
  }
@@ -66,6 +66,7 @@ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange,
66
66
  bucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
67
67
  audioCodec: audioCodec !== null && audioCodec !== void 0 ? audioCodec : null,
68
68
  type: defaults_1.LambdaRoutines.start,
69
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes !== null && offthreadVideoCacheSizeInBytes !== void 0 ? offthreadVideoCacheSizeInBytes : null,
69
70
  };
70
71
  };
71
72
  exports.makeLambdaRenderMediaPayload = makeLambdaRenderMediaPayload;
@@ -1,4 +1,5 @@
1
- import type { AudioCodec, ChromiumOptions, FrameRange, LogLevel, PixelFormat, ProResProfile, VideoImageFormat, X264Preset } from '@remotion/renderer';
1
+ import type { AudioCodec, ChromiumOptions, FrameRange, LogLevel, PixelFormat, ProResProfile, ToOptions, VideoImageFormat, X264Preset } from '@remotion/renderer';
2
+ import type { BrowserSafeApis } from '@remotion/renderer/client';
2
3
  import type { AwsRegion } from '../pricing/aws-regions';
3
4
  import type { OutNameInput, Privacy } from '../shared/constants';
4
5
  import type { DownloadBehavior } from '../shared/content-disposition-header';
@@ -51,7 +52,7 @@ export type RenderMediaOnLambdaInput = {
51
52
  * @deprecated in favor of `logLevel`: true
52
53
  */
53
54
  dumpBrowserLogs?: boolean;
54
- };
55
+ } & Partial<ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnLambda>>;
55
56
  export type RenderMediaOnLambdaOutput = {
56
57
  renderId: string;
57
58
  bucketName: string;
@@ -1,4 +1,5 @@
1
- import type { ChromiumOptions, LogLevel, StillImageFormat } from '@remotion/renderer';
1
+ import type { ChromiumOptions, LogLevel, StillImageFormat, ToOptions } from '@remotion/renderer';
2
+ import type { BrowserSafeApis } from '@remotion/renderer/client';
2
3
  import type { AwsRegion } from '../pricing/aws-regions';
3
4
  import type { CostsInfo, OutNameInput, Privacy } from '../shared/constants';
4
5
  import type { DownloadBehavior } from '../shared/content-disposition-header';
@@ -35,7 +36,7 @@ export type RenderStillOnLambdaInput = {
35
36
  renderId: string;
36
37
  cloudWatchLogs: string;
37
38
  }) => void;
38
- };
39
+ } & Partial<ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnLambda>>;
39
40
  export type RenderStillOnLambdaOutput = {
40
41
  estimatedPrice: CostsInfo;
41
42
  url: string;
@@ -60,4 +61,4 @@ export type RenderStillOnLambdaOutput = {
60
61
  * @param params.privacy Whether the item in the S3 bucket should be public. Possible values: `"private"` and `"public"`
61
62
  * @returns {Promise<RenderStillOnLambdaOutput>} See documentation for exact response structure.
62
63
  */
63
- export declare const renderStillOnLambda: ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, onInit, }: RenderStillOnLambdaInput) => Promise<RenderStillOnLambdaOutput>;
64
+ export declare const renderStillOnLambda: ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, onInit, offthreadVideoCacheSizeInBytes, }: RenderStillOnLambdaInput) => Promise<RenderStillOnLambdaOutput>;
@@ -22,7 +22,7 @@ const get_aws_urls_1 = require("../shared/get-aws-urls");
22
22
  * @param params.privacy Whether the item in the S3 bucket should be public. Possible values: `"private"` and `"public"`
23
23
  * @returns {Promise<RenderStillOnLambdaOutput>} See documentation for exact response structure.
24
24
  */
25
- const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, onInit, }) => {
25
+ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, onInit, offthreadVideoCacheSizeInBytes, }) => {
26
26
  var _a;
27
27
  if (quality) {
28
28
  throw new Error('The `quality` option is deprecated. Use `jpegQuality` instead.');
@@ -60,6 +60,7 @@ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFo
60
60
  forceHeight: forceHeight !== null && forceHeight !== void 0 ? forceHeight : null,
61
61
  forceWidth: forceWidth !== null && forceWidth !== void 0 ? forceWidth : null,
62
62
  bucketName: forceBucketName !== null && forceBucketName !== void 0 ? forceBucketName : null,
63
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes !== null && offthreadVideoCacheSizeInBytes !== void 0 ? offthreadVideoCacheSizeInBytes : null,
63
64
  },
64
65
  region,
65
66
  receivedStreamingPayload: (payload) => {
@@ -32,7 +32,7 @@ const renderCommand = async (args, remotionRoot) => {
32
32
  (0, quit_1.quit)(1);
33
33
  }
34
34
  const region = (0, get_aws_region_1.getAwsRegion)();
35
- const { chromiumOptions, crf, envVariables, frameRange, inputProps, logLevel, pixelFormat, proResProfile, puppeteerTimeout, jpegQuality, scale, everyNthFrame, numberOfGifLoops, muted, overwrite, audioBitrate, videoBitrate, height, width, browserExecutable, port, } = await cli_1.CliInternals.getCliOptions({
35
+ const { chromiumOptions, crf, envVariables, frameRange, inputProps, logLevel, pixelFormat, proResProfile, puppeteerTimeout, jpegQuality, scale, everyNthFrame, numberOfGifLoops, muted, overwrite, audioBitrate, videoBitrate, height, width, browserExecutable, port, offthreadVideoCacheSizeInBytes, } = await cli_1.CliInternals.getCliOptions({
36
36
  type: 'series',
37
37
  isLambda: true,
38
38
  remotionRoot,
@@ -51,6 +51,7 @@ const renderCommand = async (args, remotionRoot) => {
51
51
  remotionRoot,
52
52
  logLevel,
53
53
  webpackConfigOrServeUrl: serveUrl,
54
+ offthreadVideoCacheSizeInBytes,
54
55
  });
55
56
  const { compositionId } = await cli_1.CliInternals.getCompositionWithDimensionOverride({
56
57
  args: args.slice(1),
@@ -72,6 +73,7 @@ const renderCommand = async (args, remotionRoot) => {
72
73
  logLevel,
73
74
  width,
74
75
  server,
76
+ offthreadVideoCacheSizeInBytes,
75
77
  });
76
78
  composition = compositionId;
77
79
  }
@@ -27,7 +27,7 @@ const stillCommand = async (args, remotionRoot) => {
27
27
  log_1.Log.info(`${constants_1.BINARY_NAME} ${exports.STILL_COMMAND} <serve-url> <composition-id> [output-location]`);
28
28
  (0, quit_1.quit)(1);
29
29
  }
30
- const { chromiumOptions, envVariables, inputProps, logLevel, puppeteerTimeout, jpegQuality, stillFrame, scale, height, width, browserExecutable, port, } = await cli_1.CliInternals.getCliOptions({
30
+ const { chromiumOptions, envVariables, inputProps, logLevel, puppeteerTimeout, jpegQuality, stillFrame, scale, height, width, browserExecutable, port, offthreadVideoCacheSizeInBytes, } = await cli_1.CliInternals.getCliOptions({
31
31
  type: 'still',
32
32
  isLambda: true,
33
33
  remotionRoot,
@@ -47,6 +47,7 @@ const stillCommand = async (args, remotionRoot) => {
47
47
  remotionRoot,
48
48
  logLevel,
49
49
  webpackConfigOrServeUrl: serveUrl,
50
+ offthreadVideoCacheSizeInBytes,
50
51
  });
51
52
  const { compositionId } = await cli_1.CliInternals.getCompositionWithDimensionOverride({
52
53
  args: args.slice(1),
@@ -68,6 +69,7 @@ const stillCommand = async (args, remotionRoot) => {
68
69
  height,
69
70
  width,
70
71
  server,
72
+ offthreadVideoCacheSizeInBytes,
71
73
  });
72
74
  composition = compositionId;
73
75
  }
@@ -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
  };
@@ -52,6 +52,7 @@ const compositionsHandler = async (lambdaParams, options) => {
52
52
  indent: false,
53
53
  browserExecutable: null,
54
54
  onBrowserLog: null,
55
+ offthreadVideoCacheSizeInBytes: lambdaParams.offthreadVideoCacheSizeInBytes,
55
56
  });
56
57
  return Promise.resolve({
57
58
  compositions,
@@ -29,7 +29,7 @@ const estimatePriceFromBucket = ({ contents, renderMetadata, memorySizeInMb, out
29
29
  .reduce((a, b) => a + b, 0);
30
30
  const accruedSoFar = Number((0, estimate_price_1.estimatePrice)({
31
31
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
32
- durationInMiliseconds: (0, calculate_chunk_times_1.calculateChunkTimes)({
32
+ durationInMilliseconds: (0, calculate_chunk_times_1.calculateChunkTimes)({
33
33
  contents,
34
34
  renderId: renderMetadata.renderId,
35
35
  type: 'combined-time-for-cost-calculation',
@@ -16,7 +16,7 @@ const createPostRenderData = ({ renderId, region, memorySizeInMb, renderMetadata
16
16
  .map((p) => p.rendered - p.start + get_most_expensive_chunks_1.OVERHEAD_TIME_PER_LAMBDA)
17
17
  .reduce((a, b) => a + b);
18
18
  const cost = (0, estimate_price_1.estimatePrice)({
19
- durationInMiliseconds: times,
19
+ durationInMilliseconds: times,
20
20
  memorySizeInMb,
21
21
  region,
22
22
  lambdasInvoked: renderMetadata.estimatedTotalLambdaInvokations,
@@ -14,6 +14,7 @@ type ValidateCompositionOptions = {
14
14
  forceWidth: number | null;
15
15
  logLevel: LogLevel;
16
16
  server: RemotionServer | undefined;
17
+ offthreadVideoCacheSizeInBytes: number | null;
17
18
  };
18
- export declare const validateComposition: ({ serveUrl, composition, browserInstance, serializedInputPropsWithCustomSchema, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }: ValidateCompositionOptions) => Promise<VideoConfig>;
19
+ export declare const validateComposition: ({ serveUrl, composition, browserInstance, serializedInputPropsWithCustomSchema, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, offthreadVideoCacheSizeInBytes, }: ValidateCompositionOptions) => Promise<VideoConfig>;
19
20
  export {};
@@ -3,7 +3,7 @@ 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, serializedInputPropsWithCustomSchema, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, }) => {
6
+ const validateComposition = async ({ serveUrl, composition, browserInstance, serializedInputPropsWithCustomSchema, envVariables, timeoutInMilliseconds, chromiumOptions, port, forceHeight, forceWidth, logLevel, server, offthreadVideoCacheSizeInBytes, }) => {
7
7
  const { metadata: comp } = await renderer_1.RenderInternals.internalSelectComposition({
8
8
  id: composition,
9
9
  puppeteerInstance: browserInstance,
@@ -18,6 +18,7 @@ const validateComposition = async ({ serveUrl, composition, browserInstance, ser
18
18
  indent: false,
19
19
  onBrowserLog: null,
20
20
  server,
21
+ offthreadVideoCacheSizeInBytes,
21
22
  });
22
23
  return {
23
24
  ...comp,
@@ -112,6 +112,7 @@ const innerLaunchHandler = async (params, options) => {
112
112
  forceWidth: params.forceWidth,
113
113
  logLevel: params.logLevel,
114
114
  server: undefined,
115
+ offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,
115
116
  });
116
117
  renderer_1.RenderInternals.Log.info('Composition validated, resolved props', comp.props);
117
118
  remotion_1.Internals.validateDurationInFrames(comp.durationInFrames, {
@@ -198,6 +199,7 @@ const innerLaunchHandler = async (params, options) => {
198
199
  version: version_1.VERSION,
199
200
  },
200
201
  resolvedProps: serializedResolvedProps,
202
+ offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,
201
203
  };
202
204
  return payload;
203
205
  });
@@ -154,6 +154,7 @@ const renderHandler = async (params, options, logs) => {
154
154
  onCtrlCExit: () => undefined,
155
155
  server: undefined,
156
156
  serializedResolvedPropsWithCustomSchema: resolvedProps,
157
+ offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,
157
158
  })
158
159
  .then(({ slowestFrames }) => {
159
160
  console.log(`Slowest frames:`);
@@ -78,6 +78,7 @@ const startHandler = async (params, options) => {
78
78
  forceWidth: params.forceWidth,
79
79
  rendererFunctionName: params.rendererFunctionName,
80
80
  audioCodec: params.audioCodec,
81
+ offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,
81
82
  };
82
83
  // Don't replace with callLambda(), we want to return before the render is snone
83
84
  await (0, aws_clients_1.getLambdaClient)((0, get_current_region_1.getCurrentRegionInFunction)()).send(new client_lambda_1.InvokeCommand({
@@ -73,6 +73,7 @@ const innerStillHandler = async ({ params: lambdaParams, expectedBucketOwner, re
73
73
  remotionRoot: process.cwd(),
74
74
  logLevel: lambdaParams.logLevel,
75
75
  webpackConfigOrServeUrl: serveUrl,
76
+ offthreadVideoCacheSizeInBytes: lambdaParams.offthreadVideoCacheSizeInBytes,
76
77
  });
77
78
  const composition = await (0, validate_composition_1.validateComposition)({
78
79
  serveUrl,
@@ -87,6 +88,7 @@ const innerStillHandler = async ({ params: lambdaParams, expectedBucketOwner, re
87
88
  forceWidth: lambdaParams.forceWidth,
88
89
  logLevel: lambdaParams.logLevel,
89
90
  server,
91
+ offthreadVideoCacheSizeInBytes: lambdaParams.offthreadVideoCacheSizeInBytes,
90
92
  });
91
93
  const renderMetadata = {
92
94
  startedDate: Date.now(),
@@ -151,6 +153,7 @@ const innerStillHandler = async ({ params: lambdaParams, expectedBucketOwner, re
151
153
  staticBase: null,
152
154
  data: composition.props,
153
155
  }).serializedString,
156
+ offthreadVideoCacheSizeInBytes: lambdaParams.offthreadVideoCacheSizeInBytes,
154
157
  });
155
158
  const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName, (0, expected_out_name_1.getCredentialsFromOutName)(lambdaParams.outName));
156
159
  const { size } = await node_fs_1.default.promises.stat(outputPath);
@@ -174,7 +177,7 @@ const innerStillHandler = async ({ params: lambdaParams, expectedBucketOwner, re
174
177
  server.closeServer(true),
175
178
  ]);
176
179
  const estimatedPrice = (0, estimate_price_1.estimatePrice)({
177
- durationInMiliseconds: Date.now() - start + 100,
180
+ durationInMilliseconds: Date.now() - start + 100,
178
181
  memorySizeInMb: Number(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE),
179
182
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
180
183
  lambdasInvoked: 1,
package/dist/index.d.ts CHANGED
@@ -47,7 +47,7 @@ declare const renderMediaOnLambda: (input: RenderMediaOnLambdaInput) => Promise<
47
47
  /**
48
48
  * @deprecated Import this from `@remotion/lambda/client` instead
49
49
  */
50
- declare const renderStillOnLambda: ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, onInit, }: RenderStillOnLambdaInput) => Promise<RenderStillOnLambdaOutput>;
50
+ declare const renderStillOnLambda: ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, onInit, offthreadVideoCacheSizeInBytes, }: RenderStillOnLambdaInput) => Promise<RenderStillOnLambdaOutput>;
51
51
  /**
52
52
  * @deprecated Import this from `@remotion/lambda/client` instead
53
53
  */
@@ -1,5 +1,5 @@
1
1
  export declare const LambdaInternals: {
2
2
  executeCommand: (args: string[], remotionRoot: string) => Promise<void>;
3
- makeLambdaRenderMediaPayload: ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, x264Preset, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, downloadBehavior, muted, overwrite, dumpBrowserLogs, jpegQuality, quality, }: import(".").RenderMediaOnLambdaInput) => Promise<import("./defaults").LambdaStartPayload>;
3
+ makeLambdaRenderMediaPayload: ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, x264Preset, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, downloadBehavior, muted, overwrite, dumpBrowserLogs, jpegQuality, quality, offthreadVideoCacheSizeInBytes, }: import(".").RenderMediaOnLambdaInput) => Promise<import("./defaults").LambdaStartPayload>;
4
4
  getRenderProgressPayload: ({ bucketName, renderId, s3OutputProvider, }: import(".").GetRenderProgressInput) => import("./defaults").LambdaStatusPayload;
5
5
  };
@@ -1,3 +1,3 @@
1
1
  export declare const DEFAULT_AWS_REGIONS: readonly ["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"];
2
2
  export declare const AWS_REGIONS: readonly ["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
- export type AwsRegion = typeof AWS_REGIONS[number];
3
+ export type AwsRegion = (typeof AWS_REGIONS)[number];
@@ -143,6 +143,7 @@ export type LambdaStartPayload = {
143
143
  forceHeight: number | null;
144
144
  forceWidth: number | null;
145
145
  bucketName: string | null;
146
+ offthreadVideoCacheSizeInBytes: number | null;
146
147
  };
147
148
  export type LambdaStatusPayload = {
148
149
  type: LambdaRoutines.status;
@@ -193,6 +194,7 @@ export type LambdaPayloads = {
193
194
  webhook: WebhookOption;
194
195
  forceHeight: number | null;
195
196
  forceWidth: number | null;
197
+ offthreadVideoCacheSizeInBytes: number | null;
196
198
  };
197
199
  status: LambdaStatusPayload;
198
200
  renderer: {
@@ -232,6 +234,7 @@ export type LambdaPayloads = {
232
234
  launchFunctionConfig: {
233
235
  version: string;
234
236
  };
237
+ offthreadVideoCacheSizeInBytes: number | null;
235
238
  };
236
239
  still: {
237
240
  type: LambdaRoutines.still;
@@ -255,6 +258,7 @@ export type LambdaPayloads = {
255
258
  forceHeight: number | null;
256
259
  forceWidth: number | null;
257
260
  bucketName: string | null;
261
+ offthreadVideoCacheSizeInBytes: number | null;
258
262
  };
259
263
  compositions: {
260
264
  type: LambdaRoutines.compositions;
@@ -266,6 +270,7 @@ export type LambdaPayloads = {
266
270
  timeoutInMilliseconds: number;
267
271
  serveUrl: string;
268
272
  bucketName: string | null;
273
+ offthreadVideoCacheSizeInBytes: number | null;
269
274
  };
270
275
  };
271
276
  export type LambdaPayload = LambdaPayloads[LambdaRoutines];
@@ -0,0 +1,8 @@
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>>;
@@ -0,0 +1,26 @@
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,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';
@@ -45,10 +45,12 @@ async function readDirectory({ dir, etags, originalDir, }) {
45
45
  // eslint-disable-next-line no-lonely-if
46
46
  if (fs.lstatSync(filePath).isSymbolicLink()) {
47
47
  const realPath = fs.realpathSync(filePath);
48
- etags[path.relative(originalDir, filePath)] = await (0, get_etag_1.getEtagOfFile)(realPath);
48
+ etags[path.relative(originalDir, filePath)] =
49
+ await (0, get_etag_1.getEtagOfFile)(realPath);
49
50
  }
50
51
  else {
51
- etags[path.relative(originalDir, filePath)] = await (0, get_etag_1.getEtagOfFile)(filePath);
52
+ etags[path.relative(originalDir, filePath)] =
53
+ await (0, get_etag_1.getEtagOfFile)(filePath);
52
54
  }
53
55
  }
54
56
  // Return the list of files with their etags and file names
@@ -0,0 +1,14 @@
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>;
9
+ export declare const deserializeInputProps: ({ serialized, region, bucketName, expectedBucketOwner, }: {
10
+ serialized: SerializedInputProps;
11
+ region: AwsRegion;
12
+ bucketName: string;
13
+ expectedBucketOwner: string;
14
+ }) => Promise<Record<string, unknown>>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeInputProps = 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 stream_to_string_1 = require("./stream-to-string");
9
+ const serializeInputProps = async ({ inputProps, region, type, userSpecifiedBucketName, }) => {
10
+ try {
11
+ const payload = JSON.stringify(inputProps);
12
+ const hash = (0, random_hash_1.randomHash)();
13
+ const MAX_INLINE_PAYLOAD_SIZE = type === 'still' ? 5000000 : 200000;
14
+ if (payload.length > MAX_INLINE_PAYLOAD_SIZE) {
15
+ 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.`);
16
+ const bucketName = userSpecifiedBucketName !== null && userSpecifiedBucketName !== void 0 ? userSpecifiedBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
17
+ region,
18
+ })).bucketName;
19
+ await (0, io_1.lambdaWriteFile)({
20
+ body: payload,
21
+ bucketName,
22
+ region,
23
+ customCredentials: null,
24
+ downloadBehavior: null,
25
+ expectedBucketOwner: null,
26
+ key: (0, constants_1.inputPropsKey)(hash),
27
+ privacy: 'public',
28
+ });
29
+ return {
30
+ type: 'bucket-url',
31
+ hash,
32
+ };
33
+ }
34
+ return {
35
+ type: 'payload',
36
+ payload,
37
+ };
38
+ }
39
+ catch (err) {
40
+ throw new Error('Error serializing inputProps. Check it has no circular references or reduce the size if the object is big.');
41
+ }
42
+ };
43
+ exports.serializeInputProps = serializeInputProps;
44
+ const deserializeInputProps = async ({ serialized, region, bucketName, expectedBucketOwner, }) => {
45
+ if (serialized.type === 'payload') {
46
+ return JSON.parse(serialized.payload);
47
+ }
48
+ try {
49
+ const response = await (0, io_1.lambdaReadFile)({
50
+ bucketName,
51
+ expectedBucketOwner,
52
+ key: (0, constants_1.inputPropsKey)(serialized.hash),
53
+ region,
54
+ });
55
+ const body = await (0, stream_to_string_1.streamToString)(response);
56
+ const payload = JSON.parse(body);
57
+ return payload;
58
+ }
59
+ catch (err) {
60
+ throw new Error(`Failed to parse input props that were serialized: ${err.stack}`);
61
+ }
62
+ };
63
+ exports.deserializeInputProps = deserializeInputProps;
@@ -1,4 +1,4 @@
1
1
  declare const lambdaCodecs: readonly ["h264", "vp8", "vp9", "mp3", "aac", "wav", "gif", "prores"];
2
- export type LambdaCodec = typeof lambdaCodecs[number];
2
+ export type LambdaCodec = (typeof lambdaCodecs)[number];
3
3
  export declare const validateLambdaCodec: (codec: unknown) => LambdaCodec;
4
4
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.0.22",
3
+ "version": "4.0.23",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -26,10 +26,10 @@
26
26
  "aws-policies": "^1.0.1",
27
27
  "mime-types": "2.1.34",
28
28
  "zod": "3.21.4",
29
- "@remotion/bundler": "4.0.22",
30
- "@remotion/renderer": "4.0.22",
31
- "@remotion/cli": "4.0.22",
32
- "remotion": "4.0.22"
29
+ "@remotion/bundler": "4.0.23",
30
+ "remotion": "4.0.23",
31
+ "@remotion/renderer": "4.0.23",
32
+ "@remotion/cli": "4.0.23"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@jonny/eslint-config": "3.0.266",
@@ -38,16 +38,16 @@
38
38
  "@types/node": "18.14.6",
39
39
  "@types/prompt": "^1.1.0",
40
40
  "eslint": "8.42.0",
41
- "prettier": "^2.4.1",
41
+ "prettier": "3.0.2",
42
42
  "prettier-plugin-organize-imports": "^3.2.2",
43
43
  "ts-node": "^10.8.0",
44
44
  "vitest": "0.31.1",
45
45
  "zip-lib": "^0.7.2",
46
- "@remotion/bundler": "4.0.22",
47
- "@remotion/compositor-linux-arm64-gnu": "4.0.22"
46
+ "@remotion/bundler": "4.0.23",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.0.23"
48
48
  },
49
49
  "peerDependencies": {
50
- "@remotion/bundler": "4.0.22"
50
+ "@remotion/bundler": "4.0.23"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
Binary file