@remotion/lambda 4.0.72 → 4.0.73

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.
@@ -9,6 +9,7 @@ const mime_types_1 = __importDefault(require("mime-types"));
9
9
  const node_fs_1 = require("node:fs");
10
10
  const node_path_1 = __importDefault(require("node:path"));
11
11
  const aws_clients_1 = require("../shared/aws-clients");
12
+ const chunk_1 = require("../shared/chunk");
12
13
  const make_s3_key_1 = require("../shared/make-s3-key");
13
14
  const getDirFiles = (entry) => {
14
15
  throw new TypeError('should only be executed in test ' + JSON.stringify(entry));
@@ -51,34 +52,39 @@ const uploadDir = async ({ bucket, region, localDir, onProgress, keyPrefix, priv
51
52
  progresses[file.name] = 0;
52
53
  }
53
54
  const client = (0, aws_clients_1.getS3Client)(region, null);
54
- const uploads = files.map((filePath) => {
55
- const Key = (0, make_s3_key_1.makeS3Key)(keyPrefix, localDir, filePath.name);
56
- const Body = (0, node_fs_1.createReadStream)(filePath.name);
57
- const ContentType = mime_types_1.default.lookup(Key) || 'application/octet-stream';
58
- const ACL = privacy === 'no-acl'
59
- ? undefined
60
- : privacy === 'private'
61
- ? 'private'
62
- : 'public-read';
63
- const paralellUploads3 = new lib_storage_1.Upload({
64
- client,
65
- queueSize: 4,
66
- partSize: 5 * 1024 * 1024,
67
- params: {
68
- Key,
69
- Bucket: bucket,
70
- Body,
71
- ACL,
72
- ContentType,
73
- },
74
- });
75
- paralellUploads3.on('httpUploadProgress', (progress) => {
76
- var _a;
77
- progresses[filePath.name] = (_a = progress.loaded) !== null && _a !== void 0 ? _a : 0;
78
- });
79
- return paralellUploads3.done();
80
- });
81
- const promise = Promise.all(uploads);
55
+ const chunkedFiles = (0, chunk_1.chunk)(files, 200);
56
+ const uploadAll = (async () => {
57
+ for (const filesChunk of chunkedFiles) {
58
+ const uploads = filesChunk.map((filePath) => {
59
+ const Key = (0, make_s3_key_1.makeS3Key)(keyPrefix, localDir, filePath.name);
60
+ const Body = (0, node_fs_1.createReadStream)(filePath.name);
61
+ const ContentType = mime_types_1.default.lookup(Key) || 'application/octet-stream';
62
+ const ACL = privacy === 'no-acl'
63
+ ? undefined
64
+ : privacy === 'private'
65
+ ? 'private'
66
+ : 'public-read';
67
+ const paralellUploads3 = new lib_storage_1.Upload({
68
+ client,
69
+ queueSize: 4,
70
+ partSize: 5 * 1024 * 1024,
71
+ params: {
72
+ Key,
73
+ Bucket: bucket,
74
+ Body,
75
+ ACL,
76
+ ContentType,
77
+ },
78
+ });
79
+ paralellUploads3.on('httpUploadProgress', (progress) => {
80
+ var _a;
81
+ progresses[filePath.name] = (_a = progress.loaded) !== null && _a !== void 0 ? _a : 0;
82
+ });
83
+ return paralellUploads3.done();
84
+ });
85
+ await Promise.all(uploads);
86
+ }
87
+ })();
82
88
  const interval = setInterval(() => {
83
89
  onProgress({
84
90
  totalSize: files.map((f) => f.size).reduce((a, b) => a + b, 0),
@@ -87,7 +93,7 @@ const uploadDir = async ({ bucket, region, localDir, onProgress, keyPrefix, priv
87
93
  filesUploaded: files.filter((f) => progresses[f.name] === f.size).length,
88
94
  });
89
95
  }, 1000);
90
- await promise;
96
+ await uploadAll;
91
97
  clearInterval(interval);
92
98
  };
93
99
  exports.uploadDir = uploadDir;
@@ -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
  };
@@ -12,11 +12,11 @@ const get_time_to_finish_1 = require("./get-time-to-finish");
12
12
  const createPostRenderData = ({ renderId, region, memorySizeInMb, renderMetadata, contents, timeToEncode, errorExplanations, timeToDelete, outputFile, }) => {
13
13
  const initializedKeys = contents.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaTimingsPrefix)(renderId)); });
14
14
  const parsedTimings = initializedKeys.map(({ Key }) => (0, parse_lambda_timings_key_1.parseLambdaTimingsKey)(Key));
15
- const times = parsedTimings
15
+ const estimatedBillingDurationInMilliseconds = parsedTimings
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
- durationInMilliseconds: times,
19
+ durationInMilliseconds: estimatedBillingDurationInMilliseconds,
20
20
  memorySizeInMb,
21
21
  region,
22
22
  lambdasInvoked: renderMetadata.estimatedTotalLambdaInvokations,
@@ -74,6 +74,7 @@ const createPostRenderData = ({ renderId, region, memorySizeInMb, renderMetadata
74
74
  retriesInfo,
75
75
  mostExpensiveFrameRanges: (0, get_most_expensive_chunks_1.getMostExpensiveChunks)(parsedTimings, renderMetadata.framesPerLambda, renderMetadata.frameRange[0], renderMetadata.frameRange[1]),
76
76
  deleteAfter: renderMetadata.deleteAfter,
77
+ estimatedBillingDurationInMilliseconds,
77
78
  };
78
79
  };
79
80
  exports.createPostRenderData = createPostRenderData;
@@ -0,0 +1 @@
1
+ export declare const chunk: <T>(input: T[], size: number) => T[][];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chunk = void 0;
4
+ const chunk = (input, size) => {
5
+ return input.reduce((arr, item, idx) => {
6
+ return idx % size === 0
7
+ ? [...arr, [item]]
8
+ : [...arr.slice(0, -1), [...arr.slice(-1)[0], item]];
9
+ }, []);
10
+ };
11
+ exports.chunk = chunk;
@@ -354,6 +354,7 @@ export type PostRenderData = {
354
354
  timeToRenderChunks: number;
355
355
  retriesInfo: ChunkRetry[];
356
356
  mostExpensiveFrameRanges: ExpensiveChunk[] | undefined;
357
+ estimatedBillingDurationInMilliseconds: number;
357
358
  deleteAfter: DeleteAfter | null;
358
359
  };
359
360
  export type CostsInfo = {
@@ -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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.0.72",
3
+ "version": "4.0.73",
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.22.3",
29
- "@remotion/bundler": "4.0.72",
30
- "@remotion/renderer": "4.0.72",
31
- "@remotion/cli": "4.0.72",
32
- "remotion": "4.0.72"
29
+ "@remotion/bundler": "4.0.73",
30
+ "@remotion/cli": "4.0.73",
31
+ "remotion": "4.0.73",
32
+ "@remotion/renderer": "4.0.73"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@jonny/eslint-config": "3.0.276",
@@ -43,11 +43,11 @@
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.72",
47
- "@remotion/compositor-linux-arm64-gnu": "4.0.72"
46
+ "@remotion/bundler": "4.0.73",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.0.73"
48
48
  },
49
49
  "peerDependencies": {
50
- "@remotion/bundler": "4.0.72"
50
+ "@remotion/bundler": "4.0.73"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
Binary file