@remotion/lambda 4.0.164 → 4.0.165

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 (80) hide show
  1. package/dist/api/delete-render.js +7 -3
  2. package/dist/api/deploy-function.d.ts +0 -1
  3. package/dist/api/deploy-function.js +3 -3
  4. package/dist/api/download-media.js +6 -3
  5. package/dist/api/get-compositions-on-lambda.js +0 -2
  6. package/dist/api/get-render-progress.js +0 -2
  7. package/dist/api/make-lambda-payload.js +2 -1
  8. package/dist/api/render-media-on-lambda.js +0 -2
  9. package/dist/api/render-still-on-lambda.js +37 -25
  10. package/dist/cli/commands/render/progress.d.ts +3 -28
  11. package/dist/cli/commands/render/progress.js +89 -90
  12. package/dist/cli/commands/render/render.js +7 -40
  13. package/dist/cli/commands/sites/create.js +2 -2
  14. package/dist/functions/chunk-optimization/types.d.ts +0 -3
  15. package/dist/functions/helpers/calculate-chunk-times.d.ts +3 -4
  16. package/dist/functions/helpers/calculate-chunk-times.js +4 -8
  17. package/dist/functions/helpers/calculate-price-from-bucket.d.ts +3 -5
  18. package/dist/functions/helpers/calculate-price-from-bucket.js +5 -18
  19. package/dist/functions/helpers/clean-tmpdir.d.ts +0 -2
  20. package/dist/functions/helpers/clean-tmpdir.js +1 -7
  21. package/dist/functions/helpers/concat-videos.d.ts +1 -13
  22. package/dist/functions/helpers/concat-videos.js +7 -131
  23. package/dist/functions/helpers/create-post-render-data.d.ts +6 -6
  24. package/dist/functions/helpers/create-post-render-data.js +17 -37
  25. package/dist/functions/helpers/find-output-file-in-bucket.d.ts +1 -3
  26. package/dist/functions/helpers/find-output-file-in-bucket.js +1 -4
  27. package/dist/functions/helpers/get-encoding-progress-step-size.d.ts +1 -1
  28. package/dist/functions/helpers/get-encoding-progress-step-size.js +0 -3
  29. package/dist/functions/helpers/get-lambdas-invoked-stats.d.ts +1 -6
  30. package/dist/functions/helpers/get-lambdas-invoked-stats.js +0 -13
  31. package/dist/functions/helpers/get-overall-progress-s3.d.ts +4 -2
  32. package/dist/functions/helpers/get-overall-progress-s3.js +8 -6
  33. package/dist/functions/helpers/get-overall-progress.d.ts +1 -2
  34. package/dist/functions/helpers/get-overall-progress.js +2 -4
  35. package/dist/functions/helpers/get-progress.js +78 -154
  36. package/dist/functions/helpers/get-retry-stats.d.ts +0 -5
  37. package/dist/functions/helpers/get-retry-stats.js +0 -18
  38. package/dist/functions/helpers/inspect-errors.d.ts +4 -10
  39. package/dist/functions/helpers/inspect-errors.js +5 -27
  40. package/dist/functions/helpers/io.d.ts +0 -1
  41. package/dist/functions/helpers/io.js +2 -3
  42. package/dist/functions/helpers/lifecycle.d.ts +0 -4
  43. package/dist/functions/helpers/lifecycle.js +2 -3
  44. package/dist/functions/helpers/make-timeout-error.d.ts +0 -2
  45. package/dist/functions/helpers/merge-chunks.d.ts +5 -0
  46. package/dist/functions/helpers/merge-chunks.js +16 -143
  47. package/dist/functions/helpers/min-max.d.ts +1 -1
  48. package/dist/functions/helpers/min-max.js +1 -1
  49. package/dist/functions/helpers/overall-render-progress.d.ts +26 -4
  50. package/dist/functions/helpers/overall-render-progress.js +116 -27
  51. package/dist/functions/helpers/stream-renderer.js +15 -9
  52. package/dist/functions/helpers/streamify-response.d.ts +0 -3
  53. package/dist/functions/helpers/streamify-response.js +2 -14
  54. package/dist/functions/helpers/write-lambda-error.d.ts +3 -6
  55. package/dist/functions/helpers/write-lambda-error.js +1 -21
  56. package/dist/functions/index.d.ts +5 -0
  57. package/dist/functions/index.js +70 -38
  58. package/dist/functions/launch.js +103 -133
  59. package/dist/functions/renderer.d.ts +2 -2
  60. package/dist/functions/renderer.js +70 -123
  61. package/dist/functions/start.d.ts +1 -0
  62. package/dist/functions/start.js +3 -2
  63. package/dist/functions/still.d.ts +7 -2
  64. package/dist/functions/still.js +17 -34
  65. package/dist/functions/streaming/streaming.d.ts +15 -2
  66. package/dist/functions/streaming/streaming.js +8 -6
  67. package/dist/internals.d.ts +2 -1
  68. package/dist/shared/aws-clients.js +8 -0
  69. package/dist/shared/call-lambda.d.ts +5 -4
  70. package/dist/shared/call-lambda.js +53 -44
  71. package/dist/shared/constants.d.ts +14 -35
  72. package/dist/shared/constants.js +3 -31
  73. package/dist/shared/content-disposition-header.d.ts +0 -3
  74. package/dist/shared/get-function-version.js +0 -2
  75. package/dist/shared/is-flaky-error.js +4 -0
  76. package/dist/shared/parse-lambda-timings-key.d.ts +0 -2
  77. package/dist/shared/parse-lambda-timings-key.js +0 -14
  78. package/dist/shared/return-values.d.ts +0 -5
  79. package/package.json +18 -18
  80. package/remotionlambda-arm64.zip +0 -0
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deleteRender = void 0;
4
4
  const defaults_1 = require("../defaults");
5
5
  const expected_out_name_1 = require("../functions/helpers/expected-out-name");
6
- const get_render_metadata_1 = require("../functions/helpers/get-render-metadata");
6
+ const get_overall_progress_s3_1 = require("../functions/helpers/get-overall-progress-s3");
7
7
  const io_1 = require("../functions/helpers/io");
8
8
  const get_account_id_1 = require("../shared/get-account-id");
9
9
  const clean_items_1 = require("./clean-items");
@@ -20,13 +20,17 @@ const deleteRender = async (input) => {
20
20
  const expectedBucketOwner = await (0, get_account_id_1.getAccountId)({
21
21
  region: input.region,
22
22
  });
23
- const renderMetadata = await (0, get_render_metadata_1.getRenderMetadata)({
23
+ const progress = await (0, get_overall_progress_s3_1.getOverallProgressS3)({
24
24
  bucketName: input.bucketName,
25
25
  expectedBucketOwner,
26
26
  region: input.region,
27
27
  renderId: input.renderId,
28
28
  });
29
- const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, input.bucketName, (_a = input.customCredentials) !== null && _a !== void 0 ? _a : null);
29
+ // Render did not start yet
30
+ if (progress.renderMetadata === null) {
31
+ return { freedBytes: 0 };
32
+ }
33
+ const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(progress.renderMetadata, input.bucketName, (_a = input.customCredentials) !== null && _a !== void 0 ? _a : null);
30
34
  await (0, io_1.lambdaDeleteFile)({
31
35
  bucketName: renderBucketName,
32
36
  customCredentials,
@@ -23,7 +23,6 @@ export type DeployFunctionOutput = {
23
23
  alreadyExisted: boolean;
24
24
  };
25
25
  export declare const internalDeployFunction: (params: MandatoryParameters & OptionalParameters) => Promise<DeployFunctionOutput>;
26
- export declare const errorHandled: (params: MandatoryParameters & OptionalParameters) => Promise<DeployFunctionOutput>;
27
26
  /**
28
27
  * @description Creates an AWS Lambda function in your account that will be able to render a video in the cloud.
29
28
  * @see [Documentation](https://www.remotion.dev/docs/lambda/deployfunction)
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deployFunction = exports.errorHandled = exports.internalDeployFunction = void 0;
3
+ exports.deployFunction = exports.internalDeployFunction = void 0;
4
4
  const pure_1 = require("@remotion/renderer/pure");
5
5
  const no_react_1 = require("remotion/no-react");
6
6
  const version_1 = require("remotion/version");
@@ -66,7 +66,7 @@ const internalDeployFunction = async (params) => {
66
66
  };
67
67
  };
68
68
  exports.internalDeployFunction = internalDeployFunction;
69
- exports.errorHandled = pure_1.NoReactAPIs.wrapWithErrorHandling(exports.internalDeployFunction);
69
+ const errorHandled = pure_1.NoReactAPIs.wrapWithErrorHandling(exports.internalDeployFunction);
70
70
  /**
71
71
  * @description Creates an AWS Lambda function in your account that will be able to render a video in the cloud.
72
72
  * @see [Documentation](https://www.remotion.dev/docs/lambda/deployfunction)
@@ -82,7 +82,7 @@ exports.errorHandled = pure_1.NoReactAPIs.wrapWithErrorHandling(exports.internal
82
82
  const deployFunction = ({ createCloudWatchLogGroup, memorySizeInMb, region, timeoutInSeconds, cloudWatchLogRetentionPeriodInDays, customRoleArn, enableLambdaInsights, indent, logLevel, enableV5Runtime, vpcSubnetIds, vpcSecurityGroupIds, ...options }) => {
83
83
  var _a;
84
84
  const diskSizeInMb = (_a = options.diskSizeInMb) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_EPHEMERAL_STORAGE_IN_MB;
85
- return (0, exports.errorHandled)({
85
+ return errorHandled({
86
86
  indent: indent !== null && indent !== void 0 ? indent : false,
87
87
  logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
88
88
  createCloudWatchLogGroup,
@@ -7,7 +7,7 @@ exports.downloadMedia = void 0;
7
7
  const renderer_1 = require("@remotion/renderer");
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const expected_out_name_1 = require("../functions/helpers/expected-out-name");
10
- const get_render_metadata_1 = require("../functions/helpers/get-render-metadata");
10
+ const get_overall_progress_s3_1 = require("../functions/helpers/get-overall-progress-s3");
11
11
  const read_with_progress_1 = require("../functions/helpers/read-with-progress");
12
12
  const get_account_id_1 = require("../shared/get-account-id");
13
13
  /**
@@ -26,15 +26,18 @@ const downloadMedia = async (input) => {
26
26
  const expectedBucketOwner = await (0, get_account_id_1.getAccountId)({
27
27
  region: input.region,
28
28
  });
29
- const renderMetadata = await (0, get_render_metadata_1.getRenderMetadata)({
29
+ const overallProgress = await (0, get_overall_progress_s3_1.getOverallProgressS3)({
30
30
  bucketName: input.bucketName,
31
31
  expectedBucketOwner,
32
32
  region: input.region,
33
33
  renderId: input.renderId,
34
34
  });
35
+ if (!overallProgress.renderMetadata) {
36
+ throw new Error('Render did not finish yet');
37
+ }
35
38
  const outputPath = node_path_1.default.resolve(process.cwd(), input.outPath);
36
39
  renderer_1.RenderInternals.ensureOutputDirectory(outputPath);
37
- const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, input.bucketName, (_a = input.customCredentials) !== null && _a !== void 0 ? _a : null);
40
+ const { key, renderBucketName, customCredentials } = (0, expected_out_name_1.getExpectedOutName)(overallProgress.renderMetadata, input.bucketName, (_a = input.customCredentials) !== null && _a !== void 0 ? _a : null);
38
41
  const { sizeInBytes } = await (0, read_with_progress_1.lambdaDownloadFileWithProgress)({
39
42
  bucketName: renderBucketName,
40
43
  expectedBucketOwner,
@@ -46,9 +46,7 @@ const getCompositionsOnLambda = async ({ chromiumOptions, serveUrl, region, inpu
46
46
  offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes !== null && offthreadVideoCacheSizeInBytes !== void 0 ? offthreadVideoCacheSizeInBytes : null,
47
47
  },
48
48
  region,
49
- receivedStreamingPayload: () => undefined,
50
49
  timeoutInTest: 120000,
51
- retriesRemaining: 0,
52
50
  });
53
51
  return res.compositions;
54
52
  }
@@ -20,9 +20,7 @@ const getRenderProgress = async (input) => {
20
20
  type: constants_1.LambdaRoutines.status,
21
21
  payload: (0, make_lambda_payload_1.getRenderProgressPayload)(input),
22
22
  region: input.region,
23
- receivedStreamingPayload: () => undefined,
24
23
  timeoutInTest: 120000,
25
- retriesRemaining: 2,
26
24
  });
27
25
  return result;
28
26
  };
@@ -54,7 +54,7 @@ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange,
54
54
  numberOfGifLoops,
55
55
  concurrencyPerLambda,
56
56
  downloadBehavior,
57
- muted: muted !== null && muted !== void 0 ? muted : false,
57
+ muted,
58
58
  version: version_1.VERSION,
59
59
  overwrite: overwrite !== null && overwrite !== void 0 ? overwrite : false,
60
60
  audioBitrate: audioBitrate !== null && audioBitrate !== void 0 ? audioBitrate : null,
@@ -121,6 +121,7 @@ const makeLambdaRenderStillPayload = async ({ serveUrl, inputProps, imageFormat,
121
121
  offthreadVideoCacheSizeInBytes,
122
122
  deleteAfter,
123
123
  type: defaults_1.LambdaRoutines.still,
124
+ streamed: true,
124
125
  };
125
126
  };
126
127
  exports.makeLambdaRenderStillPayload = makeLambdaRenderStillPayload;
@@ -15,9 +15,7 @@ const internalRenderMediaOnLambdaRaw = async (input) => {
15
15
  type: constants_1.LambdaRoutines.start,
16
16
  payload: await (0, make_lambda_payload_1.makeLambdaRenderMediaPayload)(input),
17
17
  region,
18
- receivedStreamingPayload: () => undefined,
19
18
  timeoutInTest: 120000,
20
- retriesRemaining: 0,
21
19
  });
22
20
  return {
23
21
  renderId: res.renderId,
@@ -10,31 +10,43 @@ const internalRenderStillOnLambda = async (input) => {
10
10
  var _a;
11
11
  const { functionName, region, onInit } = input;
12
12
  try {
13
- const res = await (0, call_lambda_1.callLambda)({
14
- functionName,
15
- type: constants_1.LambdaRoutines.still,
16
- payload: await (0, make_lambda_payload_1.makeLambdaRenderStillPayload)(input),
17
- region,
18
- receivedStreamingPayload: (payload) => {
19
- if (payload.type === 'render-id-determined') {
20
- onInit({
21
- renderId: payload.renderId,
22
- cloudWatchLogs: (0, get_aws_urls_1.getCloudwatchMethodUrl)({
23
- functionName,
24
- method: constants_1.LambdaRoutines.still,
25
- region,
26
- rendererFunctionName: null,
27
- renderId: payload.renderId,
28
- }),
29
- lambdaInsightsUrl: (0, get_aws_urls_1.getLambdaInsightsUrl)({
30
- functionName,
31
- region,
32
- }),
33
- });
34
- }
35
- },
36
- timeoutInTest: 120000,
37
- retriesRemaining: 0,
13
+ const payload = await (0, make_lambda_payload_1.makeLambdaRenderStillPayload)(input);
14
+ const res = await new Promise((resolve, reject) => {
15
+ (0, call_lambda_1.callLambdaWithStreaming)({
16
+ functionName,
17
+ type: constants_1.LambdaRoutines.still,
18
+ payload,
19
+ region,
20
+ receivedStreamingPayload: ({ message }) => {
21
+ if (message.type === 'render-id-determined') {
22
+ onInit === null || onInit === void 0 ? void 0 : onInit({
23
+ renderId: message.payload.renderId,
24
+ cloudWatchLogs: (0, get_aws_urls_1.getCloudwatchMethodUrl)({
25
+ functionName,
26
+ method: constants_1.LambdaRoutines.still,
27
+ region,
28
+ rendererFunctionName: null,
29
+ renderId: message.payload.renderId,
30
+ }),
31
+ lambdaInsightsUrl: (0, get_aws_urls_1.getLambdaInsightsUrl)({
32
+ functionName,
33
+ region,
34
+ }),
35
+ });
36
+ }
37
+ if (message.type === 'still-rendered') {
38
+ resolve(message.payload);
39
+ }
40
+ },
41
+ timeoutInTest: 120000,
42
+ retriesRemaining: 0,
43
+ })
44
+ .then(() => {
45
+ reject(new Error('Expected response to be streamed'));
46
+ })
47
+ .catch((err) => {
48
+ reject(err);
49
+ });
38
50
  });
39
51
  return {
40
52
  estimatedPrice: res.estimatedPrice,
@@ -1,36 +1,11 @@
1
- import type { LogLevel } from '@remotion/renderer';
2
- import type { CleanupInfo, EncodingProgress, RenderProgress } from '../../../defaults';
3
- import type { ChunkRetry } from '../../../functions/helpers/get-retry-stats';
4
- type LambdaInvokeProgress = {
5
- totalLambdas: number | null;
6
- lambdasInvoked: number;
7
- };
8
- type ChunkProgress = {
9
- doneIn: number | null;
10
- framesRendered: number;
11
- totalFrames: number | null;
12
- totalChunks: number | null;
13
- chunksEncoded: number;
14
- };
15
- type MultiRenderProgress = {
16
- lambdaInvokeProgress: LambdaInvokeProgress;
17
- chunkProgress: ChunkProgress;
18
- encodingProgress: EncodingProgress;
19
- cleanupInfo: CleanupInfo | null;
20
- };
21
- export declare const makeMultiProgressFromStatus: (status: RenderProgress) => MultiRenderProgress;
1
+ import type { RenderProgress } from '../../../defaults';
22
2
  type DownloadedInfo = {
23
3
  totalSize: number | null;
24
4
  downloaded: number;
25
5
  doneIn: number | null;
26
6
  };
27
- export declare const makeProgressString: ({ progress, steps, downloadInfo, retriesInfo, logLevel, timeToEncode, totalFrames, }: {
28
- progress: MultiRenderProgress;
29
- steps: number;
7
+ export declare const makeProgressString: ({ downloadInfo, overall, }: {
8
+ overall: RenderProgress;
30
9
  downloadInfo: DownloadedInfo | null;
31
- retriesInfo: ChunkRetry[];
32
- logLevel: LogLevel;
33
- timeToEncode: number | null;
34
- totalFrames: number | null;
35
10
  }) => string;
36
11
  export {};
@@ -1,89 +1,96 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeProgressString = exports.makeMultiProgressFromStatus = void 0;
3
+ exports.makeProgressString = void 0;
4
4
  const cli_1 = require("@remotion/cli");
5
5
  const renderer_1 = require("@remotion/renderer");
6
6
  const no_react_1 = require("remotion/no-react");
7
7
  const truthy_1 = require("../../../shared/truthy");
8
- const makeInvokeProgress = (invokeProgress, retriesInfo) => {
8
+ const makeInvokeProgress = (overall) => {
9
+ var _a, _b;
10
+ const invokeProgress = {
11
+ lambdasInvoked: overall.lambdasInvoked,
12
+ totalLambdas: (_b = (_a = overall.renderMetadata) === null || _a === void 0 ? void 0 : _a.estimatedRenderLambdaInvokations) !== null && _b !== void 0 ? _b : null,
13
+ };
9
14
  const { lambdasInvoked, totalLambdas } = invokeProgress;
10
15
  const progress = totalLambdas === null ? 0 : lambdasInvoked / totalLambdas;
11
- return [
16
+ const topLine = [
12
17
  `${progress === 0 ? 'Invoked' : 'Invoking'} lambdas`.padEnd(cli_1.CliInternals.LABEL_WIDTH),
13
18
  cli_1.CliInternals.makeProgressBar(progress),
14
19
  progress === 1
15
- ? cli_1.CliInternals.chalk.gray('100%')
16
- : `${Math.round(progress * 100)}%`,
17
- retriesInfo.length > 0 ? `(+${retriesInfo.length} retries)` : [],
20
+ ? cli_1.CliInternals.chalk.gray(`${lambdasInvoked}/${totalLambdas}`)
21
+ : totalLambdas === null
22
+ ? null
23
+ : `${lambdasInvoked}/${totalLambdas}`,
18
24
  ].join(' ');
25
+ return [
26
+ topLine,
27
+ overall.retriesInfo.length > 0
28
+ ? `! Retrying chunk${overall.retriesInfo.length === 1 ? '' : 's'} ${overall.retriesInfo.map((r) => r.chunk).join(', ')}`
29
+ : null,
30
+ ].filter(no_react_1.NoReactInternals.truthy);
19
31
  };
20
- const makeRenderProgress = ({ chunkProgress, }) => {
21
- const { chunksEncoded, totalChunks, doneIn } = chunkProgress;
22
- const renderProgress = chunkProgress.totalFrames === null
23
- ? 0
24
- : chunkProgress.framesRendered / chunkProgress.totalFrames;
25
- const encodingProgress = totalChunks === null ? 0 : chunksEncoded / totalChunks;
26
- const frames = chunkProgress.totalFrames === null
27
- ? null
28
- : `${chunkProgress.framesRendered}/${chunkProgress.totalFrames}`;
32
+ const makeRenderProgress = (progress) => {
33
+ var _a, _b;
34
+ const framesEncoded = (_b = (_a = progress.encodingStatus) === null || _a === void 0 ? void 0 : _a.framesEncoded) !== null && _b !== void 0 ? _b : 0;
35
+ const totalFrames = progress.renderMetadata && progress.renderMetadata.type === 'video'
36
+ ? renderer_1.RenderInternals.getFramesToRender(progress.renderMetadata.frameRange, progress.renderMetadata.everyNthFrame).length
37
+ : null;
38
+ const renderProgress = totalFrames === null ? 0 : progress.framesRendered / totalFrames;
39
+ const encodingProgress = totalFrames === null ? 0 : framesEncoded / totalFrames;
40
+ const frames = totalFrames === null ? null : `${progress.framesRendered}/${totalFrames}`;
29
41
  const first = [
30
- (doneIn === null ? 'Rendering frames' : 'Rendered frames').padEnd(cli_1.CliInternals.LABEL_WIDTH, ' '),
42
+ (progress.timeToRenderFrames === null
43
+ ? 'Rendering frames'
44
+ : 'Rendered frames').padEnd(cli_1.CliInternals.LABEL_WIDTH, ' '),
31
45
  cli_1.CliInternals.makeProgressBar(renderProgress),
32
- doneIn === null ? frames : cli_1.CliInternals.chalk.gray(`${doneIn}ms`),
46
+ progress.timeToRenderFrames === null
47
+ ? frames
48
+ : cli_1.CliInternals.chalk.gray(`${progress.timeToRenderFrames}ms`),
33
49
  ]
34
50
  .filter(truthy_1.truthy)
35
51
  .join(' ');
36
52
  const second = [
37
- `${doneIn === null ? 'Encoding' : 'Encoded'} chunks`.padEnd(cli_1.CliInternals.LABEL_WIDTH, ' '),
53
+ `${progress.timeToEncode === null ? 'Encoding' : 'Encoded'} frames`.padEnd(cli_1.CliInternals.LABEL_WIDTH, ' '),
38
54
  cli_1.CliInternals.makeProgressBar(encodingProgress),
39
- doneIn === null
40
- ? `${Math.round(encodingProgress * 100)}%`
41
- : cli_1.CliInternals.chalk.gray(`${doneIn}ms`),
42
- ].join(' ');
55
+ progress.timeToEncode === null
56
+ ? totalFrames === null
57
+ ? null
58
+ : `${framesEncoded}/${totalFrames}`
59
+ : cli_1.CliInternals.chalk.gray(`${progress.timeToEncode}ms`),
60
+ ]
61
+ .filter(truthy_1.truthy)
62
+ .join(' ');
43
63
  return [first, second];
44
64
  };
45
- const makeEncodingProgress = ({ encodingProgress, chunkProgress, totalFrames, timeToEncode, }) => {
46
- const { framesEncoded } = encodingProgress;
47
- const progress = totalFrames === null ? 0 : framesEncoded / totalFrames;
48
- const chunksDone = chunkProgress.doneIn !== null;
49
- const shouldShow = progress > 0 || chunksDone;
50
- if (!shouldShow) {
51
- return '';
52
- }
53
- return [
54
- `${timeToEncode === null ? 'Combining' : 'Combined'} videos`.padEnd(cli_1.CliInternals.LABEL_WIDTH, ' '),
55
- cli_1.CliInternals.makeProgressBar(progress),
56
- timeToEncode === null
57
- ? `${Math.round(progress * 100)}%`
58
- : cli_1.CliInternals.chalk.gray(`${timeToEncode}ms`),
59
- ].join(' ');
60
- };
61
- const makeCleanupProgress = (cleanupInfo, skipped) => {
62
- if (!cleanupInfo) {
63
- return '';
64
- }
65
- if (skipped) {
66
- return [
67
- cli_1.CliInternals.chalk.blueBright(`Not cleaning up because --log=verbose was set`),
68
- ].join(' ');
69
- }
70
- const { doneIn, filesDeleted, minFilesToDelete } = cleanupInfo;
71
- const progress = filesDeleted / minFilesToDelete;
65
+ function getTotalFrames(status) {
66
+ return status.renderMetadata && status.renderMetadata.type === 'video'
67
+ ? renderer_1.RenderInternals.getFramesToRender(status.renderMetadata.frameRange, status.renderMetadata.everyNthFrame).length
68
+ : null;
69
+ }
70
+ const makeCombinationProgress = (prog) => {
71
+ var _a, _b;
72
+ const encodingProgress = {
73
+ framesEncoded: (_b = (_a = prog.encodingStatus) === null || _a === void 0 ? void 0 : _a.framesEncoded) !== null && _b !== void 0 ? _b : 0,
74
+ combinedFrames: prog.combinedFrames,
75
+ timeToCombine: prog.timeToCombine,
76
+ };
77
+ const totalFrames = getTotalFrames(prog);
78
+ const { combinedFrames, timeToCombine } = encodingProgress;
79
+ const progress = totalFrames === null ? 0 : combinedFrames / totalFrames;
72
80
  return [
81
+ `${timeToCombine === null ? 'Combining' : 'Combined'} chunks`.padEnd(cli_1.CliInternals.LABEL_WIDTH, ' '),
73
82
  cli_1.CliInternals.makeProgressBar(progress),
74
- `${doneIn === null ? 'Cleaning up' : 'Cleaned up'} artifacts`,
75
- doneIn === null
83
+ timeToCombine === null
76
84
  ? `${Math.round(progress * 100)}%`
77
- : cli_1.CliInternals.chalk.gray(`${doneIn}ms`),
85
+ : cli_1.CliInternals.chalk.gray(`${timeToCombine}ms`),
78
86
  ].join(' ');
79
87
  };
80
- const makeDownloadProgress = (downloadInfo, totalSteps) => {
88
+ const makeDownloadProgress = (downloadInfo) => {
81
89
  return [
82
- `(6/${totalSteps})`,
90
+ `${downloadInfo.doneIn === null ? 'Downloading' : 'Downloaded'} video`.padEnd(cli_1.CliInternals.LABEL_WIDTH, ' '),
83
91
  downloadInfo.totalSize === null
84
92
  ? cli_1.CliInternals.getFileSizeDownloadBar(downloadInfo.downloaded)
85
93
  : cli_1.CliInternals.makeProgressBar(downloadInfo.downloaded / downloadInfo.totalSize),
86
- `${downloadInfo.doneIn === null ? 'Downloading' : 'Downloaded'} video`,
87
94
  downloadInfo.doneIn === null
88
95
  ? [
89
96
  `${cli_1.CliInternals.formatBytes(downloadInfo.downloaded)}`,
@@ -96,43 +103,35 @@ const makeDownloadProgress = (downloadInfo, totalSteps) => {
96
103
  : cli_1.CliInternals.chalk.gray(`${downloadInfo.doneIn}ms`),
97
104
  ].join(' ');
98
105
  };
99
- const makeMultiProgressFromStatus = (status) => {
100
- var _a, _b, _c, _d, _e, _f;
101
- return {
102
- chunkProgress: {
103
- chunksEncoded: status.chunks,
104
- totalChunks: (_b = (_a = status.renderMetadata) === null || _a === void 0 ? void 0 : _a.totalChunks) !== null && _b !== void 0 ? _b : null,
105
- doneIn: status.timeToFinishChunks,
106
- framesRendered: status.framesRendered,
107
- totalFrames: status.renderMetadata && status.renderMetadata.type === 'video'
108
- ? renderer_1.RenderInternals.getFramesToRender(status.renderMetadata.frameRange, status.renderMetadata.everyNthFrame).length
109
- : null,
110
- },
111
- encodingProgress: {
112
- framesEncoded: (_d = (_c = status.encodingStatus) === null || _c === void 0 ? void 0 : _c.framesEncoded) !== null && _d !== void 0 ? _d : 0,
113
- },
114
- lambdaInvokeProgress: {
115
- lambdasInvoked: status.lambdasInvoked,
116
- totalLambdas: (_f = (_e = status.renderMetadata) === null || _e === void 0 ? void 0 : _e.estimatedRenderLambdaInvokations) !== null && _f !== void 0 ? _f : null,
117
- },
118
- cleanupInfo: status.cleanup,
119
- };
106
+ const makeTopRow = (overall) => {
107
+ const timeoutInSeconds = Math.round((overall.timeoutTimestamp - Date.now()) / 1000);
108
+ if (!overall.renderMetadata) {
109
+ return null;
110
+ }
111
+ if (overall.done) {
112
+ return null;
113
+ }
114
+ const str = [
115
+ `${Math.round(overall.overallProgress * 100)}%`,
116
+ overall.renderMetadata
117
+ ? `${overall.renderMetadata.estimatedTotalLambdaInvokations} λ`
118
+ : null,
119
+ `${overall.costs.displayCost}`,
120
+ timeoutInSeconds < 0
121
+ ? 'Timeout reached - Expecting crash shortly'
122
+ : `Timeout ${timeoutInSeconds}s`,
123
+ ]
124
+ .filter(no_react_1.NoReactInternals.truthy)
125
+ .join(' • ');
126
+ return cli_1.CliInternals.chalk.gray(str);
120
127
  };
121
- exports.makeMultiProgressFromStatus = makeMultiProgressFromStatus;
122
- const makeProgressString = ({ progress, steps, downloadInfo, retriesInfo, logLevel, timeToEncode, totalFrames, }) => {
128
+ const makeProgressString = ({ downloadInfo, overall, }) => {
123
129
  return [
124
- makeInvokeProgress(progress.lambdaInvokeProgress, retriesInfo),
125
- ...makeRenderProgress({
126
- chunkProgress: progress.chunkProgress,
127
- }),
128
- makeEncodingProgress({
129
- encodingProgress: progress.encodingProgress,
130
- chunkProgress: progress.chunkProgress,
131
- timeToEncode,
132
- totalFrames,
133
- }),
134
- makeCleanupProgress(progress.cleanupInfo, logLevel === 'verbose'),
135
- downloadInfo ? makeDownloadProgress(downloadInfo, steps) : null,
130
+ makeTopRow(overall),
131
+ ...makeInvokeProgress(overall),
132
+ ...makeRenderProgress(overall),
133
+ makeCombinationProgress(overall),
134
+ downloadInfo ? makeDownloadProgress(downloadInfo) : null,
136
135
  ]
137
136
  .filter(no_react_1.NoReactInternals.truthy)
138
137
  .join('\n');
@@ -23,11 +23,6 @@ const quit_1 = require("../../helpers/quit");
23
23
  const log_1 = require("../../log");
24
24
  const progress_1 = require("./progress");
25
25
  exports.RENDER_COMMAND = 'render';
26
- function getTotalFrames(status) {
27
- return status.renderMetadata && status.renderMetadata.type === 'video'
28
- ? renderer_1.RenderInternals.getFramesToRender(status.renderMetadata.frameRange, status.renderMetadata.everyNthFrame).length
29
- : null;
30
- }
31
26
  const { x264Option, audioBitrateOption, offthreadVideoCacheSizeInBytesOption, scaleOption, crfOption, jpegQualityOption, videoBitrateOption, mutedOption, colorSpaceOption, deleteAfterOption, enableMultiprocessOnLinuxOption, glOption, headlessOption, numberOfGifLoopsOption, encodingMaxRateOption, encodingBufferSizeOption, delayRenderTimeoutInMillisecondsOption, overwriteOption, binariesDirectoryOption, preferLosslessOption, } = client_1.BrowserSafeApis.options;
32
27
  const renderCommand = async (args, remotionRoot, logLevel) => {
33
28
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
@@ -236,7 +231,6 @@ const renderCommand = async (args, remotionRoot, logLevel) => {
236
231
  preferLossless,
237
232
  indent: false,
238
233
  });
239
- const totalSteps = downloadName ? 6 : 5;
240
234
  const progressBar = cli_1.CliInternals.createOverwriteableCliOutput({
241
235
  quiet: cli_1.CliInternals.quietFlagProvided(),
242
236
  cancelSignal: null,
@@ -256,19 +250,13 @@ const renderCommand = async (args, remotionRoot, logLevel) => {
256
250
  region: (0, get_aws_region_1.getAwsRegion)(),
257
251
  logLevel,
258
252
  });
259
- const multiProgress = (0, progress_1.makeMultiProgressFromStatus)(status);
260
253
  progressBar.update((0, progress_1.makeProgressString)({
261
- progress: multiProgress,
262
- steps: totalSteps,
263
254
  downloadInfo: null,
264
- retriesInfo: status.retriesInfo,
265
- logLevel,
266
- totalFrames: getTotalFrames(status),
267
- timeToEncode: status.timeToEncode,
255
+ overall: status,
268
256
  }), false);
269
257
  // eslint-disable-next-line no-constant-condition
270
258
  while (true) {
271
- await (0, sleep_1.sleep)(1000);
259
+ await (0, sleep_1.sleep)(500);
272
260
  const newStatus = await (0, get_render_progress_1.getRenderProgress)({
273
261
  functionName,
274
262
  bucketName: res.bucketName,
@@ -276,25 +264,14 @@ const renderCommand = async (args, remotionRoot, logLevel) => {
276
264
  region: (0, get_aws_region_1.getAwsRegion)(),
277
265
  logLevel,
278
266
  });
279
- const newProgress = (0, progress_1.makeMultiProgressFromStatus)(newStatus);
280
267
  progressBar.update((0, progress_1.makeProgressString)({
281
- progress: newProgress,
282
- steps: totalSteps,
283
- retriesInfo: newStatus.retriesInfo,
284
268
  downloadInfo: null,
285
- logLevel,
286
- timeToEncode: newStatus.timeToEncode,
287
- totalFrames: getTotalFrames(newStatus),
269
+ overall: newStatus,
288
270
  }), false);
289
271
  if (newStatus.done) {
290
272
  progressBar.update((0, progress_1.makeProgressString)({
291
- progress: newProgress,
292
- steps: totalSteps,
293
273
  downloadInfo: null,
294
- retriesInfo: newStatus.retriesInfo,
295
- logLevel,
296
- timeToEncode: newStatus.timeToEncode,
297
- totalFrames: getTotalFrames(newStatus),
274
+ overall: newStatus,
298
275
  }), false);
299
276
  if (downloadName) {
300
277
  const downloadStart = Date.now();
@@ -306,32 +283,22 @@ const renderCommand = async (args, remotionRoot, logLevel) => {
306
283
  logLevel,
307
284
  onProgress: ({ downloaded, totalSize }) => {
308
285
  progressBar.update((0, progress_1.makeProgressString)({
309
- progress: newProgress,
310
- steps: totalSteps,
311
- retriesInfo: newStatus.retriesInfo,
312
286
  downloadInfo: {
313
287
  doneIn: null,
314
288
  downloaded,
315
289
  totalSize,
316
290
  },
317
- logLevel,
318
- timeToEncode: newStatus.timeToEncode,
319
- totalFrames: getTotalFrames(newStatus),
291
+ overall: newStatus,
320
292
  }), false);
321
293
  },
322
294
  });
323
295
  progressBar.update((0, progress_1.makeProgressString)({
324
- progress: newProgress,
325
- steps: totalSteps,
326
- retriesInfo: newStatus.retriesInfo,
327
296
  downloadInfo: {
328
297
  doneIn: Date.now() - downloadStart,
329
298
  downloaded: sizeInBytes,
330
299
  totalSize: sizeInBytes,
331
300
  },
332
- logLevel,
333
- timeToEncode: newStatus.timeToEncode,
334
- totalFrames: getTotalFrames(newStatus),
301
+ overall: newStatus,
335
302
  }), false);
336
303
  log_1.Log.info({ indent: false, logLevel });
337
304
  log_1.Log.info({ indent: false, logLevel });
@@ -349,7 +316,7 @@ const renderCommand = async (args, remotionRoot, logLevel) => {
349
316
  newStatus.timeToFinish
350
317
  ? `${(newStatus.timeToFinish / 1000).toFixed(2)}sec`
351
318
  : null,
352
- `Estimated cost $${newStatus.costs.displayCost}`,
319
+ `Estimated cost ${newStatus.costs.displayCost}`,
353
320
  ]
354
321
  .filter(Boolean)
355
322
  .join(', '));
@@ -141,14 +141,14 @@ const sitesCreateSubcommand = async (args, remotionRoot, logLevel) => {
141
141
  left: 'Serve URL',
142
142
  logLevel,
143
143
  right: serveUrl,
144
- color: 'blue',
144
+ color: 'blueBright',
145
145
  });
146
146
  cli_1.CliInternals.printFact('info')({
147
147
  indent: false,
148
148
  left: 'Site name',
149
149
  logLevel,
150
150
  right: siteName,
151
- color: 'blue',
151
+ color: 'blueBright',
152
152
  });
153
153
  log_1.Log.info({ indent: false, logLevel });
154
154
  log_1.Log.info({ indent: false, logLevel }, cli_1.CliInternals.chalk.blueBright('ℹ️ Redeploy your site everytime you make changes to it. You can overwrite the existing site by running:'));
@@ -6,6 +6,3 @@ export type ObjectChunkTimingData = {
6
6
  [key: number]: number;
7
7
  };
8
8
  };
9
- export type ChunkTimingData = Omit<ObjectChunkTimingData, 'timings'> & {
10
- timings: number[];
11
- };
@@ -1,6 +1,5 @@
1
- import type { _Object } from '@aws-sdk/client-s3';
2
- export declare const calculateChunkTimes: ({ contents, renderId, type, }: {
3
- contents: _Object[];
4
- renderId: string;
1
+ import type { ParsedTiming } from '../../shared/parse-lambda-timings-key';
2
+ export declare const calculateChunkTimes: ({ type, timings, }: {
5
3
  type: 'combined-time-for-cost-calculation' | 'absolute-time';
4
+ timings: ParsedTiming[];
6
5
  }) => number;