@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.
- package/dist/api/delete-render.js +7 -3
- package/dist/api/deploy-function.d.ts +0 -1
- package/dist/api/deploy-function.js +3 -3
- package/dist/api/download-media.js +6 -3
- package/dist/api/get-compositions-on-lambda.js +0 -2
- package/dist/api/get-render-progress.js +0 -2
- package/dist/api/make-lambda-payload.js +2 -1
- package/dist/api/render-media-on-lambda.js +0 -2
- package/dist/api/render-still-on-lambda.js +37 -25
- package/dist/cli/commands/render/progress.d.ts +3 -28
- package/dist/cli/commands/render/progress.js +89 -90
- package/dist/cli/commands/render/render.js +7 -40
- package/dist/cli/commands/sites/create.js +2 -2
- package/dist/functions/chunk-optimization/types.d.ts +0 -3
- package/dist/functions/helpers/calculate-chunk-times.d.ts +3 -4
- package/dist/functions/helpers/calculate-chunk-times.js +4 -8
- package/dist/functions/helpers/calculate-price-from-bucket.d.ts +3 -5
- package/dist/functions/helpers/calculate-price-from-bucket.js +5 -18
- package/dist/functions/helpers/clean-tmpdir.d.ts +0 -2
- package/dist/functions/helpers/clean-tmpdir.js +1 -7
- package/dist/functions/helpers/concat-videos.d.ts +1 -13
- package/dist/functions/helpers/concat-videos.js +7 -131
- package/dist/functions/helpers/create-post-render-data.d.ts +6 -6
- package/dist/functions/helpers/create-post-render-data.js +17 -37
- package/dist/functions/helpers/find-output-file-in-bucket.d.ts +1 -3
- package/dist/functions/helpers/find-output-file-in-bucket.js +1 -4
- package/dist/functions/helpers/get-encoding-progress-step-size.d.ts +1 -1
- package/dist/functions/helpers/get-encoding-progress-step-size.js +0 -3
- package/dist/functions/helpers/get-lambdas-invoked-stats.d.ts +1 -6
- package/dist/functions/helpers/get-lambdas-invoked-stats.js +0 -13
- package/dist/functions/helpers/get-overall-progress-s3.d.ts +4 -2
- package/dist/functions/helpers/get-overall-progress-s3.js +8 -6
- package/dist/functions/helpers/get-overall-progress.d.ts +1 -2
- package/dist/functions/helpers/get-overall-progress.js +2 -4
- package/dist/functions/helpers/get-progress.js +78 -154
- package/dist/functions/helpers/get-retry-stats.d.ts +0 -5
- package/dist/functions/helpers/get-retry-stats.js +0 -18
- package/dist/functions/helpers/inspect-errors.d.ts +4 -10
- package/dist/functions/helpers/inspect-errors.js +5 -27
- package/dist/functions/helpers/io.d.ts +0 -1
- package/dist/functions/helpers/io.js +2 -3
- package/dist/functions/helpers/lifecycle.d.ts +0 -4
- package/dist/functions/helpers/lifecycle.js +2 -3
- package/dist/functions/helpers/make-timeout-error.d.ts +0 -2
- package/dist/functions/helpers/merge-chunks.d.ts +5 -0
- package/dist/functions/helpers/merge-chunks.js +16 -143
- package/dist/functions/helpers/min-max.d.ts +1 -1
- package/dist/functions/helpers/min-max.js +1 -1
- package/dist/functions/helpers/overall-render-progress.d.ts +26 -4
- package/dist/functions/helpers/overall-render-progress.js +116 -27
- package/dist/functions/helpers/stream-renderer.js +15 -9
- package/dist/functions/helpers/streamify-response.d.ts +0 -3
- package/dist/functions/helpers/streamify-response.js +2 -14
- package/dist/functions/helpers/write-lambda-error.d.ts +3 -6
- package/dist/functions/helpers/write-lambda-error.js +1 -21
- package/dist/functions/index.d.ts +5 -0
- package/dist/functions/index.js +70 -38
- package/dist/functions/launch.js +103 -133
- package/dist/functions/renderer.d.ts +2 -2
- package/dist/functions/renderer.js +70 -123
- package/dist/functions/start.d.ts +1 -0
- package/dist/functions/start.js +3 -2
- package/dist/functions/still.d.ts +7 -2
- package/dist/functions/still.js +17 -34
- package/dist/functions/streaming/streaming.d.ts +15 -2
- package/dist/functions/streaming/streaming.js +8 -6
- package/dist/internals.d.ts +2 -1
- package/dist/shared/aws-clients.js +8 -0
- package/dist/shared/call-lambda.d.ts +5 -4
- package/dist/shared/call-lambda.js +53 -44
- package/dist/shared/constants.d.ts +14 -35
- package/dist/shared/constants.js +3 -31
- package/dist/shared/content-disposition-header.d.ts +0 -3
- package/dist/shared/get-function-version.js +0 -2
- package/dist/shared/is-flaky-error.js +4 -0
- package/dist/shared/parse-lambda-timings-key.d.ts +0 -2
- package/dist/shared/parse-lambda-timings-key.js +0 -14
- package/dist/shared/return-values.d.ts +0 -5
- package/package.json +18 -18
- package/remotionlambda-arm64.zip +0 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculateChunkTimes = void 0;
|
|
4
|
-
const constants_1 = require("../../shared/constants");
|
|
5
|
-
const parse_lambda_timings_key_1 = require("../../shared/parse-lambda-timings-key");
|
|
6
4
|
const min_max_1 = require("./min-max");
|
|
7
5
|
const getAbsoluteTime = (parsedTimings) => {
|
|
8
6
|
if (parsedTimings.length === 0) {
|
|
@@ -12,16 +10,14 @@ const getAbsoluteTime = (parsedTimings) => {
|
|
|
12
10
|
const allStarts = parsedTimings.map((p) => p.start);
|
|
13
11
|
const biggestEnd = (0, min_max_1.max)(allEnds);
|
|
14
12
|
const smallestStart = (0, min_max_1.min)(allStarts);
|
|
15
|
-
return biggestEnd - smallestStart;
|
|
13
|
+
return Math.max(0, biggestEnd - smallestStart);
|
|
16
14
|
};
|
|
17
|
-
const calculateChunkTimes = ({
|
|
18
|
-
const parsedTimings =
|
|
19
|
-
.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaTimingsPrefix)(renderId)); })
|
|
20
|
-
.map((f) => (0, parse_lambda_timings_key_1.parseLambdaTimingsKey)(f.Key));
|
|
15
|
+
const calculateChunkTimes = ({ type, timings, }) => {
|
|
16
|
+
const parsedTimings = timings;
|
|
21
17
|
const absoluteTime = getAbsoluteTime(parsedTimings);
|
|
22
18
|
if (type === 'combined-time-for-cost-calculation') {
|
|
23
19
|
const totalEncodingTimings = parsedTimings
|
|
24
|
-
.map((p) => p.rendered - p.start)
|
|
20
|
+
.map((p) => Math.max(0, p.rendered - p.start))
|
|
25
21
|
.reduce((a, b) => a + b, 0);
|
|
26
22
|
return totalEncodingTimings + absoluteTime;
|
|
27
23
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type { _Object } from '@aws-sdk/client-s3';
|
|
2
1
|
import type { RenderMetadata } from '../../shared/constants';
|
|
3
|
-
import type {
|
|
4
|
-
export declare const estimatePriceFromBucket: ({
|
|
5
|
-
contents: _Object[];
|
|
2
|
+
import type { ParsedTiming } from '../../shared/parse-lambda-timings-key';
|
|
3
|
+
export declare const estimatePriceFromBucket: ({ renderMetadata, memorySizeInMb, diskSizeInMb, lambdasInvoked, timings, }: {
|
|
6
4
|
renderMetadata: RenderMetadata | null;
|
|
7
5
|
memorySizeInMb: number;
|
|
8
|
-
outputFileMetadata: OutputFileMetadata | null;
|
|
9
6
|
diskSizeInMb: number;
|
|
10
7
|
lambdasInvoked: number;
|
|
8
|
+
timings: ParsedTiming[];
|
|
11
9
|
}) => {
|
|
12
10
|
accruedSoFar: number;
|
|
13
11
|
estimatedBillingDurationInMilliseconds: number;
|
|
@@ -2,35 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.estimatePriceFromBucket = void 0;
|
|
4
4
|
const estimate_price_1 = require("../../api/estimate-price");
|
|
5
|
-
const constants_1 = require("../../shared/constants");
|
|
6
|
-
const parse_lambda_timings_key_1 = require("../../shared/parse-lambda-timings-key");
|
|
7
5
|
const calculate_chunk_times_1 = require("./calculate-chunk-times");
|
|
8
6
|
const get_current_region_1 = require("./get-current-region");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
var _a, _b, _c;
|
|
7
|
+
const estimatePriceFromBucket = ({ renderMetadata, memorySizeInMb, diskSizeInMb, lambdasInvoked, timings, }) => {
|
|
8
|
+
var _a, _b;
|
|
12
9
|
if (!renderMetadata) {
|
|
13
10
|
return null;
|
|
14
11
|
}
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
.map((f) => (0, parse_lambda_timings_key_1.parseLambdaTimingsKey)(f.Key));
|
|
18
|
-
const timeToFinish = (0, get_time_to_finish_1.getTimeToFinish)({
|
|
19
|
-
lastModified: (_a = outputFileMetadata === null || outputFileMetadata === void 0 ? void 0 : outputFileMetadata.lastModified) !== null && _a !== void 0 ? _a : null,
|
|
20
|
-
renderMetadata,
|
|
21
|
-
});
|
|
22
|
-
const elapsedTime = timeToFinish === null
|
|
23
|
-
? Math.max(0, Date.now() - ((_b = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.startedDate) !== null && _b !== void 0 ? _b : 0))
|
|
24
|
-
: timeToFinish;
|
|
25
|
-
const unfinished = Math.max(0, ((_c = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _c !== void 0 ? _c : 0) - parsedTimings.length);
|
|
12
|
+
const elapsedTime = Math.max(0, Date.now() - ((_a = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.startedDate) !== null && _a !== void 0 ? _a : 0));
|
|
13
|
+
const unfinished = Math.max(0, ((_b = renderMetadata === null || renderMetadata === void 0 ? void 0 : renderMetadata.totalChunks) !== null && _b !== void 0 ? _b : 0) - timings.length);
|
|
26
14
|
const timeElapsedOfUnfinished = new Array(unfinished)
|
|
27
15
|
.fill(true)
|
|
28
16
|
.map(() => elapsedTime)
|
|
29
17
|
.reduce((a, b) => a + b, 0);
|
|
30
18
|
const estimatedBillingDurationInMilliseconds = (0, calculate_chunk_times_1.calculateChunkTimes)({
|
|
31
|
-
contents,
|
|
32
|
-
renderId: renderMetadata.renderId,
|
|
33
19
|
type: 'combined-time-for-cost-calculation',
|
|
20
|
+
timings,
|
|
34
21
|
}) + timeElapsedOfUnfinished;
|
|
35
22
|
const accruedSoFar = Number((0, estimate_price_1.estimatePrice)({
|
|
36
23
|
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
@@ -3,11 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.deleteTmpDir =
|
|
6
|
+
exports.deleteTmpDir = void 0;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const node_path_1 = require("node:path");
|
|
9
|
-
exports.deletedFiles = [];
|
|
10
|
-
exports.deletedFilesSize = 0;
|
|
11
9
|
const deleteAllFilesInAFolderRecursively = (path) => {
|
|
12
10
|
const files = node_fs_1.default.readdirSync(path);
|
|
13
11
|
files.forEach((file) => {
|
|
@@ -19,22 +17,18 @@ const deleteAllFilesInAFolderRecursively = (path) => {
|
|
|
19
17
|
}
|
|
20
18
|
else {
|
|
21
19
|
node_fs_1.default.unlinkSync(filePath);
|
|
22
|
-
exports.deletedFilesSize += stat.size;
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
22
|
catch (err) {
|
|
26
23
|
// Can fail if file was already deleted by cleanup. In that case
|
|
27
24
|
// let's ignore it
|
|
28
25
|
}
|
|
29
|
-
exports.deletedFiles.push(filePath);
|
|
30
26
|
});
|
|
31
27
|
if (path !== '/tmp') {
|
|
32
28
|
node_fs_1.default.rmSync(path, { recursive: true, force: true });
|
|
33
29
|
}
|
|
34
30
|
};
|
|
35
31
|
const deleteTmpDir = () => {
|
|
36
|
-
exports.deletedFiles = [];
|
|
37
|
-
exports.deletedFilesSize = 0;
|
|
38
32
|
if (!process.env.VITEST) {
|
|
39
33
|
deleteAllFilesInAFolderRecursively('/tmp');
|
|
40
34
|
}
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import type { AudioCodec, CancelSignal, LogLevel } from '@remotion/renderer';
|
|
2
|
-
import type { AwsRegion } from '../../pricing/aws-regions';
|
|
3
2
|
import type { LambdaCodec } from '../../shared/validate-lambda-codec';
|
|
4
|
-
|
|
5
|
-
export declare const getAllFilesS3: ({ bucket, expectedFiles, outdir, renderId, region, expectedBucketOwner, onErrors, logLevel, }: {
|
|
6
|
-
bucket: string;
|
|
7
|
-
expectedFiles: number;
|
|
8
|
-
outdir: string;
|
|
9
|
-
renderId: string;
|
|
10
|
-
region: AwsRegion;
|
|
11
|
-
expectedBucketOwner: string;
|
|
12
|
-
onErrors: (errors: EnhancedErrorInfo[]) => void;
|
|
13
|
-
logLevel: LogLevel;
|
|
14
|
-
}) => Promise<string[]>;
|
|
15
|
-
export declare const concatVideosS3: ({ onProgress, numberOfFrames, codec, fps, numberOfGifLoops, files, outdir, audioCodec, audioBitrate, logLevel, framesPerLambda, binariesDirectory, cancelSignal, preferLossless, muted, }: {
|
|
3
|
+
export declare const concatVideos: ({ onProgress, numberOfFrames, codec, fps, numberOfGifLoops, files, outdir, audioCodec, audioBitrate, logLevel, framesPerLambda, binariesDirectory, cancelSignal, preferLossless, muted, }: {
|
|
16
4
|
onProgress: (frames: number) => void;
|
|
17
5
|
numberOfFrames: number;
|
|
18
6
|
codec: LambdaCodec;
|
|
@@ -1,140 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
6
|
+
exports.concatVideos = void 0;
|
|
27
7
|
const renderer_1 = require("@remotion/renderer");
|
|
28
|
-
const node_fs_1 =
|
|
29
|
-
const node_path_1 =
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
30
10
|
const constants_1 = require("../../shared/constants");
|
|
31
11
|
const can_concat_seamlessly_1 = require("./can-concat-seamlessly");
|
|
32
|
-
const inspect_errors_1 = require("./inspect-errors");
|
|
33
|
-
const io_1 = require("./io");
|
|
34
12
|
const timer_1 = require("./timer");
|
|
35
|
-
const
|
|
36
|
-
return node_path_1.default.join(outdir, node_path_1.default.basename(file));
|
|
37
|
-
};
|
|
38
|
-
const downloadS3File = async ({ bucket, key, outdir, region, expectedBucketOwner, }) => {
|
|
39
|
-
const Body = await (0, io_1.lambdaReadFile)({
|
|
40
|
-
bucketName: bucket,
|
|
41
|
-
key,
|
|
42
|
-
region,
|
|
43
|
-
expectedBucketOwner,
|
|
44
|
-
});
|
|
45
|
-
const outpath = getChunkDownloadOutputLocation({ outdir, file: key });
|
|
46
|
-
if (Buffer.isBuffer(Body)) {
|
|
47
|
-
return node_fs_1.promises.writeFile(outpath, Body);
|
|
48
|
-
}
|
|
49
|
-
return new Promise((resolve, reject) => {
|
|
50
|
-
Body.pipe((0, node_fs_1.createWriteStream)(outpath))
|
|
51
|
-
.on('error', (err) => reject(err))
|
|
52
|
-
.on('close', () => resolve());
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
const getAllFilesS3 = ({ bucket, expectedFiles, outdir, renderId, region, expectedBucketOwner, onErrors, logLevel, }) => {
|
|
56
|
-
const alreadyDownloading = {};
|
|
57
|
-
const downloaded = {};
|
|
58
|
-
const getFiles = async () => {
|
|
59
|
-
const prefix = (0, constants_1.rendersPrefix)(renderId);
|
|
60
|
-
const lsTimer = (0, timer_1.timer)('Listing files', logLevel);
|
|
61
|
-
const contents = await (0, io_1.lambdaLs)({
|
|
62
|
-
bucketName: bucket,
|
|
63
|
-
prefix,
|
|
64
|
-
region,
|
|
65
|
-
expectedBucketOwner,
|
|
66
|
-
});
|
|
67
|
-
lsTimer.end();
|
|
68
|
-
return {
|
|
69
|
-
filesInBucket: contents
|
|
70
|
-
.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.chunkKey)(renderId)); })
|
|
71
|
-
.map((_) => _.Key),
|
|
72
|
-
errorContents: contents.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.getErrorKeyPrefix)(renderId)); }),
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
return new Promise((resolve, reject) => {
|
|
76
|
-
const loop = async () => {
|
|
77
|
-
const { filesInBucket, errorContents } = await getFiles();
|
|
78
|
-
const checkFinish = () => {
|
|
79
|
-
const areAllFilesDownloaded = Object.keys(downloaded).length === expectedFiles;
|
|
80
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, 'Checking for finish... ', Object.keys(downloaded), expectedFiles + ' files expected');
|
|
81
|
-
if (areAllFilesDownloaded) {
|
|
82
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, 'All files are downloaded!');
|
|
83
|
-
resolve(
|
|
84
|
-
// Need to use downloaded variable, not filesInBucket
|
|
85
|
-
// as it may be out of date
|
|
86
|
-
Object.keys(downloaded)
|
|
87
|
-
.sort()
|
|
88
|
-
.map((file) => getChunkDownloadOutputLocation({ outdir, file })));
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `Found ${filesInBucket.length} out of ${expectedFiles}`);
|
|
92
|
-
const errors = (await (0, inspect_errors_1.inspectErrors)({
|
|
93
|
-
bucket,
|
|
94
|
-
contents: errorContents,
|
|
95
|
-
expectedBucketOwner,
|
|
96
|
-
region,
|
|
97
|
-
renderId,
|
|
98
|
-
})).filter((e) => e.isFatal);
|
|
99
|
-
if (errors.length > 0) {
|
|
100
|
-
onErrors(errors);
|
|
101
|
-
// Will die here
|
|
102
|
-
}
|
|
103
|
-
filesInBucket.forEach(async (key) => {
|
|
104
|
-
if (alreadyDownloading[key]) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
alreadyDownloading[key] = true;
|
|
108
|
-
try {
|
|
109
|
-
const downloadTimer = (0, timer_1.timer)('Downloading ' + key, logLevel);
|
|
110
|
-
await downloadS3File({
|
|
111
|
-
bucket,
|
|
112
|
-
key,
|
|
113
|
-
outdir,
|
|
114
|
-
region,
|
|
115
|
-
expectedBucketOwner,
|
|
116
|
-
});
|
|
117
|
-
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, 'Successfully downloaded', key);
|
|
118
|
-
downloadTimer.end();
|
|
119
|
-
downloaded[key] = true;
|
|
120
|
-
checkFinish();
|
|
121
|
-
}
|
|
122
|
-
catch (err) {
|
|
123
|
-
reject(err);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
const areAllFilesDownloading = Object.keys(alreadyDownloading).length === expectedFiles;
|
|
127
|
-
if (!areAllFilesDownloading) {
|
|
128
|
-
setTimeout(() => {
|
|
129
|
-
loop().catch((err) => reject(err));
|
|
130
|
-
}, 100);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
loop().catch((err) => reject(err));
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
exports.getAllFilesS3 = getAllFilesS3;
|
|
137
|
-
const concatVideosS3 = async ({ onProgress, numberOfFrames, codec, fps, numberOfGifLoops, files, outdir, audioCodec, audioBitrate, logLevel, framesPerLambda, binariesDirectory, cancelSignal, preferLossless, muted, }) => {
|
|
13
|
+
const concatVideos = async ({ onProgress, numberOfFrames, codec, fps, numberOfGifLoops, files, outdir, audioCodec, audioBitrate, logLevel, framesPerLambda, binariesDirectory, cancelSignal, preferLossless, muted, }) => {
|
|
138
14
|
const outfile = (0, node_path_1.join)(renderer_1.RenderInternals.tmpDir(constants_1.REMOTION_CONCATED_TOKEN), `concat.${renderer_1.RenderInternals.getFileExtensionFromCodec(codec, audioCodec)}`);
|
|
139
15
|
const combine = (0, timer_1.timer)('Combine chunks', logLevel);
|
|
140
16
|
const filelistDir = renderer_1.RenderInternals.tmpDir(constants_1.REMOTION_FILELIST_TOKEN);
|
|
@@ -174,4 +50,4 @@ const concatVideosS3 = async ({ onProgress, numberOfFrames, codec, fps, numberOf
|
|
|
174
50
|
});
|
|
175
51
|
return { outfile, cleanupChunksProm };
|
|
176
52
|
};
|
|
177
|
-
exports.
|
|
53
|
+
exports.concatVideos = concatVideos;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { _Object } from '@aws-sdk/client-s3';
|
|
2
1
|
import type { AwsRegion } from '../../pricing/aws-regions';
|
|
3
2
|
import type { PostRenderData, RenderMetadata } from '../../shared/constants';
|
|
4
3
|
import type { OutputFileMetadata } from './find-output-file-in-bucket';
|
|
4
|
+
import type { OverallRenderProgress } from './overall-render-progress';
|
|
5
5
|
import type { EnhancedErrorInfo } from './write-lambda-error';
|
|
6
|
-
export declare const createPostRenderData: ({
|
|
7
|
-
renderId: string;
|
|
8
|
-
expectedBucketOwner: string;
|
|
6
|
+
export declare const createPostRenderData: ({ region, memorySizeInMb, renderMetadata, errorExplanations, timeToDelete, outputFile, timeToCombine, overallProgress, timeToFinish, outputSize, }: {
|
|
9
7
|
region: AwsRegion;
|
|
10
8
|
memorySizeInMb: number;
|
|
11
9
|
renderMetadata: RenderMetadata;
|
|
12
|
-
contents: _Object[];
|
|
13
|
-
timeToEncode: number;
|
|
14
10
|
timeToDelete: number;
|
|
15
11
|
errorExplanations: EnhancedErrorInfo[];
|
|
16
12
|
outputFile: OutputFileMetadata;
|
|
13
|
+
timeToCombine: number | null;
|
|
14
|
+
overallProgress: OverallRenderProgress;
|
|
15
|
+
timeToFinish: number;
|
|
16
|
+
outputSize: number;
|
|
17
17
|
}) => PostRenderData;
|
|
@@ -4,15 +4,9 @@ exports.createPostRenderData = void 0;
|
|
|
4
4
|
const estimate_price_1 = require("../../api/estimate-price");
|
|
5
5
|
const constants_1 = require("../../shared/constants");
|
|
6
6
|
const get_most_expensive_chunks_1 = require("../../shared/get-most-expensive-chunks");
|
|
7
|
-
const parse_lambda_timings_key_1 = require("../../shared/parse-lambda-timings-key");
|
|
8
7
|
const calculate_chunk_times_1 = require("./calculate-chunk-times");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const get_time_to_finish_1 = require("./get-time-to-finish");
|
|
12
|
-
const render_has_audio_video_1 = require("./render-has-audio-video");
|
|
13
|
-
const createPostRenderData = ({ renderId, region, memorySizeInMb, renderMetadata, contents, timeToEncode, errorExplanations, timeToDelete, outputFile, }) => {
|
|
14
|
-
const initializedKeys = contents.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaTimingsPrefix)(renderId)); });
|
|
15
|
-
const parsedTimings = initializedKeys.map(({ Key }) => (0, parse_lambda_timings_key_1.parseLambdaTimingsKey)(Key));
|
|
8
|
+
const createPostRenderData = ({ region, memorySizeInMb, renderMetadata, errorExplanations, timeToDelete, outputFile, timeToCombine, overallProgress, timeToFinish, outputSize, }) => {
|
|
9
|
+
const parsedTimings = overallProgress.timings;
|
|
16
10
|
const estimatedBillingDurationInMilliseconds = parsedTimings
|
|
17
11
|
.map((p) => p.rendered - p.start + get_most_expensive_chunks_1.OVERHEAD_TIME_PER_LAMBDA)
|
|
18
12
|
.reduce((a, b) => a + b);
|
|
@@ -29,58 +23,44 @@ const createPostRenderData = ({ renderId, region, memorySizeInMb, renderMetadata
|
|
|
29
23
|
throw new Error('Cannot wrap up without an output file in the S3 bucket.');
|
|
30
24
|
}
|
|
31
25
|
const endTime = Date.now();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
throw new TypeError(`Cannot calculate timeToFinish value`);
|
|
26
|
+
if (overallProgress.timeToEncode === null) {
|
|
27
|
+
throw new Error('Expected time to encode to be set');
|
|
28
|
+
}
|
|
29
|
+
if (overallProgress.timeToRenderFrames === null) {
|
|
30
|
+
throw new Error('Expected time to encode to be set');
|
|
38
31
|
}
|
|
39
|
-
const renderSize = contents
|
|
40
|
-
.map((c) => { var _a; return (_a = c.Size) !== null && _a !== void 0 ? _a : 0; })
|
|
41
|
-
.reduce((a, b) => a + b, 0);
|
|
42
|
-
const retriesInfo = (0, get_retry_stats_1.getRetryStats)({
|
|
43
|
-
contents,
|
|
44
|
-
renderId,
|
|
45
|
-
});
|
|
46
|
-
const { hasAudio, hasVideo } = (0, render_has_audio_video_1.lambdaRenderHasAudioVideo)(renderMetadata);
|
|
47
32
|
return {
|
|
48
33
|
cost: {
|
|
49
34
|
currency: 'USD',
|
|
50
35
|
disclaimer: 'Estimated cost for lambda invocations only. Does not include cost for S3 storage and data transfer.',
|
|
51
36
|
estimatedCost: cost,
|
|
52
|
-
estimatedDisplayCost: new Intl.NumberFormat('en-US', {
|
|
37
|
+
estimatedDisplayCost: `$${new Intl.NumberFormat('en-US', {
|
|
53
38
|
currency: 'USD',
|
|
54
39
|
currencyDisplay: 'narrowSymbol',
|
|
55
|
-
}).format(cost)
|
|
40
|
+
}).format(cost)}`,
|
|
56
41
|
},
|
|
57
42
|
outputFile: outputFile.url,
|
|
58
43
|
timeToFinish,
|
|
59
44
|
errors: errorExplanations,
|
|
60
45
|
startTime: renderMetadata.startedDate,
|
|
61
46
|
endTime,
|
|
62
|
-
outputSize
|
|
63
|
-
renderSize,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
chunkCount: renderMetadata.totalChunks,
|
|
67
|
-
renderId,
|
|
68
|
-
hasAudio,
|
|
69
|
-
hasVideo,
|
|
70
|
-
}).length,
|
|
71
|
-
timeToEncode,
|
|
47
|
+
outputSize,
|
|
48
|
+
renderSize: outputSize,
|
|
49
|
+
filesCleanedUp: 0,
|
|
50
|
+
timeToEncode: overallProgress.timeToEncode,
|
|
72
51
|
timeToCleanUp: timeToDelete,
|
|
73
52
|
timeToRenderChunks: (0, calculate_chunk_times_1.calculateChunkTimes)({
|
|
74
|
-
contents,
|
|
75
|
-
renderId,
|
|
76
53
|
type: 'absolute-time',
|
|
54
|
+
timings: overallProgress.timings,
|
|
77
55
|
}),
|
|
78
|
-
|
|
56
|
+
timeToRenderFrames: overallProgress.timeToRenderFrames,
|
|
57
|
+
retriesInfo: overallProgress.retries,
|
|
79
58
|
mostExpensiveFrameRanges: renderMetadata.type === 'still'
|
|
80
59
|
? []
|
|
81
60
|
: (0, get_most_expensive_chunks_1.getMostExpensiveChunks)(parsedTimings, renderMetadata.framesPerLambda, renderMetadata.frameRange[0], renderMetadata.frameRange[1]),
|
|
82
61
|
deleteAfter: renderMetadata.deleteAfter,
|
|
83
62
|
estimatedBillingDurationInMilliseconds,
|
|
63
|
+
timeToCombine: timeToCombine !== null && timeToCombine !== void 0 ? timeToCombine : null,
|
|
84
64
|
};
|
|
85
65
|
};
|
|
86
66
|
exports.createPostRenderData = createPostRenderData;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { AwsRegion } from '
|
|
1
|
+
import type { AwsRegion } from '../../client';
|
|
2
2
|
import type { CustomCredentials } from '../../shared/aws-clients';
|
|
3
3
|
import type { RenderMetadata } from '../../shared/constants';
|
|
4
4
|
export type OutputFileMetadata = {
|
|
5
5
|
url: string;
|
|
6
|
-
size: number;
|
|
7
|
-
lastModified: number;
|
|
8
6
|
};
|
|
9
7
|
export declare const findOutputFileInBucket: ({ region, renderMetadata, bucketName, customCredentials, }: {
|
|
10
8
|
region: AwsRegion;
|
|
@@ -6,21 +6,18 @@ const expected_out_name_1 = require("./expected-out-name");
|
|
|
6
6
|
const get_output_url_from_metadata_1 = require("./get-output-url-from-metadata");
|
|
7
7
|
const io_1 = require("./io");
|
|
8
8
|
const findOutputFileInBucket = async ({ region, renderMetadata, bucketName, customCredentials, }) => {
|
|
9
|
-
var _a;
|
|
10
9
|
if (!renderMetadata) {
|
|
11
10
|
throw new Error('unexpectedly did not get renderMetadata');
|
|
12
11
|
}
|
|
13
12
|
const { renderBucketName, key } = (0, expected_out_name_1.getExpectedOutName)(renderMetadata, bucketName, customCredentials);
|
|
14
13
|
try {
|
|
15
|
-
|
|
14
|
+
await (0, io_1.lambdaHeadCommand)({
|
|
16
15
|
bucketName,
|
|
17
16
|
key,
|
|
18
17
|
region,
|
|
19
18
|
customCredentials,
|
|
20
19
|
});
|
|
21
20
|
return {
|
|
22
|
-
lastModified: (_a = head.LastModified) === null || _a === void 0 ? void 0 : _a.getTime(),
|
|
23
|
-
size: head.ContentLength,
|
|
24
21
|
url: (0, get_output_url_from_metadata_1.getOutputUrlFromMetadata)(renderMetadata, bucketName, customCredentials).url,
|
|
25
22
|
};
|
|
26
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
declare const getEncodingProgressStepSize: (totalFrames: number) => number;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEncodingProgressStepSize = void 0;
|
|
4
2
|
const getEncodingProgressStepSize = (totalFrames) => {
|
|
5
3
|
return Math.min(100, Math.max(5, totalFrames / 10));
|
|
6
4
|
};
|
|
7
|
-
exports.getEncodingProgressStepSize = getEncodingProgressStepSize;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export type LambdaInvokeStats = {
|
|
1
|
+
type LambdaInvokeStats = {
|
|
3
2
|
lambdasInvoked: number;
|
|
4
3
|
};
|
|
5
|
-
export declare const getLambdasInvokedStats: ({ contents, renderId, }: {
|
|
6
|
-
contents: _Object[];
|
|
7
|
-
renderId: string;
|
|
8
|
-
}) => LambdaInvokeStats;
|
|
@@ -1,14 +1 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLambdasInvokedStats = void 0;
|
|
4
|
-
const constants_1 = require("../../shared/constants");
|
|
5
|
-
const parse_lambda_initialized_key_1 = require("../../shared/parse-lambda-initialized-key");
|
|
6
|
-
const getLambdasInvokedStats = ({ contents, renderId, }) => {
|
|
7
|
-
const lambdasInvoked = contents
|
|
8
|
-
.filter((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.lambdaChunkInitializedPrefix)(renderId)); })
|
|
9
|
-
.filter((c) => (0, parse_lambda_initialized_key_1.parseLambdaInitializedKey)(c.Key).attempt === 1);
|
|
10
|
-
return {
|
|
11
|
-
lambdasInvoked: lambdasInvoked.length,
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
exports.getLambdasInvokedStats = getLambdasInvokedStats;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { AwsRegion } from '../../client';
|
|
1
2
|
import type { OverallRenderProgress } from './overall-render-progress';
|
|
2
|
-
export declare const getOverallProgressS3: ({ renderId, bucketName, expectedBucketOwner, }: {
|
|
3
|
+
export declare const getOverallProgressS3: ({ renderId, bucketName, expectedBucketOwner, region, }: {
|
|
3
4
|
renderId: string;
|
|
4
5
|
expectedBucketOwner: string;
|
|
5
6
|
bucketName: string;
|
|
6
|
-
|
|
7
|
+
region: AwsRegion;
|
|
8
|
+
}) => Promise<OverallRenderProgress>;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOverallProgressS3 = void 0;
|
|
4
|
-
const
|
|
4
|
+
const constants_1 = require("../../shared/constants");
|
|
5
5
|
const stream_to_string_1 = require("../../shared/stream-to-string");
|
|
6
|
-
const get_current_region_1 = require("./get-current-region");
|
|
7
6
|
const io_1 = require("./io");
|
|
8
|
-
const getOverallProgressS3 = async ({ renderId, bucketName, expectedBucketOwner, }) => {
|
|
7
|
+
const getOverallProgressS3 = async ({ renderId, bucketName, expectedBucketOwner, region, }) => {
|
|
9
8
|
try {
|
|
10
9
|
const Body = await (0, io_1.lambdaReadFile)({
|
|
11
10
|
bucketName,
|
|
12
|
-
key: (0,
|
|
11
|
+
key: (0, constants_1.overallProgressKey)(renderId),
|
|
13
12
|
expectedBucketOwner,
|
|
14
|
-
region
|
|
13
|
+
region,
|
|
15
14
|
});
|
|
16
15
|
const str = await (0, stream_to_string_1.streamToString)(Body);
|
|
17
16
|
return JSON.parse(str);
|
|
18
17
|
}
|
|
19
18
|
catch (err) {
|
|
20
|
-
|
|
19
|
+
if (err.name === 'NotFound') {
|
|
20
|
+
throw new TypeError(`No render with ID "${renderId}" found in bucket ${bucketName} and region ${region}`);
|
|
21
|
+
}
|
|
22
|
+
throw err;
|
|
21
23
|
}
|
|
22
24
|
};
|
|
23
25
|
exports.getOverallProgressS3 = getOverallProgressS3;
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOverallProgress = void 0;
|
|
4
4
|
const weights = {
|
|
5
|
-
cleanup: 0.1,
|
|
6
5
|
encoding: 0.225,
|
|
7
6
|
rendering: 0.225,
|
|
8
7
|
frames: 0.225,
|
|
9
8
|
invoking: 0.225,
|
|
10
9
|
};
|
|
11
|
-
const getOverallProgress = ({
|
|
12
|
-
return (
|
|
13
|
-
encoding * weights.encoding +
|
|
10
|
+
const getOverallProgress = ({ encoding, rendering, invoking, frames, }) => {
|
|
11
|
+
return (encoding * weights.encoding +
|
|
14
12
|
rendering * weights.rendering +
|
|
15
13
|
invoking * weights.invoking +
|
|
16
14
|
frames * weights.frames);
|