@remotion/lambda 3.2.42 → 3.2.44
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/render-media-on-lambda.d.ts +1 -0
- package/dist/api/render-media-on-lambda.js +7 -2
- package/dist/api/render-still-on-lambda.js +2 -2
- package/dist/cli/commands/render/progress.d.ts +2 -1
- package/dist/cli/commands/render/progress.js +10 -3
- package/dist/cli/commands/render/render.js +7 -0
- package/dist/functions/chunk-optimization/can-use-optimization.d.ts +6 -0
- package/dist/functions/chunk-optimization/can-use-optimization.js +23 -0
- package/dist/functions/chunk-optimization/collect-data.d.ts +9 -0
- package/dist/functions/chunk-optimization/collect-data.js +27 -0
- package/dist/functions/chunk-optimization/get-frame-ranges-from-profile.d.ts +3 -0
- package/dist/functions/chunk-optimization/get-frame-ranges-from-profile.js +11 -0
- package/dist/functions/chunk-optimization/get-profile-duration.d.ts +3 -0
- package/dist/functions/chunk-optimization/get-profile-duration.js +18 -0
- package/dist/functions/chunk-optimization/is-valid-profile.d.ts +2 -0
- package/dist/functions/chunk-optimization/is-valid-profile.js +12 -0
- package/dist/functions/chunk-optimization/optimize-invocation-order.d.ts +2 -0
- package/dist/functions/chunk-optimization/optimize-invocation-order.js +19 -0
- package/dist/functions/chunk-optimization/optimize-profile.d.ts +9 -0
- package/dist/functions/chunk-optimization/optimize-profile.js +74 -0
- package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +4 -1
- package/dist/functions/chunk-optimization/s3-optimization-file.d.ts +17 -0
- package/dist/functions/chunk-optimization/s3-optimization-file.js +47 -0
- package/dist/functions/chunk-optimization/simulate-frame-ranges.d.ts +7 -0
- package/dist/functions/chunk-optimization/simulate-frame-ranges.js +47 -0
- package/dist/functions/chunk-optimization/sort-by-duration.d.ts +2 -0
- package/dist/functions/chunk-optimization/sort-by-duration.js +25 -0
- package/dist/functions/launch.js +10 -7
- package/dist/shared/get-aws-url.d.ts +8 -0
- package/dist/shared/get-aws-url.js +7 -0
- package/dist/shared/get-aws-urls.d.ts +13 -0
- package/dist/shared/get-aws-urls.js +11 -0
- package/package.json +6 -6
- package/remotionlambda.zip +0 -0
|
@@ -5,7 +5,7 @@ const version_1 = require("remotion/version");
|
|
|
5
5
|
const call_lambda_1 = require("../shared/call-lambda");
|
|
6
6
|
const constants_1 = require("../shared/constants");
|
|
7
7
|
const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
|
|
8
|
-
const
|
|
8
|
+
const get_aws_urls_1 = require("../shared/get-aws-urls");
|
|
9
9
|
const serialize_input_props_1 = require("../shared/serialize-input-props");
|
|
10
10
|
const validate_download_behavior_1 = require("../shared/validate-download-behavior");
|
|
11
11
|
const validate_frames_per_lambda_1 = require("../shared/validate-frames-per-lambda");
|
|
@@ -89,12 +89,17 @@ const renderMediaOnLambda = async ({ functionName, serveUrl, inputProps, codec,
|
|
|
89
89
|
return {
|
|
90
90
|
renderId: res.renderId,
|
|
91
91
|
bucketName: res.bucketName,
|
|
92
|
-
cloudWatchLogs: (0,
|
|
92
|
+
cloudWatchLogs: (0, get_aws_urls_1.getCloudwatchStreamUrl)({
|
|
93
93
|
functionName,
|
|
94
94
|
method: constants_1.LambdaRoutines.renderer,
|
|
95
95
|
region,
|
|
96
96
|
renderId: res.renderId,
|
|
97
97
|
}),
|
|
98
|
+
folderInS3Console: (0, get_aws_urls_1.getS3RenderUrl)({
|
|
99
|
+
bucketName: res.bucketName,
|
|
100
|
+
renderId: res.renderId,
|
|
101
|
+
region,
|
|
102
|
+
}),
|
|
98
103
|
};
|
|
99
104
|
}
|
|
100
105
|
catch (err) {
|
|
@@ -5,7 +5,7 @@ const version_1 = require("remotion/version");
|
|
|
5
5
|
const call_lambda_1 = require("../shared/call-lambda");
|
|
6
6
|
const constants_1 = require("../shared/constants");
|
|
7
7
|
const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
|
|
8
|
-
const
|
|
8
|
+
const get_aws_urls_1 = require("../shared/get-aws-urls");
|
|
9
9
|
const serialize_input_props_1 = require("../shared/serialize-input-props");
|
|
10
10
|
/**
|
|
11
11
|
* @description Renders a still frame on Lambda
|
|
@@ -64,7 +64,7 @@ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFo
|
|
|
64
64
|
sizeInBytes: res.size,
|
|
65
65
|
bucketName: res.bucketName,
|
|
66
66
|
renderId: res.renderId,
|
|
67
|
-
cloudWatchLogs: (0,
|
|
67
|
+
cloudWatchLogs: (0, get_aws_urls_1.getCloudwatchStreamUrl)({
|
|
68
68
|
functionName,
|
|
69
69
|
method: constants_1.LambdaRoutines.still,
|
|
70
70
|
region,
|
|
@@ -22,10 +22,11 @@ declare type DownloadedInfo = {
|
|
|
22
22
|
downloaded: number;
|
|
23
23
|
doneIn: number | null;
|
|
24
24
|
};
|
|
25
|
-
export declare const makeProgressString: ({ progress, steps, downloadInfo, retriesInfo, }: {
|
|
25
|
+
export declare const makeProgressString: ({ progress, steps, downloadInfo, retriesInfo, verbose, }: {
|
|
26
26
|
progress: MultiRenderProgress;
|
|
27
27
|
steps: number;
|
|
28
28
|
downloadInfo: DownloadedInfo | null;
|
|
29
29
|
retriesInfo: ChunkRetry[];
|
|
30
|
+
verbose: boolean;
|
|
30
31
|
}) => string;
|
|
31
32
|
export {};
|
|
@@ -57,10 +57,17 @@ const makeEncodingProgress = ({ encodingProgress, chunkProgress, totalSteps, })
|
|
|
57
57
|
: cli_1.CliInternals.chalk.gray(`${doneIn}ms`),
|
|
58
58
|
].join(' ');
|
|
59
59
|
};
|
|
60
|
-
const makeCleanupProgress = (cleanupInfo, totalSteps) => {
|
|
60
|
+
const makeCleanupProgress = (cleanupInfo, totalSteps, skipped) => {
|
|
61
61
|
if (!cleanupInfo) {
|
|
62
62
|
return '';
|
|
63
63
|
}
|
|
64
|
+
if (skipped) {
|
|
65
|
+
return [
|
|
66
|
+
'🪣 ',
|
|
67
|
+
`(4/${totalSteps})`,
|
|
68
|
+
cli_1.CliInternals.chalk.blueBright(`Not cleaning up because --log=verbose was set`),
|
|
69
|
+
].join(' ');
|
|
70
|
+
}
|
|
64
71
|
const { doneIn, filesDeleted, minFilesToDelete } = cleanupInfo;
|
|
65
72
|
const progress = filesDeleted / minFilesToDelete;
|
|
66
73
|
return [
|
|
@@ -116,7 +123,7 @@ const makeMultiProgressFromStatus = (status) => {
|
|
|
116
123
|
};
|
|
117
124
|
};
|
|
118
125
|
exports.makeMultiProgressFromStatus = makeMultiProgressFromStatus;
|
|
119
|
-
const makeProgressString = ({ progress, steps, downloadInfo, retriesInfo, }) => {
|
|
126
|
+
const makeProgressString = ({ progress, steps, downloadInfo, retriesInfo, verbose, }) => {
|
|
120
127
|
return [
|
|
121
128
|
makeInvokeProgress(progress.lambdaInvokeProgress, steps, retriesInfo),
|
|
122
129
|
makeChunkProgress({
|
|
@@ -129,7 +136,7 @@ const makeProgressString = ({ progress, steps, downloadInfo, retriesInfo, }) =>
|
|
|
129
136
|
chunkProgress: progress.chunkProgress,
|
|
130
137
|
totalSteps: steps,
|
|
131
138
|
}),
|
|
132
|
-
makeCleanupProgress(progress.cleanupInfo, steps),
|
|
139
|
+
makeCleanupProgress(progress.cleanupInfo, steps, verbose),
|
|
133
140
|
downloadInfo ? makeDownloadProgress(downloadInfo, steps) : null,
|
|
134
141
|
]
|
|
135
142
|
.filter(remotion_1.Internals.truthy)
|
|
@@ -100,7 +100,9 @@ const renderCommand = async (args) => {
|
|
|
100
100
|
const progressBar = cli_1.CliInternals.createOverwriteableCliOutput(cli_1.CliInternals.quietFlagProvided());
|
|
101
101
|
log_1.Log.info(cli_1.CliInternals.chalk.gray(`bucket = ${res.bucketName}, function = ${functionName}`));
|
|
102
102
|
log_1.Log.info(cli_1.CliInternals.chalk.gray(`renderId = ${res.renderId}, codec = ${codec} (${reason})`));
|
|
103
|
+
const verbose = renderer_1.RenderInternals.isEqualOrBelowLogLevel(cli_1.ConfigInternals.Logging.getLogLevel(), 'verbose');
|
|
103
104
|
log_1.Log.verbose(`CloudWatch logs (if enabled): ${res.cloudWatchLogs}`);
|
|
105
|
+
log_1.Log.verbose(`Render folder: ${res.folderInS3Console}`);
|
|
104
106
|
const status = await (0, get_render_progress_1.getRenderProgress)({
|
|
105
107
|
functionName,
|
|
106
108
|
bucketName: res.bucketName,
|
|
@@ -113,6 +115,7 @@ const renderCommand = async (args) => {
|
|
|
113
115
|
steps: totalSteps,
|
|
114
116
|
downloadInfo: null,
|
|
115
117
|
retriesInfo: status.retriesInfo,
|
|
118
|
+
verbose,
|
|
116
119
|
}));
|
|
117
120
|
// eslint-disable-next-line no-constant-condition
|
|
118
121
|
while (true) {
|
|
@@ -129,6 +132,7 @@ const renderCommand = async (args) => {
|
|
|
129
132
|
steps: totalSteps,
|
|
130
133
|
retriesInfo: newStatus.retriesInfo,
|
|
131
134
|
downloadInfo: null,
|
|
135
|
+
verbose,
|
|
132
136
|
}));
|
|
133
137
|
if (newStatus.done) {
|
|
134
138
|
progressBar.update((0, progress_1.makeProgressString)({
|
|
@@ -136,6 +140,7 @@ const renderCommand = async (args) => {
|
|
|
136
140
|
steps: totalSteps,
|
|
137
141
|
downloadInfo: null,
|
|
138
142
|
retriesInfo: newStatus.retriesInfo,
|
|
143
|
+
verbose,
|
|
139
144
|
}));
|
|
140
145
|
if (downloadName) {
|
|
141
146
|
const downloadStart = Date.now();
|
|
@@ -154,6 +159,7 @@ const renderCommand = async (args) => {
|
|
|
154
159
|
downloaded,
|
|
155
160
|
totalSize,
|
|
156
161
|
},
|
|
162
|
+
verbose,
|
|
157
163
|
}));
|
|
158
164
|
},
|
|
159
165
|
});
|
|
@@ -166,6 +172,7 @@ const renderCommand = async (args) => {
|
|
|
166
172
|
downloaded: sizeInBytes,
|
|
167
173
|
totalSize: sizeInBytes,
|
|
168
174
|
},
|
|
175
|
+
verbose,
|
|
169
176
|
}));
|
|
170
177
|
log_1.Log.info();
|
|
171
178
|
log_1.Log.info();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.canUseOptimization = void 0;
|
|
4
|
+
const version_1 = require("remotion/version");
|
|
5
|
+
const canUseOptimization = ({ optimization, framesPerLambda, frameRange, }) => {
|
|
6
|
+
if (!optimization) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (optimization.framesPerLambda !== framesPerLambda) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (optimization.lambdaVersion !== version_1.VERSION) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (optimization.frameRange[0] !== frameRange[0]) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (optimization.frameRange[1] !== frameRange[1]) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
};
|
|
23
|
+
exports.canUseOptimization = canUseOptimization;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AwsRegion } from '../../pricing/aws-regions';
|
|
2
|
+
export declare const collectChunkInformation: ({ bucketName, renderId, region, expectedBucketOwner, }: {
|
|
3
|
+
bucketName: string;
|
|
4
|
+
renderId: string;
|
|
5
|
+
region: AwsRegion;
|
|
6
|
+
expectedBucketOwner: string;
|
|
7
|
+
}) => Promise<(Omit<import("./types").ObjectChunkTimingData, "timings"> & {
|
|
8
|
+
timings: number[];
|
|
9
|
+
})[]>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectChunkInformation = void 0;
|
|
4
|
+
const constants_1 = require("../../shared/constants");
|
|
5
|
+
const stream_to_string_1 = require("../../shared/stream-to-string");
|
|
6
|
+
const io_1 = require("../helpers/io");
|
|
7
|
+
const collectChunkInformation = async ({ bucketName, renderId, region, expectedBucketOwner, }) => {
|
|
8
|
+
const prefix = (0, constants_1.lambdaTimingsPrefix)(renderId);
|
|
9
|
+
const timingFiles = await (0, io_1.lambdaLs)({
|
|
10
|
+
bucketName,
|
|
11
|
+
prefix,
|
|
12
|
+
region,
|
|
13
|
+
expectedBucketOwner,
|
|
14
|
+
});
|
|
15
|
+
const timingFileContents = await Promise.all(timingFiles.map(async (file) => {
|
|
16
|
+
const contents = await (0, io_1.lambdaReadFile)({
|
|
17
|
+
bucketName,
|
|
18
|
+
key: file.Key,
|
|
19
|
+
region,
|
|
20
|
+
expectedBucketOwner,
|
|
21
|
+
});
|
|
22
|
+
const string = await (0, stream_to_string_1.streamToString)(contents);
|
|
23
|
+
return JSON.parse(string);
|
|
24
|
+
}));
|
|
25
|
+
return timingFileContents;
|
|
26
|
+
};
|
|
27
|
+
exports.collectChunkInformation = collectChunkInformation;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortProfileByFrameRanges = exports.getFrameRangesFromProfile = void 0;
|
|
4
|
+
const getFrameRangesFromProfile = (profile) => {
|
|
5
|
+
return profile.map((p) => p.frameRange);
|
|
6
|
+
};
|
|
7
|
+
exports.getFrameRangesFromProfile = getFrameRangesFromProfile;
|
|
8
|
+
const sortProfileByFrameRanges = (profile) => {
|
|
9
|
+
return profile.slice().sort((a, b) => a.frameRange[0] - b.frameRange[0]);
|
|
10
|
+
};
|
|
11
|
+
exports.sortProfileByFrameRanges = sortProfileByFrameRanges;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProfileDuration = exports.getTimingEndTimestamps = void 0;
|
|
4
|
+
const getTimingEndTimestamps = (chunk) => {
|
|
5
|
+
return chunk.timings.map((timing) => chunk.startDate + timing);
|
|
6
|
+
};
|
|
7
|
+
exports.getTimingEndTimestamps = getTimingEndTimestamps;
|
|
8
|
+
const getProfileTimestamps = (chunks) => {
|
|
9
|
+
return chunks.map((c) => (0, exports.getTimingEndTimestamps)(c));
|
|
10
|
+
};
|
|
11
|
+
const getProfileDuration = (chunks) => {
|
|
12
|
+
const startTimeStamps = chunks.map((c) => c.startDate).flat(1);
|
|
13
|
+
const endTimestamps = getProfileTimestamps(chunks).flat(1);
|
|
14
|
+
const earliest = Math.min(...startTimeStamps);
|
|
15
|
+
const latest = Math.max(...endTimestamps);
|
|
16
|
+
return latest - earliest;
|
|
17
|
+
};
|
|
18
|
+
exports.getProfileDuration = getProfileDuration;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidOptimizationProfile = void 0;
|
|
4
|
+
const renderer_1 = require("@remotion/renderer");
|
|
5
|
+
const isValidOptimizationProfile = (profile) => {
|
|
6
|
+
return profile.every((timing) => {
|
|
7
|
+
const frames = renderer_1.RenderInternals.getFramesToRender(timing.frameRange, 1);
|
|
8
|
+
const values = Object.values(timing.timings);
|
|
9
|
+
return frames.length === values.length && values.every((v) => v > 0);
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
exports.isValidOptimizationProfile = isValidOptimizationProfile;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.optimizeInvocationOrder = void 0;
|
|
4
|
+
const sort_by_duration_1 = require("./sort-by-duration");
|
|
5
|
+
const optimizeInvocationOrder = (profile) => {
|
|
6
|
+
const sortedByDuration = (0, sort_by_duration_1.sortProfileByDuration)(profile).reverse();
|
|
7
|
+
const sortedByStartTime = profile
|
|
8
|
+
.slice()
|
|
9
|
+
.map((a) => a.startDate)
|
|
10
|
+
.sort((a, b) => a - b);
|
|
11
|
+
const result = sortedByStartTime.map((prof, i) => {
|
|
12
|
+
return {
|
|
13
|
+
...sortedByDuration[i],
|
|
14
|
+
startDate: prof,
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
exports.optimizeInvocationOrder = optimizeInvocationOrder;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TimingProfile } from './types';
|
|
2
|
+
export declare const assignFrameToOther: ({ frameRanges, fromChunk, toChunk, framesToShift, }: {
|
|
3
|
+
frameRanges: [number, number][];
|
|
4
|
+
fromChunk: number;
|
|
5
|
+
toChunk: number;
|
|
6
|
+
framesToShift: number;
|
|
7
|
+
}) => [number, number][];
|
|
8
|
+
export declare const optimizeProfile: (_profile: TimingProfile) => TimingProfile;
|
|
9
|
+
export declare const optimizeProfileRecursively: (profile: TimingProfile, amount: number) => TimingProfile;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.optimizeProfileRecursively = exports.optimizeProfile = exports.assignFrameToOther = void 0;
|
|
4
|
+
const get_frame_ranges_from_profile_1 = require("./get-frame-ranges-from-profile");
|
|
5
|
+
const simulate_frame_ranges_1 = require("./simulate-frame-ranges");
|
|
6
|
+
const sort_by_duration_1 = require("./sort-by-duration");
|
|
7
|
+
const assignFrameToOther = ({ frameRanges, fromChunk, toChunk, framesToShift, }) => {
|
|
8
|
+
if (fromChunk < toChunk) {
|
|
9
|
+
return frameRanges.map((frameRange, i) => {
|
|
10
|
+
if (i === fromChunk) {
|
|
11
|
+
return [frameRange[0], frameRange[1] - framesToShift];
|
|
12
|
+
}
|
|
13
|
+
if (i === toChunk) {
|
|
14
|
+
return [frameRange[0] - framesToShift, frameRange[1]];
|
|
15
|
+
}
|
|
16
|
+
if (i > fromChunk && i < toChunk) {
|
|
17
|
+
return [frameRange[0] - framesToShift, frameRange[1] - framesToShift];
|
|
18
|
+
}
|
|
19
|
+
return frameRange;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return frameRanges.map((frameRange, i) => {
|
|
23
|
+
if (i === fromChunk) {
|
|
24
|
+
return [frameRange[0] + framesToShift, frameRange[1]];
|
|
25
|
+
}
|
|
26
|
+
if (i === toChunk) {
|
|
27
|
+
return [frameRange[0], frameRange[1] + framesToShift];
|
|
28
|
+
}
|
|
29
|
+
if (i > toChunk && i < fromChunk) {
|
|
30
|
+
return [frameRange[0] + framesToShift, frameRange[1] + framesToShift];
|
|
31
|
+
}
|
|
32
|
+
return frameRange;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.assignFrameToOther = assignFrameToOther;
|
|
36
|
+
const optimizeProfile = (_profile) => {
|
|
37
|
+
const sortedByStart = _profile
|
|
38
|
+
.slice()
|
|
39
|
+
.sort((a, b) => a.frameRange[0] - b.frameRange[0]);
|
|
40
|
+
const sortedByDuration = (0, sort_by_duration_1.sortProfileByDuration)(sortedByStart);
|
|
41
|
+
const indexOfFastest = sortedByStart.indexOf(sortedByDuration[0]);
|
|
42
|
+
if (indexOfFastest === -1) {
|
|
43
|
+
throw new Error('invalid timing profile: ' + JSON.stringify(_profile));
|
|
44
|
+
}
|
|
45
|
+
const slowest = sortedByDuration[sortedByDuration.length - 1];
|
|
46
|
+
const indexOfSlowest = sortedByStart.indexOf(slowest);
|
|
47
|
+
if (indexOfSlowest === -1) {
|
|
48
|
+
throw new Error('invalid timing profile: ' + JSON.stringify(_profile));
|
|
49
|
+
}
|
|
50
|
+
const frameRanges = (0, get_frame_ranges_from_profile_1.getFrameRangesFromProfile)(sortedByStart);
|
|
51
|
+
if (indexOfFastest === indexOfSlowest) {
|
|
52
|
+
return _profile;
|
|
53
|
+
}
|
|
54
|
+
const newFrameRanges = (0, exports.assignFrameToOther)({
|
|
55
|
+
frameRanges,
|
|
56
|
+
fromChunk: indexOfSlowest,
|
|
57
|
+
toChunk: indexOfFastest,
|
|
58
|
+
framesToShift: Math.max(1, Math.min(2, Math.floor(slowest.timings.length / 3))),
|
|
59
|
+
});
|
|
60
|
+
const simulated = (0, simulate_frame_ranges_1.simulateFrameRanges)({
|
|
61
|
+
profile: sortedByStart,
|
|
62
|
+
newFrameRanges,
|
|
63
|
+
});
|
|
64
|
+
return simulated;
|
|
65
|
+
};
|
|
66
|
+
exports.optimizeProfile = optimizeProfile;
|
|
67
|
+
const optimizeProfileRecursively = (profile, amount) => {
|
|
68
|
+
let optimized = profile;
|
|
69
|
+
for (let i = 0; i < amount; i++) {
|
|
70
|
+
optimized = (0, exports.optimizeProfile)(optimized);
|
|
71
|
+
}
|
|
72
|
+
return optimized;
|
|
73
|
+
};
|
|
74
|
+
exports.optimizeProfileRecursively = optimizeProfileRecursively;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AwsRegion } from '../../pricing/aws-regions';
|
|
2
|
+
import type { OptimizationProfile } from './types';
|
|
3
|
+
export declare const writeOptimization: ({ bucketName, optimization, compositionId, siteId, region, expectedBucketOwner, }: {
|
|
4
|
+
bucketName: string;
|
|
5
|
+
optimization: OptimizationProfile;
|
|
6
|
+
compositionId: string;
|
|
7
|
+
siteId: string;
|
|
8
|
+
region: AwsRegion;
|
|
9
|
+
expectedBucketOwner: string;
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
export declare const getOptimization: ({ siteId, compositionId, bucketName, region, expectedBucketOwner, }: {
|
|
12
|
+
bucketName: string;
|
|
13
|
+
siteId: string;
|
|
14
|
+
compositionId: string;
|
|
15
|
+
region: AwsRegion;
|
|
16
|
+
expectedBucketOwner: string;
|
|
17
|
+
}) => Promise<OptimizationProfile | null>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOptimization = exports.writeOptimization = void 0;
|
|
4
|
+
const constants_1 = require("../../shared/constants");
|
|
5
|
+
const stream_to_string_1 = require("../../shared/stream-to-string");
|
|
6
|
+
const io_1 = require("../helpers/io");
|
|
7
|
+
const writeOptimization = async ({ bucketName, optimization, compositionId, siteId, region, expectedBucketOwner, }) => {
|
|
8
|
+
await (0, io_1.lambdaWriteFile)({
|
|
9
|
+
bucketName,
|
|
10
|
+
body: JSON.stringify(optimization),
|
|
11
|
+
key: (0, constants_1.optimizationProfile)(siteId, compositionId) + '.json',
|
|
12
|
+
region,
|
|
13
|
+
privacy: 'private',
|
|
14
|
+
expectedBucketOwner,
|
|
15
|
+
downloadBehavior: null,
|
|
16
|
+
customCredentials: null,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
exports.writeOptimization = writeOptimization;
|
|
20
|
+
const getOptimization = async ({ siteId, compositionId, bucketName, region, expectedBucketOwner, }) => {
|
|
21
|
+
const prefix = (0, constants_1.optimizationProfile)(siteId, compositionId);
|
|
22
|
+
const dir = await (0, io_1.lambdaLs)({
|
|
23
|
+
bucketName,
|
|
24
|
+
prefix,
|
|
25
|
+
region,
|
|
26
|
+
expectedBucketOwner,
|
|
27
|
+
});
|
|
28
|
+
const files = dir
|
|
29
|
+
.sort((a, b) => {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
return ((_a = a.LastModified) === null || _a === void 0 ? void 0 : _a.getTime()) -
|
|
32
|
+
((_b = b.LastModified) === null || _b === void 0 ? void 0 : _b.getTime());
|
|
33
|
+
})
|
|
34
|
+
.reverse();
|
|
35
|
+
if (files.length === 0) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const body = await (0, io_1.lambdaReadFile)({
|
|
39
|
+
bucketName,
|
|
40
|
+
key: files[0].Key,
|
|
41
|
+
region,
|
|
42
|
+
expectedBucketOwner,
|
|
43
|
+
});
|
|
44
|
+
const str = await (0, stream_to_string_1.streamToString)(body);
|
|
45
|
+
return JSON.parse(str);
|
|
46
|
+
};
|
|
47
|
+
exports.getOptimization = getOptimization;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ChunkTimingData, TimingProfile } from './types';
|
|
2
|
+
export declare const getTimingForFrame: (profile: TimingProfile, frame: number) => number;
|
|
3
|
+
export declare const getSimulatedTimingForFrameRange: (profile: TimingProfile, frameRange: [number, number]) => ChunkTimingData['timings'];
|
|
4
|
+
export declare const simulateFrameRanges: ({ profile, newFrameRanges, }: {
|
|
5
|
+
profile: TimingProfile;
|
|
6
|
+
newFrameRanges: [number, number][];
|
|
7
|
+
}) => TimingProfile;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.simulateFrameRanges = exports.getSimulatedTimingForFrameRange = exports.getTimingForFrame = void 0;
|
|
4
|
+
const getTimingForFrame = (profile, frame) => {
|
|
5
|
+
for (const timingInfo of profile) {
|
|
6
|
+
if (timingInfo.frameRange[0] > frame || timingInfo.frameRange[1] < frame) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
let lastTime = timingInfo.startDate;
|
|
10
|
+
for (let i = 0; i < timingInfo.timings.length; i++) {
|
|
11
|
+
const actualFrame = i + timingInfo.frameRange[0];
|
|
12
|
+
const timing = timingInfo.timings[i];
|
|
13
|
+
const absolute = timing + timingInfo.startDate;
|
|
14
|
+
if (actualFrame === frame) {
|
|
15
|
+
return absolute - lastTime;
|
|
16
|
+
}
|
|
17
|
+
lastTime = absolute;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
throw new Error(`Frame ${frame} was not rendered`);
|
|
21
|
+
};
|
|
22
|
+
exports.getTimingForFrame = getTimingForFrame;
|
|
23
|
+
const getSimulatedTimingForFrameRange = (profile, frameRange) => {
|
|
24
|
+
const timings = [];
|
|
25
|
+
let totalDuration = 0;
|
|
26
|
+
for (let i = frameRange[0]; i <= frameRange[1]; i++) {
|
|
27
|
+
const timingForFrame = (0, exports.getTimingForFrame)(profile, i);
|
|
28
|
+
timings.push(timingForFrame + totalDuration);
|
|
29
|
+
totalDuration += timingForFrame;
|
|
30
|
+
}
|
|
31
|
+
return timings;
|
|
32
|
+
};
|
|
33
|
+
exports.getSimulatedTimingForFrameRange = getSimulatedTimingForFrameRange;
|
|
34
|
+
const simulateFrameRanges = ({ profile, newFrameRanges, }) => {
|
|
35
|
+
if (profile.length !== newFrameRanges.length) {
|
|
36
|
+
throw new Error('Expected previous and new frame ranges to be equal');
|
|
37
|
+
}
|
|
38
|
+
return newFrameRanges.map((range, i) => {
|
|
39
|
+
return {
|
|
40
|
+
timings: (0, exports.getSimulatedTimingForFrameRange)(profile, range),
|
|
41
|
+
chunk: i,
|
|
42
|
+
frameRange: range,
|
|
43
|
+
startDate: profile[i].startDate,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
exports.simulateFrameRanges = simulateFrameRanges;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortProfileByDuration = void 0;
|
|
4
|
+
const get_profile_duration_1 = require("./get-profile-duration");
|
|
5
|
+
const durationCache = new Map();
|
|
6
|
+
const getChunkDuration = (chunk) => {
|
|
7
|
+
const inCache = durationCache.get(chunk);
|
|
8
|
+
if (inCache) {
|
|
9
|
+
return inCache;
|
|
10
|
+
}
|
|
11
|
+
const timestamps = (0, get_profile_duration_1.getTimingEndTimestamps)(chunk);
|
|
12
|
+
const duration = Math.max(...timestamps) - chunk.startDate;
|
|
13
|
+
durationCache.set(chunk, duration);
|
|
14
|
+
return duration;
|
|
15
|
+
};
|
|
16
|
+
const sortProfileByDuration = (profile) => {
|
|
17
|
+
const sortedByDuration = profile.slice().sort((a, b) => {
|
|
18
|
+
const aDuration = getChunkDuration(a);
|
|
19
|
+
const bDuration = getChunkDuration(b);
|
|
20
|
+
return aDuration - bDuration;
|
|
21
|
+
});
|
|
22
|
+
durationCache.clear();
|
|
23
|
+
return sortedByDuration;
|
|
24
|
+
};
|
|
25
|
+
exports.sortProfileByDuration = sortProfileByDuration;
|
package/dist/functions/launch.js
CHANGED
|
@@ -66,6 +66,7 @@ const innerLaunchHandler = async (params, options) => {
|
|
|
66
66
|
const startedDate = Date.now();
|
|
67
67
|
let webhookInvoked = false;
|
|
68
68
|
console.log(`Function has ${Math.max(options.getRemainingTimeInMillis() - 1000, 1000)} before it times out`);
|
|
69
|
+
const verbose = renderer_1.RenderInternals.isEqualOrBelowLogLevel(params.logLevel, 'verbose');
|
|
69
70
|
const webhookDueToTimeout = setTimeout(async () => {
|
|
70
71
|
if (params.webhook && !webhookInvoked) {
|
|
71
72
|
try {
|
|
@@ -108,7 +109,7 @@ const innerLaunchHandler = async (params, options) => {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
}, Math.max(options.getRemainingTimeInMillis() - 1000, 1000));
|
|
111
|
-
const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(
|
|
112
|
+
const browserInstance = await (0, get_browser_instance_1.getBrowserInstance)(verbose, params.chromiumOptions);
|
|
112
113
|
const downloadMap = renderer_1.RenderInternals.makeDownloadMap();
|
|
113
114
|
const inputPropsPromise = (0, deserialize_input_props_1.deserializeInputProps)({
|
|
114
115
|
bucketName: params.bucketName,
|
|
@@ -403,12 +404,14 @@ const innerLaunchHandler = async (params, options) => {
|
|
|
403
404
|
chunkCount,
|
|
404
405
|
renderId: params.renderId,
|
|
405
406
|
});
|
|
406
|
-
const deletProm =
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
407
|
+
const deletProm = verbose
|
|
408
|
+
? Promise.resolve(0)
|
|
409
|
+
: (0, delete_chunks_1.cleanupFiles)({
|
|
410
|
+
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
411
|
+
bucket: params.bucketName,
|
|
412
|
+
contents,
|
|
413
|
+
jobs,
|
|
414
|
+
});
|
|
412
415
|
const cleanupSerializedInputPropsProm = (0, cleanup_serialized_input_props_1.cleanupSerializedInputProps)({
|
|
413
416
|
bucketName: params.bucketName,
|
|
414
417
|
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AwsRegion } from '../client';
|
|
2
|
+
import type { LambdaRoutines } from './constants';
|
|
3
|
+
export declare const getCloudwatchStreamUrl: ({ region, functionName, method, renderId, }: {
|
|
4
|
+
region: AwsRegion;
|
|
5
|
+
functionName: string;
|
|
6
|
+
method: LambdaRoutines;
|
|
7
|
+
renderId: string;
|
|
8
|
+
}) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCloudwatchStreamUrl = void 0;
|
|
4
|
+
const getCloudwatchStreamUrl = ({ region, functionName, method, renderId, }) => {
|
|
5
|
+
return `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#logsV2:log-groups/log-group/$252Faws$252Flambda$252F${functionName}/log-events$3FfilterPattern$3D$2522method$253D${method}$252CrenderId$253D${renderId}$2522`;
|
|
6
|
+
};
|
|
7
|
+
exports.getCloudwatchStreamUrl = getCloudwatchStreamUrl;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AwsRegion } from '../client';
|
|
2
|
+
import type { LambdaRoutines } from './constants';
|
|
3
|
+
export declare const getCloudwatchStreamUrl: ({ region, functionName, method, renderId, }: {
|
|
4
|
+
region: AwsRegion;
|
|
5
|
+
functionName: string;
|
|
6
|
+
method: LambdaRoutines;
|
|
7
|
+
renderId: string;
|
|
8
|
+
}) => string;
|
|
9
|
+
export declare const getS3RenderUrl: ({ renderId, region, bucketName, }: {
|
|
10
|
+
renderId: string;
|
|
11
|
+
region: AwsRegion;
|
|
12
|
+
bucketName: string;
|
|
13
|
+
}) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getS3RenderUrl = exports.getCloudwatchStreamUrl = void 0;
|
|
4
|
+
const getCloudwatchStreamUrl = ({ region, functionName, method, renderId, }) => {
|
|
5
|
+
return `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#logsV2:log-groups/log-group/$252Faws$252Flambda$252F${functionName}/log-events$3FfilterPattern$3D$2522method$253D${method}$252CrenderId$253D${renderId}$2522`;
|
|
6
|
+
};
|
|
7
|
+
exports.getCloudwatchStreamUrl = getCloudwatchStreamUrl;
|
|
8
|
+
const getS3RenderUrl = ({ renderId, region, bucketName, }) => {
|
|
9
|
+
return `https://s3.console.aws.amazon.com/s3/buckets/${bucketName}?region=${region}&prefix=renders/${renderId}/`;
|
|
10
|
+
};
|
|
11
|
+
exports.getS3RenderUrl = getS3RenderUrl;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/lambda",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.44",
|
|
4
4
|
"description": "Distributed renderer for Remotion based on AWS Lambda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"@aws-sdk/client-service-quotas": "3.190.0",
|
|
32
32
|
"@aws-sdk/lib-storage": "3.190.0",
|
|
33
33
|
"@aws-sdk/s3-request-presigner": "3.190.0",
|
|
34
|
-
"@remotion/bundler": "3.2.
|
|
35
|
-
"@remotion/cli": "3.2.
|
|
36
|
-
"@remotion/renderer": "3.2.
|
|
34
|
+
"@remotion/bundler": "3.2.44",
|
|
35
|
+
"@remotion/cli": "3.2.44",
|
|
36
|
+
"@remotion/renderer": "3.2.44",
|
|
37
37
|
"aws-policies": "^1.0.1",
|
|
38
38
|
"mime-types": "2.1.34",
|
|
39
|
-
"remotion": "3.2.
|
|
39
|
+
"remotion": "3.2.44"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": ">=16.8.0",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "443b4b387b78905e747ebe69b3b91ee85966796d"
|
|
63
63
|
}
|
package/remotionlambda.zip
CHANGED
|
Binary file
|