@remotion/lambda 3.3.7 → 3.3.8

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 (43) hide show
  1. package/dist/admin/generate-etag-list.d.ts +1 -0
  2. package/dist/admin/generate-etag-list.js +14 -0
  3. package/dist/api/get-aws-client.d.ts +2 -0
  4. package/dist/api/get-aws-client.js +2 -0
  5. package/dist/api/iam-validation/simulate-rule.js +0 -22
  6. package/dist/api/iam-validation/simulate.js +17 -5
  7. package/dist/api/iam-validation/user-permissions.js +0 -6
  8. package/dist/cli/commands/render/progress.d.ts +6 -3
  9. package/dist/cli/commands/render/progress.js +49 -39
  10. package/dist/cli/commands/render/render.js +16 -1
  11. package/dist/functions/helpers/concat-videos.d.ts +10 -6
  12. package/dist/functions/helpers/concat-videos.js +5 -21
  13. package/dist/functions/helpers/create-post-render-data.js +0 -12
  14. package/dist/functions/helpers/get-chunk-progress.d.ts +0 -0
  15. package/dist/functions/helpers/get-chunk-progress.js +1 -0
  16. package/dist/functions/helpers/get-encoding-metadata.d.ts +4 -8
  17. package/dist/functions/helpers/get-encoding-metadata.js +4 -18
  18. package/dist/functions/helpers/get-final-encoding-status.d.ts +2 -4
  19. package/dist/functions/helpers/get-final-encoding-status.js +1 -4
  20. package/dist/functions/helpers/get-lambdas-invoked-stats.d.ts +1 -5
  21. package/dist/functions/helpers/get-lambdas-invoked-stats.js +1 -9
  22. package/dist/functions/helpers/get-overall-progress.d.ts +2 -1
  23. package/dist/functions/helpers/get-overall-progress.js +7 -5
  24. package/dist/functions/helpers/get-progress.js +37 -25
  25. package/dist/functions/helpers/get-rendered-frames-progress.d.ts +8 -0
  26. package/dist/functions/helpers/get-rendered-frames-progress.js +37 -0
  27. package/dist/functions/launch.js +48 -37
  28. package/dist/functions/renderer.js +15 -22
  29. package/dist/functions/still.js +2 -0
  30. package/dist/shared/aws-clients.d.ts +3 -0
  31. package/dist/shared/aws-clients.js +9 -1
  32. package/dist/shared/chunk-progress.d.ts +9 -0
  33. package/dist/shared/chunk-progress.js +2034 -0
  34. package/dist/shared/constants.d.ts +4 -5
  35. package/dist/shared/get-account-id.js +4 -6
  36. package/dist/shared/get-chunk-progress.d.ts +0 -0
  37. package/dist/shared/get-chunk-progress.js +1 -0
  38. package/dist/shared/parse-chunk-key.d.ts +4 -0
  39. package/dist/shared/parse-chunk-key.js +14 -0
  40. package/package.json +7 -6
  41. package/remotionlambda.zip +0 -0
  42. package/dist/shared/get-cloudwatch-stream-url.d.ts +0 -8
  43. package/dist/shared/get-cloudwatch-stream-url.js +0 -7
@@ -1,6 +1,7 @@
1
- export declare const getOverallProgress: ({ cleanup, encoding, rendering, invoking, }: {
1
+ export declare const getOverallProgress: ({ cleanup, encoding, rendering, invoking, frames, }: {
2
2
  cleanup: number;
3
3
  encoding: number;
4
4
  rendering: number;
5
5
  invoking: number;
6
+ frames: number;
6
7
  }) => number;
@@ -3,14 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getOverallProgress = void 0;
4
4
  const weights = {
5
5
  cleanup: 0.1,
6
- encoding: 0.3,
7
- rendering: 0.3,
8
- invoking: 0.3,
6
+ encoding: 0.225,
7
+ rendering: 0.225,
8
+ frames: 0.225,
9
+ invoking: 0.225,
9
10
  };
10
- const getOverallProgress = ({ cleanup, encoding, rendering, invoking, }) => {
11
+ const getOverallProgress = ({ cleanup, encoding, rendering, invoking, frames, }) => {
11
12
  return (cleanup * weights.cleanup +
12
13
  encoding * weights.encoding +
13
14
  rendering * weights.rendering +
14
- invoking * weights.invoking);
15
+ invoking * weights.invoking +
16
+ frames * weights.frames);
15
17
  };
16
18
  exports.getOverallProgress = getOverallProgress;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getProgress = void 0;
4
+ const renderer_1 = require("@remotion/renderer");
4
5
  const remotion_1 = require("remotion");
6
+ const chunk_progress_1 = require("../../shared/chunk-progress");
5
7
  const constants_1 = require("../../shared/constants");
6
8
  const docs_url_1 = require("../../shared/docs-url");
7
9
  const calculate_chunk_times_1 = require("./calculate-chunk-times");
@@ -19,12 +21,13 @@ const get_lambdas_invoked_stats_1 = require("./get-lambdas-invoked-stats");
19
21
  const get_overall_progress_1 = require("./get-overall-progress");
20
22
  const get_post_render_data_1 = require("./get-post-render-data");
21
23
  const get_render_metadata_1 = require("./get-render-metadata");
24
+ const get_rendered_frames_progress_1 = require("./get-rendered-frames-progress");
22
25
  const get_retry_stats_1 = require("./get-retry-stats");
23
26
  const get_time_to_finish_1 = require("./get-time-to-finish");
24
27
  const inspect_errors_1 = require("./inspect-errors");
25
28
  const io_1 = require("./io");
26
29
  const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region, memorySizeInMb, timeoutInMilliseconds, customCredentials, }) => {
27
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
30
+ var _a, _b, _c, _d, _e, _f, _g, _h;
28
31
  const postRenderData = await (0, get_post_render_data_1.getPostRenderData)({
29
32
  bucketName,
30
33
  region,
@@ -33,7 +36,9 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
33
36
  });
34
37
  if (postRenderData) {
35
38
  const outData = (0, expected_out_name_1.getExpectedOutName)(postRenderData.renderMetadata, bucketName, customCredentials);
39
+ const totalFrameCount = renderer_1.RenderInternals.getFramesToRender(postRenderData.renderMetadata.frameRange, postRenderData.renderMetadata.everyNthFrame).length;
36
40
  return {
41
+ framesRendered: totalFrameCount,
37
42
  bucket: bucketName,
38
43
  renderSize: postRenderData.renderSize,
39
44
  chunks: postRenderData.renderMetadata.totalChunks,
@@ -51,10 +56,7 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
51
56
  currentTime: Date.now(),
52
57
  done: true,
53
58
  encodingStatus: {
54
- framesEncoded: postRenderData.renderMetadata.videoConfig.durationInFrames,
55
- totalFrames: postRenderData.renderMetadata.videoConfig.durationInFrames,
56
- doneIn: postRenderData.timeToEncode,
57
- timeToInvoke: postRenderData.timeToInvokeLambdas,
59
+ framesEncoded: totalFrameCount,
58
60
  },
59
61
  errors: postRenderData.errors,
60
62
  fatalErrorEncountered: false,
@@ -64,12 +66,12 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
64
66
  renderMetadata: postRenderData.renderMetadata,
65
67
  timeToFinish: postRenderData.timeToFinish,
66
68
  timeToFinishChunks: postRenderData.timeToRenderChunks,
67
- timeToInvokeLambdas: postRenderData.timeToInvokeLambdas,
68
69
  overallProgress: 1,
69
70
  retriesInfo: postRenderData.retriesInfo,
70
71
  outKey: outData.key,
71
72
  outBucket: outData.renderBucketName,
72
73
  mostExpensiveFrameRanges: (_a = postRenderData.mostExpensiveFrameRanges) !== null && _a !== void 0 ? _a : null,
74
+ timeToEncode: postRenderData.timeToEncode,
73
75
  };
74
76
  }
75
77
  const contents = await (0, io_1.lambdaLs)({
@@ -80,14 +82,10 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
80
82
  });
81
83
  (0, check_if_render_exists_1.checkIfRenderExists)(contents, renderId, bucketName, (0, get_current_region_1.getCurrentRegionInFunction)());
82
84
  const renderMetadataExists = Boolean(contents.find((c) => c.Key === (0, constants_1.renderMetadataKey)(renderId)));
83
- const [encodingStatus, renderMetadata, errorExplanations] = await Promise.all([
84
- (0, get_encoding_metadata_1.getEncodingMetadata)({
85
- exists: Boolean(contents.find((c) => c.Key === (0, constants_1.encodingProgressKey)(renderId))),
86
- bucketName,
87
- renderId,
88
- region: (0, get_current_region_1.getCurrentRegionInFunction)(),
89
- expectedBucketOwner,
90
- }),
85
+ const encodingStatus = (0, get_encoding_metadata_1.getEncodingMetadata)({
86
+ exists: contents.find((c) => c.Key === (0, constants_1.encodingProgressKey)(renderId)),
87
+ });
88
+ const [renderMetadata, errorExplanations] = await Promise.all([
91
89
  renderMetadataExists
92
90
  ? (0, get_render_metadata_1.getRenderMetadata)({
93
91
  bucketName,
@@ -137,6 +135,20 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
137
135
  renderMetadata,
138
136
  });
139
137
  const chunks = contents.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.chunkKey)(renderId)); });
138
+ const framesRendered = renderMetadata
139
+ ? (0, get_rendered_frames_progress_1.getRenderedFramesProgress)({
140
+ contents,
141
+ everyNthFrame: renderMetadata.everyNthFrame,
142
+ frameRange: renderMetadata.frameRange,
143
+ framesPerLambda: renderMetadata.framesPerLambda,
144
+ renderId,
145
+ })
146
+ : 0;
147
+ console.log('etags', contents
148
+ .filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaChunkInitializedPrefix)(renderId)); })
149
+ .map((c) => {
150
+ return (0, chunk_progress_1.getProgressOfChunk)(c.ETag);
151
+ }));
140
152
  const allChunks = chunks.length === ((_f = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _f !== void 0 ? _f : Infinity);
141
153
  const renderSize = contents
142
154
  .map((c) => { var _a; return (_a = c.Size) !== null && _a !== void 0 ? _a : 0; })
@@ -144,22 +156,18 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
144
156
  const lambdasInvokedStats = (0, get_lambdas_invoked_stats_1.getLambdasInvokedStats)({
145
157
  contents,
146
158
  renderId,
147
- estimatedRenderLambdaInvokations: (_g = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.estimatedRenderLambdaInvokations) !== null && _g !== void 0 ? _g : null,
148
- startDate: (_h = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.startedDate) !== null && _h !== void 0 ? _h : null,
149
- checkIfAllLambdasWereInvoked: true,
150
159
  });
151
160
  const retriesInfo = (0, get_retry_stats_1.getRetryStats)({
152
161
  contents,
153
162
  renderId,
154
163
  });
155
164
  const finalEncodingStatus = (0, get_final_encoding_status_1.getFinalEncodingStatus)({
156
- encodingStatus,
165
+ encodingProgress: encodingStatus,
157
166
  outputFileExists: Boolean(outputFile),
158
167
  renderMetadata,
159
- lambdaInvokeStatus: lambdasInvokedStats,
160
168
  });
161
169
  const chunkCount = outputFile
162
- ? (_j = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _j !== void 0 ? _j : 0
170
+ ? (_g = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _g !== void 0 ? _g : 0
163
171
  : chunks.length;
164
172
  // We add a 20 second buffer for it, since AWS timeshifts can be quite a lot. Once it's 20sec over the limit, we consider it timed out
165
173
  const isBeyondTimeout = renderMetadata &&
@@ -182,7 +190,11 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
182
190
  : null,
183
191
  ...errorExplanations,
184
192
  ].filter(remotion_1.Internals.truthy);
193
+ const frameCount = renderMetadata
194
+ ? renderer_1.RenderInternals.getFramesToRender(renderMetadata.frameRange, renderMetadata.everyNthFrame).length
195
+ : null;
185
196
  return {
197
+ framesRendered,
186
198
  chunks: chunkCount,
187
199
  done: false,
188
200
  encodingStatus,
@@ -190,7 +202,7 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
190
202
  renderId,
191
203
  renderMetadata,
192
204
  bucket: bucketName,
193
- outputFile: (_k = outputFile === null || outputFile === void 0 ? void 0 : outputFile.url) !== null && _k !== void 0 ? _k : null,
205
+ outputFile: (_h = outputFile === null || outputFile === void 0 ? void 0 : outputFile.url) !== null && _h !== void 0 ? _h : null,
194
206
  timeToFinish,
195
207
  errors: allErrors,
196
208
  fatalErrorEncountered: allErrors.some((f) => f.isFatal && !f.willRetry),
@@ -205,18 +217,17 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
205
217
  type: 'absolute-time',
206
218
  })
207
219
  : null,
208
- timeToInvokeLambdas: (_l = encodingStatus === null || encodingStatus === void 0 ? void 0 : encodingStatus.timeToInvoke) !== null && _l !== void 0 ? _l : lambdasInvokedStats.timeToInvokeLambdas,
209
220
  overallProgress: (0, get_overall_progress_1.getOverallProgress)({
210
221
  cleanup: cleanup ? cleanup.filesDeleted / cleanup.minFilesToDelete : 0,
211
- encoding: finalEncodingStatus && renderMetadata
212
- ? finalEncodingStatus.framesEncoded /
213
- renderMetadata.videoConfig.durationInFrames
222
+ encoding: finalEncodingStatus && renderMetadata && frameCount
223
+ ? finalEncodingStatus.framesEncoded / frameCount
214
224
  : 0,
215
225
  invoking: renderMetadata
216
226
  ? lambdasInvokedStats.lambdasInvoked /
217
227
  renderMetadata.estimatedRenderLambdaInvokations
218
228
  : 0,
219
229
  rendering: renderMetadata ? chunkCount / renderMetadata.totalChunks : 0,
230
+ frames: frameCount === null ? 0 : framesRendered / frameCount,
220
231
  }),
221
232
  retriesInfo,
222
233
  outKey: outputFile && renderMetadata
@@ -227,6 +238,7 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
227
238
  .renderBucketName
228
239
  : null,
229
240
  mostExpensiveFrameRanges: null,
241
+ timeToEncode: null,
230
242
  };
231
243
  };
232
244
  exports.getProgress = getProgress;
@@ -0,0 +1,8 @@
1
+ import type { _Object } from '@aws-sdk/client-s3';
2
+ export declare const getRenderedFramesProgress: ({ contents, renderId, framesPerLambda, everyNthFrame, frameRange, }: {
3
+ contents: _Object[];
4
+ renderId: string;
5
+ framesPerLambda: number;
6
+ frameRange: [number, number];
7
+ everyNthFrame: number;
8
+ }) => number;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRenderedFramesProgress = void 0;
4
+ const chunk_progress_1 = require("../../shared/chunk-progress");
5
+ const constants_1 = require("../../shared/constants");
6
+ const parse_chunk_key_1 = require("../../shared/parse-chunk-key");
7
+ const parse_lambda_initialized_key_1 = require("../../shared/parse-lambda-initialized-key");
8
+ const plan_frame_ranges_1 = require("../chunk-optimization/plan-frame-ranges");
9
+ const getRenderedFramesProgress = ({ contents, renderId, framesPerLambda, everyNthFrame, frameRange, }) => {
10
+ const chunkProgress = {};
11
+ const { chunks } = (0, plan_frame_ranges_1.planFrameRanges)({
12
+ everyNthFrame,
13
+ frameRange,
14
+ framesPerLambda,
15
+ });
16
+ // Sort, so only the latest attempt is used
17
+ const sortedChunks = contents
18
+ .filter((c) => {
19
+ return c.Key.startsWith((0, constants_1.lambdaChunkInitializedPrefix)(renderId));
20
+ })
21
+ .sort((a, b) => {
22
+ return a.Key.localeCompare(b.Key);
23
+ });
24
+ for (const chunk of sortedChunks) {
25
+ const key = (0, parse_lambda_initialized_key_1.parseLambdaInitializedKey)(chunk.Key);
26
+ chunkProgress[key.chunk] = (0, chunk_progress_1.getProgressOfChunk)(chunk.ETag);
27
+ }
28
+ for (const chunk of contents.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.chunkKey)(renderId)); })) {
29
+ const parsed = (0, parse_chunk_key_1.parseLambdaChunkKey)(chunk.Key);
30
+ const frameRangeInChunk = chunks[parsed.chunk];
31
+ chunkProgress[parsed.chunk] =
32
+ frameRangeInChunk[1] - frameRangeInChunk[0] + 1;
33
+ }
34
+ const framesRendered = Object.values(chunkProgress).reduce((a, b) => a + b, 0);
35
+ return framesRendered;
36
+ };
37
+ exports.getRenderedFramesProgress = getRenderedFramesProgress;
@@ -1,12 +1,33 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.launchHandler = void 0;
7
27
  const client_lambda_1 = require("@aws-sdk/client-lambda");
8
28
  const renderer_1 = require("@remotion/renderer");
9
- const fs_1 = __importDefault(require("fs"));
29
+ const fs_1 = __importStar(require("fs"));
30
+ const path_1 = require("path");
10
31
  const remotion_1 = require("remotion");
11
32
  const version_1 = require("remotion/version");
12
33
  const aws_clients_1 = require("../shared/aws-clients");
@@ -29,7 +50,6 @@ const find_output_file_in_bucket_1 = require("./helpers/find-output-file-in-buck
29
50
  const get_browser_instance_1 = require("./helpers/get-browser-instance");
30
51
  const get_current_region_1 = require("./helpers/get-current-region");
31
52
  const get_files_to_delete_1 = require("./helpers/get-files-to-delete");
32
- const get_lambdas_invoked_stats_1 = require("./helpers/get-lambdas-invoked-stats");
33
53
  const get_output_url_from_metadata_1 = require("./helpers/get-output-url-from-metadata");
34
54
  const inspect_errors_1 = require("./helpers/inspect-errors");
35
55
  const io_1 = require("./helpers/io");
@@ -223,6 +243,8 @@ const innerLaunchHandler = async (params, options) => {
223
243
  renderId: params.renderId,
224
244
  outName: (_b = params.outName) !== null && _b !== void 0 ? _b : undefined,
225
245
  privacy: params.privacy,
246
+ everyNthFrame: params.everyNthFrame,
247
+ frameRange: realFrameRange,
226
248
  };
227
249
  const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, params.bucketName, typeof params.outName === 'string' || typeof params.outName === 'undefined'
228
250
  ? null
@@ -264,27 +286,17 @@ const innerLaunchHandler = async (params, options) => {
264
286
  }));
265
287
  reqSend.end();
266
288
  let lastProgressUploaded = 0;
267
- let encodingStop = null;
268
- const onProgress = (framesEncoded, start) => {
289
+ const onProgress = (framesEncoded) => {
269
290
  const relativeProgress = framesEncoded / frameCount.length;
270
291
  const deltaSinceLastProgressUploaded = relativeProgress - lastProgressUploaded;
271
- if (relativeProgress === 1) {
272
- encodingStop = Date.now();
273
- }
274
292
  if (deltaSinceLastProgressUploaded < 0.1) {
275
293
  return;
276
294
  }
277
295
  lastProgressUploaded = relativeProgress;
278
- const encodingProgress = {
279
- framesEncoded,
280
- totalFrames: frameCount.length,
281
- doneIn: encodingStop ? encodingStop - start : null,
282
- timeToInvoke: null,
283
- };
284
296
  (0, io_1.lambdaWriteFile)({
285
297
  bucketName: params.bucketName,
286
298
  key: (0, constants_1.encodingProgressKey)(params.renderId),
287
- body: JSON.stringify(encodingProgress),
299
+ body: String(framesEncoded),
288
300
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
289
301
  privacy: 'private',
290
302
  expectedBucketOwner: options.expectedBucketOwner,
@@ -338,24 +350,35 @@ const innerLaunchHandler = async (params, options) => {
338
350
  throw new Error('Stopping Lambda function because error occurred: ' + errors[0].stack);
339
351
  };
340
352
  const fps = comp.fps / params.everyNthFrame;
341
- const { outfile, cleanupChunksProm, encodingStart } = await (0, concat_videos_1.concatVideosS3)({
353
+ const outdir = (0, path_1.join)(renderer_1.RenderInternals.tmpDir(constants_1.CONCAT_FOLDER_TOKEN), 'bucket');
354
+ if ((0, fs_1.existsSync)(outdir)) {
355
+ (fs_1.rmSync !== null && fs_1.rmSync !== void 0 ? fs_1.rmSync : fs_1.rmdirSync)(outdir, {
356
+ recursive: true,
357
+ });
358
+ }
359
+ (0, fs_1.mkdirSync)(outdir);
360
+ const files = await (0, concat_videos_1.getAllFilesS3)({
342
361
  bucket: params.bucketName,
343
362
  expectedFiles: chunkCount,
344
- onProgress,
345
- numberOfFrames: frameCount.length,
363
+ outdir,
346
364
  renderId: params.renderId,
347
365
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
348
- codec: params.codec,
349
366
  expectedBucketOwner: options.expectedBucketOwner,
367
+ onErrors,
368
+ });
369
+ const encodingStart = Date.now();
370
+ const { outfile, cleanupChunksProm } = await (0, concat_videos_1.concatVideosS3)({
371
+ onProgress,
372
+ numberOfFrames: frameCount.length,
373
+ codec: params.codec,
350
374
  fps,
351
375
  numberOfGifLoops: params.numberOfGifLoops,
352
376
  ffmpegExecutable: null,
353
377
  remotionRoot: process.cwd(),
354
- onErrors,
378
+ files,
379
+ outdir,
355
380
  });
356
- if (!encodingStop) {
357
- encodingStop = Date.now();
358
- }
381
+ const encodingStop = Date.now();
359
382
  const outputSize = fs_1.default.statSync(outfile);
360
383
  await (0, io_1.lambdaWriteFile)({
361
384
  bucketName: renderBucketName,
@@ -373,22 +396,10 @@ const innerLaunchHandler = async (params, options) => {
373
396
  expectedBucketOwner: options.expectedBucketOwner,
374
397
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
375
398
  });
376
- const finalEncodingProgress = {
377
- framesEncoded: frameCount.length,
378
- totalFrames: frameCount.length,
379
- doneIn: encodingStop ? encodingStop - encodingStart : null,
380
- timeToInvoke: (0, get_lambdas_invoked_stats_1.getLambdasInvokedStats)({
381
- contents,
382
- renderId: params.renderId,
383
- estimatedRenderLambdaInvokations: renderMetadata.estimatedRenderLambdaInvokations,
384
- checkIfAllLambdasWereInvoked: false,
385
- startDate: renderMetadata.startedDate,
386
- }).timeToInvokeLambdas,
387
- };
388
399
  const finalEncodingProgressProm = (0, io_1.lambdaWriteFile)({
389
400
  bucketName: params.bucketName,
390
401
  key: (0, constants_1.encodingProgressKey)(params.renderId),
391
- body: JSON.stringify(finalEncodingProgress),
402
+ body: String(frameCount.length),
392
403
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
393
404
  privacy: 'private',
394
405
  expectedBucketOwner: options.expectedBucketOwner,
@@ -9,13 +9,11 @@ const renderer_1 = require("@remotion/renderer");
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const aws_clients_1 = require("../shared/aws-clients");
12
+ const chunk_progress_1 = require("../shared/chunk-progress");
12
13
  const constants_1 = require("../shared/constants");
13
14
  const deserialize_input_props_1 = require("../shared/deserialize-input-props");
14
- const clean_tmpdir_1 = require("./helpers/clean-tmpdir");
15
15
  const get_browser_instance_1 = require("./helpers/get-browser-instance");
16
16
  const get_current_region_1 = require("./helpers/get-current-region");
17
- const get_files_in_folder_1 = require("./helpers/get-files-in-folder");
18
- const get_folder_size_1 = require("./helpers/get-folder-size");
19
17
  const io_1 = require("./helpers/io");
20
18
  const write_lambda_error_1 = require("./helpers/write-lambda-error");
21
19
  const renderHandler = async (params, options, logs) => {
@@ -64,9 +62,17 @@ const renderHandler = async (params, options, logs) => {
64
62
  inputProps,
65
63
  frameRange: params.frameRange,
66
64
  onProgress: ({ renderedFrames, encodedFrames, stitchStage }) => {
67
- if (renderedFrames % 10 === 0 &&
65
+ if (renderedFrames % 5 === 0 &&
68
66
  renderer_1.RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose')) {
69
67
  console.log(`Rendered ${renderedFrames} frames, encoded ${encodedFrames} frames, stage = ${stitchStage}`);
68
+ (0, chunk_progress_1.writeLambdaInitializedFile)({
69
+ attempt: params.attempt,
70
+ bucketName: params.bucketName,
71
+ chunk: params.chunk,
72
+ expectedBucketOwner: options.expectedBucketOwner,
73
+ framesRendered: renderedFrames,
74
+ renderId: params.renderId,
75
+ }).catch((err) => reject(err));
70
76
  }
71
77
  const allFrames = renderer_1.RenderInternals.getFramesToRender(params.frameRange, params.everyNthFrame);
72
78
  if (renderedFrames === allFrames.length) {
@@ -76,26 +82,13 @@ const renderHandler = async (params, options, logs) => {
76
82
  },
77
83
  concurrency: params.concurrencyPerLambda,
78
84
  onStart: () => {
79
- (0, io_1.lambdaWriteFile)({
80
- privacy: 'private',
85
+ (0, chunk_progress_1.writeLambdaInitializedFile)({
86
+ attempt: params.attempt,
81
87
  bucketName: params.bucketName,
82
- body: JSON.stringify({
83
- filesCleaned: clean_tmpdir_1.deletedFilesSize,
84
- filesInTmp: fs_1.default.readdirSync('/tmp'),
85
- isWarm: options.isWarm,
86
- deletedFiles: clean_tmpdir_1.deletedFiles,
87
- tmpSize: (0, get_folder_size_1.getFolderSizeRecursively)('/tmp'),
88
- tmpDirFiles: (0, get_files_in_folder_1.getFolderFiles)('/tmp'),
89
- }),
90
- key: (0, constants_1.lambdaChunkInitializedKey)({
91
- renderId: params.renderId,
92
- chunk: params.chunk,
93
- attempt: params.attempt,
94
- }),
95
- region: (0, get_current_region_1.getCurrentRegionInFunction)(),
88
+ chunk: params.chunk,
96
89
  expectedBucketOwner: options.expectedBucketOwner,
97
- downloadBehavior: null,
98
- customCredentials: null,
90
+ framesRendered: 0,
91
+ renderId: params.renderId,
99
92
  }).catch((err) => reject(err));
100
93
  },
101
94
  puppeteerInstance: browserInstance,
@@ -93,6 +93,8 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
93
93
  renderId,
94
94
  outName: (_b = lambdaParams.outName) !== null && _b !== void 0 ? _b : undefined,
95
95
  privacy: lambdaParams.privacy,
96
+ everyNthFrame: 1,
97
+ frameRange: [lambdaParams.frame, lambdaParams.frame],
96
98
  };
97
99
  await (0, io_1.lambdaWriteFile)({
98
100
  bucketName,
@@ -3,6 +3,7 @@ import { IAMClient } from '@aws-sdk/client-iam';
3
3
  import { LambdaClient } from '@aws-sdk/client-lambda';
4
4
  import { S3Client } from '@aws-sdk/client-s3';
5
5
  import { ServiceQuotasClient } from '@aws-sdk/client-service-quotas';
6
+ import { STSClient } from '@aws-sdk/client-sts';
6
7
  import type { AwsRegion } from '../pricing/aws-regions';
7
8
  export declare type ServiceMapping = {
8
9
  s3: S3Client;
@@ -10,6 +11,7 @@ export declare type ServiceMapping = {
10
11
  iam: IAMClient;
11
12
  lambda: LambdaClient;
12
13
  servicequotas: ServiceQuotasClient;
14
+ sts: STSClient;
13
15
  };
14
16
  export declare type CustomCredentialsWithoutSensitiveData = {
15
17
  endpoint: string;
@@ -28,3 +30,4 @@ export declare const getS3Client: (region: AwsRegion, customCredentials: CustomC
28
30
  export declare const getLambdaClient: (region: AwsRegion) => LambdaClient;
29
31
  export declare const getIamClient: (region: AwsRegion) => IAMClient;
30
32
  export declare const getServiceQuotasClient: (region: AwsRegion) => ServiceQuotasClient;
33
+ export declare const getStsClient: (region: AwsRegion) => STSClient;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getServiceQuotasClient = exports.getIamClient = exports.getLambdaClient = exports.getS3Client = exports.getCloudWatchLogsClient = exports.getServiceClient = void 0;
3
+ exports.getStsClient = exports.getServiceQuotasClient = exports.getIamClient = exports.getLambdaClient = exports.getS3Client = exports.getCloudWatchLogsClient = exports.getServiceClient = void 0;
4
4
  const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
5
5
  const client_iam_1 = require("@aws-sdk/client-iam");
6
6
  const client_lambda_1 = require("@aws-sdk/client-lambda");
7
7
  const client_s3_1 = require("@aws-sdk/client-s3");
8
8
  const client_service_quotas_1 = require("@aws-sdk/client-service-quotas");
9
+ const client_sts_1 = require("@aws-sdk/client-sts");
9
10
  const check_credentials_1 = require("./check-credentials");
10
11
  const is_in_lambda_1 = require("./is-in-lambda");
11
12
  const _clients = {};
@@ -55,6 +56,9 @@ const getServiceClient = ({ region, service, customCredentials, }) => {
55
56
  if (service === 'servicequotas') {
56
57
  return client_service_quotas_1.ServiceQuotasClient;
57
58
  }
59
+ if (service === 'sts') {
60
+ return client_sts_1.STSClient;
61
+ }
58
62
  throw new TypeError('unknown client ' + service);
59
63
  })();
60
64
  const key = getKey({
@@ -119,3 +123,7 @@ const getServiceQuotasClient = (region) => {
119
123
  });
120
124
  };
121
125
  exports.getServiceQuotasClient = getServiceQuotasClient;
126
+ const getStsClient = (region) => {
127
+ return (0, exports.getServiceClient)({ region, service: 'sts', customCredentials: null });
128
+ };
129
+ exports.getStsClient = getStsClient;
@@ -0,0 +1,9 @@
1
+ export declare const writeLambdaInitializedFile: ({ bucketName, expectedBucketOwner, attempt, chunk, renderId, framesRendered, }: {
2
+ bucketName: string;
3
+ expectedBucketOwner: string;
4
+ renderId: string;
5
+ chunk: number;
6
+ attempt: number;
7
+ framesRendered: number;
8
+ }) => Promise<void>;
9
+ export declare const getProgressOfChunk: (etag: string) => number;