@remotion/lambda 4.0.0-copy.4 → 4.0.0-esm.17

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 (100) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/admin/bundle-lambda.js +20 -4
  3. package/dist/admin/generate-etag-list.d.ts +1 -0
  4. package/dist/admin/generate-etag-list.js +14 -0
  5. package/dist/admin/make-layer-public.js +23 -1
  6. package/dist/api/deploy-function.js +3 -1
  7. package/dist/api/deploy-site.d.ts +5 -0
  8. package/dist/api/deploy-site.js +39 -21
  9. package/dist/api/get-aws-client.d.ts +2 -0
  10. package/dist/api/get-aws-client.js +2 -0
  11. package/dist/api/get-buckets.js +26 -9
  12. package/dist/api/get-compositions-on-lambda.d.ts +2 -1
  13. package/dist/api/get-compositions-on-lambda.js +1 -3
  14. package/dist/api/get-or-create-bucket.js +2 -7
  15. package/dist/api/get-regions.d.ts +5 -1
  16. package/dist/api/get-regions.js +5 -2
  17. package/dist/api/iam-validation/simulate-rule.js +0 -22
  18. package/dist/api/iam-validation/simulate.js +24 -5
  19. package/dist/api/iam-validation/user-permissions.js +0 -8
  20. package/dist/api/render-media-on-lambda.d.ts +2 -1
  21. package/dist/api/render-media-on-lambda.js +6 -10
  22. package/dist/api/render-still-on-lambda.d.ts +2 -1
  23. package/dist/api/render-still-on-lambda.js +1 -3
  24. package/dist/api/upload-dir.d.ts +4 -3
  25. package/dist/api/upload-dir.js +33 -19
  26. package/dist/cli/args.d.ts +1 -0
  27. package/dist/cli/commands/compositions/index.js +1 -3
  28. package/dist/cli/commands/regions.js +5 -1
  29. package/dist/cli/commands/render/progress.d.ts +6 -3
  30. package/dist/cli/commands/render/progress.js +49 -39
  31. package/dist/cli/commands/render/render.js +17 -4
  32. package/dist/cli/commands/sites/create.js +12 -4
  33. package/dist/cli/commands/still.js +5 -9
  34. package/dist/cli/helpers/progress-bar.d.ts +9 -3
  35. package/dist/cli/helpers/progress-bar.js +19 -3
  36. package/dist/cli/index.js +6 -1
  37. package/dist/functions/compositions.js +10 -3
  38. package/dist/functions/helpers/concat-videos.d.ts +10 -6
  39. package/dist/functions/helpers/concat-videos.js +8 -25
  40. package/dist/functions/helpers/create-post-render-data.js +0 -12
  41. package/dist/functions/helpers/expected-out-name.js +1 -1
  42. package/dist/functions/helpers/get-chromium-executable-path.js +2 -1
  43. package/dist/functions/helpers/get-current-region.d.ts +1 -1
  44. package/dist/functions/helpers/get-encoding-metadata.d.ts +4 -8
  45. package/dist/functions/helpers/get-encoding-metadata.js +4 -18
  46. package/dist/functions/helpers/get-final-encoding-status.d.ts +2 -4
  47. package/dist/functions/helpers/get-final-encoding-status.js +1 -4
  48. package/dist/functions/helpers/get-lambdas-invoked-stats.d.ts +1 -5
  49. package/dist/functions/helpers/get-lambdas-invoked-stats.js +1 -9
  50. package/dist/functions/helpers/get-overall-progress.d.ts +2 -1
  51. package/dist/functions/helpers/get-overall-progress.js +7 -5
  52. package/dist/functions/helpers/get-progress.js +40 -26
  53. package/dist/functions/helpers/get-rendered-frames-progress.d.ts +8 -0
  54. package/dist/functions/helpers/get-rendered-frames-progress.js +37 -0
  55. package/dist/functions/launch.js +50 -38
  56. package/dist/functions/renderer.js +19 -24
  57. package/dist/functions/start.js +9 -2
  58. package/dist/functions/still.js +16 -5
  59. package/dist/index.d.ts +9 -2
  60. package/dist/index.js +10 -2
  61. package/dist/pricing/aws-regions.d.ts +2 -1
  62. package/dist/pricing/aws-regions.js +31 -1
  63. package/dist/pricing/price-per-1-s.js +413 -39
  64. package/dist/shared/aws-clients.d.ts +3 -0
  65. package/dist/shared/aws-clients.js +75 -13
  66. package/dist/shared/check-credentials.js +3 -0
  67. package/dist/shared/chunk-progress.d.ts +9 -0
  68. package/dist/shared/chunk-progress.js +2034 -0
  69. package/dist/shared/constants.d.ts +13 -12
  70. package/dist/shared/convert-to-serve-url.d.ts +5 -1
  71. package/dist/shared/convert-to-serve-url.js +1 -5
  72. package/dist/shared/deserialize-input-props.d.ts +1 -1
  73. package/dist/shared/deserialize-input-props.js +1 -1
  74. package/dist/shared/function-zip-path.d.ts +2 -1
  75. package/dist/shared/function-zip-path.js +3 -2
  76. package/dist/shared/get-account-id.js +4 -6
  77. package/dist/shared/get-etag.d.ts +1 -0
  78. package/dist/shared/get-etag.js +24 -0
  79. package/dist/shared/get-s3-operations.d.ts +10 -0
  80. package/dist/shared/get-s3-operations.js +36 -0
  81. package/dist/shared/hosted-layers.js +368 -60
  82. package/dist/shared/invoke-webhook.d.ts +2 -0
  83. package/dist/shared/parse-chunk-key.d.ts +4 -0
  84. package/dist/shared/parse-chunk-key.js +14 -0
  85. package/dist/shared/read-dir.d.ts +9 -0
  86. package/dist/shared/read-dir.js +57 -0
  87. package/dist/shared/validate-bucketname.d.ts +5 -0
  88. package/dist/shared/validate-bucketname.js +19 -1
  89. package/dist/shared/validate-lambda-codec.d.ts +1 -1
  90. package/dist/shared/validate-lambda-codec.js +0 -1
  91. package/package.json +18 -14
  92. package/remotionlambda-arm64.zip +0 -0
  93. package/remotionlambda-x64.zip +0 -0
  94. package/remotionlambda.zip +0 -0
  95. package/.prettierrc.js +0 -14
  96. package/dist/api/enable-s3-website.d.ts +0 -5
  97. package/dist/api/enable-s3-website.js +0 -16
  98. package/dist/shared/get-cloudwatch-stream-url.d.ts +0 -8
  99. package/dist/shared/get-cloudwatch-stream-url.js +0 -7
  100. package/tsconfig.json +0 -16
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.concatVideosS3 = void 0;
26
+ exports.concatVideosS3 = exports.getAllFilesS3 = void 0;
27
27
  const renderer_1 = require("@remotion/renderer");
28
28
  const fs_1 = __importStar(require("fs"));
29
29
  const path_1 = __importStar(require("path"));
@@ -127,36 +127,19 @@ const getAllFilesS3 = ({ bucket, expectedFiles, outdir, renderId, region, expect
127
127
  loop().catch((err) => reject(err));
128
128
  });
129
129
  };
130
- const concatVideosS3 = async ({ bucket, expectedFiles, onProgress, numberOfFrames, renderId, region, codec, expectedBucketOwner, fps, numberOfGifLoops, ffmpegExecutable, remotionRoot, onErrors, }) => {
130
+ exports.getAllFilesS3 = getAllFilesS3;
131
+ const concatVideosS3 = async ({ onProgress, numberOfFrames, codec, fps, numberOfGifLoops, ffmpegExecutable, remotionRoot, files, outdir, }) => {
131
132
  var _a;
132
- const outdir = (0, path_1.join)(renderer_1.RenderInternals.tmpDir(constants_1.CONCAT_FOLDER_TOKEN), 'bucket');
133
- if ((0, fs_1.existsSync)(outdir)) {
134
- (fs_1.rmSync !== null && fs_1.rmSync !== void 0 ? fs_1.rmSync : fs_1.rmdirSync)(outdir, {
135
- recursive: true,
136
- });
137
- }
138
- (0, fs_1.mkdirSync)(outdir);
139
- const files = await getAllFilesS3({
140
- bucket,
141
- expectedFiles,
142
- outdir,
143
- renderId,
144
- region,
145
- expectedBucketOwner,
146
- onErrors,
147
- });
148
- const outfile = (0, path_1.join)(renderer_1.RenderInternals.tmpDir(constants_1.REMOTION_CONCATED_TOKEN), 'concat.' + renderer_1.RenderInternals.getFileExtensionFromCodec(codec, 'final'));
133
+ const outfile = (0, path_1.join)(renderer_1.RenderInternals.tmpDir(constants_1.REMOTION_CONCATED_TOKEN), 'concat.' + renderer_1.RenderInternals.getFileExtensionFromCodec(codec));
149
134
  const combine = (0, timer_1.timer)('Combine videos');
150
135
  const filelistDir = renderer_1.RenderInternals.tmpDir(constants_1.REMOTION_FILELIST_TOKEN);
151
- const encodingStart = Date.now();
152
- const codecForCombining = codec === 'h264-mkv' ? 'h264' : codec;
153
- await (0, renderer_1.combineVideos)({
136
+ await renderer_1.RenderInternals.combineVideos({
154
137
  files,
155
138
  filelistDir,
156
139
  output: outfile,
157
- onProgress: (p) => onProgress(p, encodingStart),
140
+ onProgress: (p) => onProgress(p),
158
141
  numberOfFrames,
159
- codec: codecForCombining,
142
+ codec,
160
143
  fps,
161
144
  numberOfGifLoops,
162
145
  ffmpegExecutable,
@@ -166,6 +149,6 @@ const concatVideosS3 = async ({ bucket, expectedFiles, onProgress, numberOfFrame
166
149
  const cleanupChunksProm = ((_a = fs_1.default.promises.rm) !== null && _a !== void 0 ? _a : fs_1.default.promises.rmdir)(outdir, {
167
150
  recursive: true,
168
151
  });
169
- return { outfile, cleanupChunksProm, encodingStart };
152
+ return { outfile, cleanupChunksProm };
170
153
  };
171
154
  exports.concatVideosS3 = concatVideosS3;
@@ -8,7 +8,6 @@ const parse_lambda_timings_key_1 = require("../../shared/parse-lambda-timings-ke
8
8
  const calculate_chunk_times_1 = require("./calculate-chunk-times");
9
9
  const get_current_architecture_1 = require("./get-current-architecture");
10
10
  const get_files_to_delete_1 = require("./get-files-to-delete");
11
- const get_lambdas_invoked_stats_1 = require("./get-lambdas-invoked-stats");
12
11
  const get_retry_stats_1 = require("./get-retry-stats");
13
12
  const get_time_to_finish_1 = require("./get-time-to-finish");
14
13
  const createPostRenderData = ({ renderId, region, memorySizeInMb, renderMetadata, contents, timeToEncode, errorExplanations, timeToDelete, outputFile, }) => {
@@ -41,17 +40,7 @@ const createPostRenderData = ({ renderId, region, memorySizeInMb, renderMetadata
41
40
  const renderSize = contents
42
41
  .map((c) => { var _a; return (_a = c.Size) !== null && _a !== void 0 ? _a : 0; })
43
42
  .reduce((a, b) => a + b, 0);
44
- const { timeToInvokeLambdas } = (0, get_lambdas_invoked_stats_1.getLambdasInvokedStats)({
45
- contents,
46
- renderId,
47
- estimatedRenderLambdaInvokations: renderMetadata.estimatedRenderLambdaInvokations,
48
- startDate: renderMetadata.startedDate,
49
- checkIfAllLambdasWereInvoked: false,
50
- });
51
43
  const retriesInfo = (0, get_retry_stats_1.getRetryStats)({ contents, renderId });
52
- if (timeToInvokeLambdas === null) {
53
- throw new Error('should have timing for all lambdas');
54
- }
55
44
  return {
56
45
  cost: {
57
46
  currency: 'USD',
@@ -81,7 +70,6 @@ const createPostRenderData = ({ renderId, region, memorySizeInMb, renderMetadata
81
70
  renderId,
82
71
  type: 'absolute-time',
83
72
  }),
84
- timeToInvokeLambdas,
85
73
  retriesInfo,
86
74
  mostExpensiveFrameRanges: (0, get_most_expensive_chunks_1.getMostExpensiveChunks)(parsedTimings, renderMetadata.framesPerLambda),
87
75
  };
@@ -38,7 +38,7 @@ const getExpectedOutName = (renderMetadata, bucketName, customCredentials) => {
38
38
  if (renderMetadata.type === 'video') {
39
39
  return {
40
40
  renderBucketName: bucketName,
41
- key: (0, defaults_1.outName)(renderMetadata.renderId, renderer_1.RenderInternals.getFileExtensionFromCodec(renderMetadata.codec, 'final')),
41
+ key: (0, defaults_1.outName)(renderMetadata.renderId, renderer_1.RenderInternals.getFileExtensionFromCodec(renderMetadata.codec)),
42
42
  customCredentials: null,
43
43
  };
44
44
  }
@@ -2,9 +2,10 @@
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.executablePath = void 0;
5
- if (/^AWS_Lambda_nodejs(?:10|12|14)[.]x$/.test((_a = process.env.AWS_EXECUTION_ENV) !== null && _a !== void 0 ? _a : '') === true) {
5
+ if (/^AWS_Lambda_nodejs(?:10|12|14|16|18)[.]x$/.test((_a = process.env.AWS_EXECUTION_ENV) !== null && _a !== void 0 ? _a : '') === true) {
6
6
  if (process.env.FONTCONFIG_PATH === undefined) {
7
7
  process.env.FONTCONFIG_PATH = '/opt';
8
+ process.env.FONTCONFIG_FILE = '/opt/fonts.conf';
8
9
  }
9
10
  process.env.LD_LIBRARY_PATH = '/opt/lib:/opt/bin';
10
11
  }
@@ -1 +1 @@
1
- export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "us-east-1" | "us-east-2" | "us-west-2" | "ap-south-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1";
1
+ export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-south-1" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "af-south-1" | "ap-south-1" | "ap-east-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "me-south-1" | "sa-east-1";
@@ -1,9 +1,5 @@
1
+ import type { _Object } from '@aws-sdk/client-s3';
1
2
  import type { EncodingProgress } from '../../defaults';
2
- import type { AwsRegion } from '../../pricing/aws-regions';
3
- export declare const getEncodingMetadata: ({ exists, bucketName, renderId, region, expectedBucketOwner, }: {
4
- exists: boolean;
5
- bucketName: string;
6
- renderId: string;
7
- region: AwsRegion;
8
- expectedBucketOwner: string;
9
- }) => Promise<EncodingProgress | null>;
3
+ export declare const getEncodingMetadata: ({ exists, }: {
4
+ exists: _Object | undefined;
5
+ }) => EncodingProgress | null;
@@ -1,26 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEncodingMetadata = void 0;
4
- const defaults_1 = require("../../defaults");
5
- const stream_to_string_1 = require("../../shared/stream-to-string");
6
- const io_1 = require("./io");
7
- const getEncodingMetadata = async ({ exists, bucketName, renderId, region, expectedBucketOwner, }) => {
4
+ const chunk_progress_1 = require("../../shared/chunk-progress");
5
+ const getEncodingMetadata = ({ exists, }) => {
8
6
  if (!exists) {
9
7
  return null;
10
8
  }
11
- try {
12
- const Body = await (0, io_1.lambdaReadFile)({
13
- bucketName,
14
- key: (0, defaults_1.encodingProgressKey)(renderId),
15
- region,
16
- expectedBucketOwner,
17
- });
18
- const encodingProgress = JSON.parse(await (0, stream_to_string_1.streamToString)(Body));
19
- return encodingProgress;
20
- }
21
- catch (err) {
22
- // The file may not yet have been fully written or already have been cleaned up again
23
- return null;
24
- }
9
+ const framesEncoded = (0, chunk_progress_1.getProgressOfChunk)(exists.ETag);
10
+ return { framesEncoded };
25
11
  };
26
12
  exports.getEncodingMetadata = getEncodingMetadata;
@@ -1,8 +1,6 @@
1
1
  import type { EncodingProgress, RenderMetadata } from '../../shared/constants';
2
- import type { LambdaInvokeStats } from './get-lambdas-invoked-stats';
3
- export declare const getFinalEncodingStatus: ({ encodingStatus: encodingProgress, renderMetadata, outputFileExists, lambdaInvokeStatus, }: {
4
- encodingStatus: EncodingProgress | null;
2
+ export declare const getFinalEncodingStatus: ({ encodingProgress, renderMetadata, outputFileExists, }: {
3
+ encodingProgress: EncodingProgress | null;
5
4
  renderMetadata: RenderMetadata | null;
6
5
  outputFileExists: boolean;
7
- lambdaInvokeStatus: LambdaInvokeStats;
8
6
  }) => EncodingProgress | null;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFinalEncodingStatus = void 0;
4
- const getFinalEncodingStatus = ({ encodingStatus: encodingProgress, renderMetadata, outputFileExists, lambdaInvokeStatus, }) => {
4
+ const getFinalEncodingStatus = ({ encodingProgress, renderMetadata, outputFileExists, }) => {
5
5
  if (!renderMetadata) {
6
6
  return null;
7
7
  }
@@ -11,9 +11,6 @@ const getFinalEncodingStatus = ({ encodingStatus: encodingProgress, renderMetada
11
11
  if (outputFileExists) {
12
12
  return {
13
13
  framesEncoded: renderMetadata.videoConfig.durationInFrames,
14
- totalFrames: renderMetadata.videoConfig.durationInFrames,
15
- doneIn: null,
16
- timeToInvoke: lambdaInvokeStatus.timeToInvokeLambdas,
17
14
  };
18
15
  }
19
16
  return null;
@@ -1,12 +1,8 @@
1
1
  import type { _Object } from '@aws-sdk/client-s3';
2
2
  export declare type LambdaInvokeStats = {
3
- timeToInvokeLambdas: number | null;
4
3
  lambdasInvoked: number;
5
4
  };
6
- export declare const getLambdasInvokedStats: ({ contents, renderId, estimatedRenderLambdaInvokations, startDate, checkIfAllLambdasWereInvoked, }: {
5
+ export declare const getLambdasInvokedStats: ({ contents, renderId, }: {
7
6
  contents: _Object[];
8
7
  renderId: string;
9
- estimatedRenderLambdaInvokations: number | null;
10
- startDate: number | null;
11
- checkIfAllLambdasWereInvoked: boolean;
12
8
  }) => LambdaInvokeStats;
@@ -3,19 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLambdasInvokedStats = void 0;
4
4
  const constants_1 = require("../../shared/constants");
5
5
  const parse_lambda_initialized_key_1 = require("../../shared/parse-lambda-initialized-key");
6
- const min_max_1 = require("./min-max");
7
- const getLambdasInvokedStats = ({ contents, renderId, estimatedRenderLambdaInvokations, startDate, checkIfAllLambdasWereInvoked, }) => {
8
- var _a;
6
+ const getLambdasInvokedStats = ({ contents, renderId, }) => {
9
7
  const lambdasInvoked = contents
10
8
  .filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaChunkInitializedPrefix)(renderId)); })
11
9
  .filter((c) => (0, parse_lambda_initialized_key_1.parseLambdaInitializedKey)(c.Key).attempt === 1);
12
- const allLambdasInvoked = !checkIfAllLambdasWereInvoked ||
13
- lambdasInvoked.length === estimatedRenderLambdaInvokations;
14
- const timeToInvokeLambdas = !allLambdasInvoked || startDate === null
15
- ? null
16
- : ((_a = (0, min_max_1.max)(lambdasInvoked.map((l) => { var _a; return (_a = l.LastModified) === null || _a === void 0 ? void 0 : _a.getTime(); }))) !== null && _a !== void 0 ? _a : 0) - startDate;
17
10
  return {
18
- timeToInvokeLambdas,
19
11
  lambdasInvoked: lambdasInvoked.length,
20
12
  };
21
13
  };
@@ -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, _j;
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,13 @@ 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,
75
+ outputSizeInBytes: postRenderData.outputSize,
73
76
  };
74
77
  }
75
78
  const contents = await (0, io_1.lambdaLs)({
@@ -78,16 +81,11 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
78
81
  region: (0, get_current_region_1.getCurrentRegionInFunction)(),
79
82
  expectedBucketOwner,
80
83
  });
81
- (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,
@@ -107,6 +105,7 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
107
105
  if ((renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.type) === 'still') {
108
106
  throw new Error("You don't need to call getRenderProgress() on a still render. Once you have obtained the `renderId`, the render is already done! 😉");
109
107
  }
108
+ (0, check_if_render_exists_1.checkIfRenderExists)(contents, renderId, bucketName, (0, get_current_region_1.getCurrentRegionInFunction)());
110
109
  const outputFile = renderMetadata
111
110
  ? await (0, find_output_file_in_bucket_1.findOutputFileInBucket)({
112
111
  bucketName,
@@ -137,6 +136,20 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
137
136
  renderMetadata,
138
137
  });
139
138
  const chunks = contents.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.chunkKey)(renderId)); });
139
+ const framesRendered = renderMetadata
140
+ ? (0, get_rendered_frames_progress_1.getRenderedFramesProgress)({
141
+ contents,
142
+ everyNthFrame: renderMetadata.everyNthFrame,
143
+ frameRange: renderMetadata.frameRange,
144
+ framesPerLambda: renderMetadata.framesPerLambda,
145
+ renderId,
146
+ })
147
+ : 0;
148
+ console.log('etags', contents
149
+ .filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaChunkInitializedPrefix)(renderId)); })
150
+ .map((c) => {
151
+ return (0, chunk_progress_1.getProgressOfChunk)(c.ETag);
152
+ }));
140
153
  const allChunks = chunks.length === ((_f = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _f !== void 0 ? _f : Infinity);
141
154
  const renderSize = contents
142
155
  .map((c) => { var _a; return (_a = c.Size) !== null && _a !== void 0 ? _a : 0; })
@@ -144,22 +157,18 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
144
157
  const lambdasInvokedStats = (0, get_lambdas_invoked_stats_1.getLambdasInvokedStats)({
145
158
  contents,
146
159
  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
160
  });
151
161
  const retriesInfo = (0, get_retry_stats_1.getRetryStats)({
152
162
  contents,
153
163
  renderId,
154
164
  });
155
165
  const finalEncodingStatus = (0, get_final_encoding_status_1.getFinalEncodingStatus)({
156
- encodingStatus,
166
+ encodingProgress: encodingStatus,
157
167
  outputFileExists: Boolean(outputFile),
158
168
  renderMetadata,
159
- lambdaInvokeStatus: lambdasInvokedStats,
160
169
  });
161
170
  const chunkCount = outputFile
162
- ? (_j = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _j !== void 0 ? _j : 0
171
+ ? (_g = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _g !== void 0 ? _g : 0
163
172
  : chunks.length;
164
173
  // 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
174
  const isBeyondTimeout = renderMetadata &&
@@ -182,7 +191,11 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
182
191
  : null,
183
192
  ...errorExplanations,
184
193
  ].filter(remotion_1.Internals.truthy);
194
+ const frameCount = renderMetadata
195
+ ? renderer_1.RenderInternals.getFramesToRender(renderMetadata.frameRange, renderMetadata.everyNthFrame).length
196
+ : null;
185
197
  return {
198
+ framesRendered,
186
199
  chunks: chunkCount,
187
200
  done: false,
188
201
  encodingStatus,
@@ -190,7 +203,7 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
190
203
  renderId,
191
204
  renderMetadata,
192
205
  bucket: bucketName,
193
- outputFile: (_k = outputFile === null || outputFile === void 0 ? void 0 : outputFile.url) !== null && _k !== void 0 ? _k : null,
206
+ outputFile: (_h = outputFile === null || outputFile === void 0 ? void 0 : outputFile.url) !== null && _h !== void 0 ? _h : null,
194
207
  timeToFinish,
195
208
  errors: allErrors,
196
209
  fatalErrorEncountered: allErrors.some((f) => f.isFatal && !f.willRetry),
@@ -205,18 +218,17 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
205
218
  type: 'absolute-time',
206
219
  })
207
220
  : null,
208
- timeToInvokeLambdas: (_l = encodingStatus === null || encodingStatus === void 0 ? void 0 : encodingStatus.timeToInvoke) !== null && _l !== void 0 ? _l : lambdasInvokedStats.timeToInvokeLambdas,
209
221
  overallProgress: (0, get_overall_progress_1.getOverallProgress)({
210
222
  cleanup: cleanup ? cleanup.filesDeleted / cleanup.minFilesToDelete : 0,
211
- encoding: finalEncodingStatus && renderMetadata
212
- ? finalEncodingStatus.framesEncoded /
213
- renderMetadata.videoConfig.durationInFrames
223
+ encoding: finalEncodingStatus && renderMetadata && frameCount
224
+ ? finalEncodingStatus.framesEncoded / frameCount
214
225
  : 0,
215
226
  invoking: renderMetadata
216
227
  ? lambdasInvokedStats.lambdasInvoked /
217
228
  renderMetadata.estimatedRenderLambdaInvokations
218
229
  : 0,
219
230
  rendering: renderMetadata ? chunkCount / renderMetadata.totalChunks : 0,
231
+ frames: frameCount === null ? 0 : framesRendered / frameCount,
220
232
  }),
221
233
  retriesInfo,
222
234
  outKey: outputFile && renderMetadata
@@ -227,6 +239,8 @@ const getProgress = async ({ bucketName, renderId, expectedBucketOwner, region,
227
239
  .renderBucketName
228
240
  : null,
229
241
  mostExpensiveFrameRanges: null,
242
+ timeToEncode: null,
243
+ outputSizeInBytes: (_j = outputFile === null || outputFile === void 0 ? void 0 : outputFile.size) !== null && _j !== void 0 ? _j : null,
230
244
  };
231
245
  };
232
246
  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;