@remotion/lambda 4.0.5 → 4.0.7
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/admin/bundle-lambda.js +2 -0
- package/dist/api/get-compositions-on-lambda.js +2 -0
- package/dist/api/get-render-progress.d.ts +2 -2
- package/dist/api/get-render-progress.js +2 -0
- package/dist/api/make-lambda-payload.d.ts +2 -2
- package/dist/api/render-media-on-lambda.js +4 -2
- package/dist/api/render-still-on-lambda.d.ts +5 -1
- package/dist/api/render-still-on-lambda.js +18 -3
- package/dist/cli/commands/render/render.js +1 -1
- package/dist/cli/commands/still.js +38 -50
- package/dist/cli/index.js +16 -2
- package/dist/cli/log.d.ts +9 -3
- package/dist/client.d.ts +4 -1
- package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +1 -4
- package/dist/functions/compositions.d.ts +1 -0
- package/dist/functions/compositions.js +2 -1
- package/dist/functions/helpers/get-current-region.d.ts +1 -1
- package/dist/functions/helpers/get-progress.js +8 -1
- package/dist/functions/helpers/make-timeout-error.d.ts +2 -1
- package/dist/functions/helpers/make-timeout-error.js +7 -6
- package/dist/functions/helpers/make-timeout-message.d.ts +2 -1
- package/dist/functions/helpers/make-timeout-message.js +53 -16
- package/dist/functions/helpers/streamify-response.js +15 -12
- package/dist/functions/helpers/streaming-payloads.d.ts +19 -0
- package/dist/functions/helpers/streaming-payloads.js +25 -0
- package/dist/functions/index.js +44 -5
- package/dist/functions/info.d.ts +1 -0
- package/dist/functions/info.js +1 -0
- package/dist/functions/launch.d.ts +3 -1
- package/dist/functions/launch.js +7 -4
- package/dist/functions/renderer.d.ts +3 -1
- package/dist/functions/renderer.js +26 -10
- package/dist/functions/start.d.ts +1 -0
- package/dist/functions/start.js +2 -1
- package/dist/functions/still.d.ts +8 -5
- package/dist/functions/still.js +51 -54
- package/dist/index.d.ts +3 -3
- package/dist/internals.d.ts +1 -1
- package/dist/shared/aws-clients.d.ts +1 -1
- package/dist/shared/aws-clients.js +3 -1
- package/dist/shared/call-lambda.d.ts +4 -1
- package/dist/shared/call-lambda.js +30 -13
- package/dist/shared/compress-props.js +1 -1
- package/dist/shared/constants.d.ts +1 -0
- package/dist/shared/encode-aws-url-params.d.ts +1 -0
- package/dist/shared/encode-aws-url-params.js +7 -0
- package/dist/shared/get-aws-urls.d.ts +9 -2
- package/dist/shared/get-aws-urls.js +15 -4
- package/dist/shared/get-function-version.js +2 -0
- package/dist/shared/invoke-webhook.d.ts +2 -0
- package/dist/shared/return-values.d.ts +5 -5
- package/package.json +20 -19
- package/remotionlambda-arm64.zip +0 -0
- package/remotionlambda-x64.zip +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ResponseStream } from './streamify-response';
|
|
3
|
+
declare const streamingPayloadSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"render-id-determined">;
|
|
5
|
+
renderId: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
renderId: string;
|
|
8
|
+
type: "render-id-determined";
|
|
9
|
+
}, {
|
|
10
|
+
renderId: string;
|
|
11
|
+
type: "render-id-determined";
|
|
12
|
+
}>]>;
|
|
13
|
+
export type StreamingPayloads = z.infer<typeof streamingPayloadSchema>;
|
|
14
|
+
export declare const isStreamingPayload: (str: string) => false | {
|
|
15
|
+
renderId: string;
|
|
16
|
+
type: "render-id-determined";
|
|
17
|
+
};
|
|
18
|
+
export declare const sendProgressEvent: (responseStream: ResponseStream, payload: StreamingPayloads) => void;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendProgressEvent = exports.isStreamingPayload = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const streamingPayloadSchema = zod_1.z.discriminatedUnion('type', [
|
|
6
|
+
zod_1.z.object({
|
|
7
|
+
type: zod_1.z.literal('render-id-determined'),
|
|
8
|
+
renderId: zod_1.z.string(),
|
|
9
|
+
}),
|
|
10
|
+
]);
|
|
11
|
+
const isStreamingPayload = (str) => {
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(str);
|
|
14
|
+
return streamingPayloadSchema.parse(parsed);
|
|
15
|
+
}
|
|
16
|
+
catch (_a) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.isStreamingPayload = isStreamingPayload;
|
|
21
|
+
const sendProgressEvent = (responseStream, payload) => {
|
|
22
|
+
const stringified = JSON.stringify(payload);
|
|
23
|
+
responseStream.write(stringified);
|
|
24
|
+
};
|
|
25
|
+
exports.sendProgressEvent = sendProgressEvent;
|
package/dist/functions/index.js
CHANGED
|
@@ -3,18 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.handler = void 0;
|
|
4
4
|
const renderer_1 = require("@remotion/renderer");
|
|
5
5
|
const constants_1 = require("../shared/constants");
|
|
6
|
+
const random_hash_1 = require("../shared/random-hash");
|
|
6
7
|
const compositions_1 = require("./compositions");
|
|
7
8
|
const clean_tmpdir_1 = require("./helpers/clean-tmpdir");
|
|
8
9
|
const is_warm_1 = require("./helpers/is-warm");
|
|
9
10
|
const print_cloudwatch_helper_1 = require("./helpers/print-cloudwatch-helper");
|
|
10
11
|
const streamify_response_1 = require("./helpers/streamify-response");
|
|
12
|
+
const streaming_payloads_1 = require("./helpers/streaming-payloads");
|
|
11
13
|
const info_1 = require("./info");
|
|
12
14
|
const launch_1 = require("./launch");
|
|
13
15
|
const progress_1 = require("./progress");
|
|
14
16
|
const renderer_2 = require("./renderer");
|
|
15
17
|
const start_1 = require("./start");
|
|
16
18
|
const still_1 = require("./still");
|
|
17
|
-
|
|
19
|
+
const innerHandler = async (params, responseStream, context) => {
|
|
18
20
|
process.env.__RESERVED_IS_INSIDE_REMOTION_LAMBDA = 'true';
|
|
19
21
|
const timeoutInMilliseconds = context.getRemainingTimeInMillis();
|
|
20
22
|
if (!(context === null || context === void 0 ? void 0 : context.invokedFunctionArn)) {
|
|
@@ -25,12 +27,22 @@ exports.handler = (0, streamify_response_1.streamifyResponse)(async (params, res
|
|
|
25
27
|
(0, is_warm_1.setWarm)();
|
|
26
28
|
const currentUserId = context.invokedFunctionArn.split(':')[4];
|
|
27
29
|
if (params.type === constants_1.LambdaRoutines.still) {
|
|
30
|
+
const renderId = (0, random_hash_1.randomHash)({ randomInTests: true });
|
|
28
31
|
(0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.still, {
|
|
32
|
+
renderId,
|
|
29
33
|
inputProps: JSON.stringify(params.inputProps),
|
|
30
34
|
isWarm,
|
|
31
35
|
});
|
|
32
|
-
|
|
36
|
+
renderer_1.RenderInternals.setLogLevel(params.logLevel);
|
|
37
|
+
const renderIdDetermined = {
|
|
38
|
+
type: 'render-id-determined',
|
|
39
|
+
renderId,
|
|
40
|
+
};
|
|
41
|
+
(0, streaming_payloads_1.sendProgressEvent)(responseStream, renderIdDetermined);
|
|
42
|
+
const response = await (0, still_1.stillHandler)({
|
|
33
43
|
expectedBucketOwner: currentUserId,
|
|
44
|
+
params,
|
|
45
|
+
renderId,
|
|
34
46
|
});
|
|
35
47
|
responseStream.write(JSON.stringify(response));
|
|
36
48
|
responseStream.end();
|
|
@@ -41,6 +53,7 @@ exports.handler = (0, streamify_response_1.streamifyResponse)(async (params, res
|
|
|
41
53
|
inputProps: JSON.stringify(params.inputProps),
|
|
42
54
|
isWarm,
|
|
43
55
|
});
|
|
56
|
+
renderer_1.RenderInternals.setLogLevel(params.logLevel);
|
|
44
57
|
const response = await (0, start_1.startHandler)(params, {
|
|
45
58
|
expectedBucketOwner: currentUserId,
|
|
46
59
|
});
|
|
@@ -54,10 +67,12 @@ exports.handler = (0, streamify_response_1.streamifyResponse)(async (params, res
|
|
|
54
67
|
inputProps: JSON.stringify(params.inputProps),
|
|
55
68
|
isWarm,
|
|
56
69
|
});
|
|
57
|
-
|
|
70
|
+
renderer_1.RenderInternals.setLogLevel(params.logLevel);
|
|
71
|
+
const response = await (0, launch_1.launchHandler)(params, {
|
|
58
72
|
expectedBucketOwner: currentUserId,
|
|
59
73
|
getRemainingTimeInMillis: context.getRemainingTimeInMillis,
|
|
60
74
|
});
|
|
75
|
+
responseStream.write(JSON.stringify(response));
|
|
61
76
|
responseStream.end();
|
|
62
77
|
return;
|
|
63
78
|
}
|
|
@@ -82,10 +97,12 @@ exports.handler = (0, streamify_response_1.streamifyResponse)(async (params, res
|
|
|
82
97
|
resolvedProps: JSON.stringify(params.resolvedProps),
|
|
83
98
|
isWarm,
|
|
84
99
|
});
|
|
85
|
-
|
|
100
|
+
renderer_1.RenderInternals.setLogLevel(params.logLevel);
|
|
101
|
+
const response = await (0, renderer_2.rendererHandler)(params, {
|
|
86
102
|
expectedBucketOwner: currentUserId,
|
|
87
103
|
isWarm,
|
|
88
104
|
});
|
|
105
|
+
responseStream.write(JSON.stringify(response));
|
|
89
106
|
responseStream.end();
|
|
90
107
|
return;
|
|
91
108
|
}
|
|
@@ -110,4 +127,26 @@ exports.handler = (0, streamify_response_1.streamifyResponse)(async (params, res
|
|
|
110
127
|
return;
|
|
111
128
|
}
|
|
112
129
|
throw new Error(constants_1.COMMAND_NOT_FOUND);
|
|
113
|
-
}
|
|
130
|
+
};
|
|
131
|
+
const routine = async (params, responseStream, context) => {
|
|
132
|
+
try {
|
|
133
|
+
await innerHandler(params, responseStream, context);
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
const res = {
|
|
137
|
+
type: 'error',
|
|
138
|
+
message: err.message,
|
|
139
|
+
stack: err.stack,
|
|
140
|
+
};
|
|
141
|
+
responseStream.write(JSON.stringify(res));
|
|
142
|
+
responseStream.end();
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
responseStream.on('close', () => {
|
|
146
|
+
if (!process.env.VITEST) {
|
|
147
|
+
process.exit(0);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
exports.handler = (0, streamify_response_1.streamifyResponse)(routine);
|
package/dist/functions/info.d.ts
CHANGED
package/dist/functions/info.js
CHANGED
|
@@ -3,5 +3,7 @@ type Options = {
|
|
|
3
3
|
expectedBucketOwner: string;
|
|
4
4
|
getRemainingTimeInMillis: () => number;
|
|
5
5
|
};
|
|
6
|
-
export declare const launchHandler: (params: LambdaPayload, options: Options) => Promise<
|
|
6
|
+
export declare const launchHandler: (params: LambdaPayload, options: Options) => Promise<{
|
|
7
|
+
type: 'success';
|
|
8
|
+
}>;
|
|
7
9
|
export {};
|
package/dist/functions/launch.js
CHANGED
|
@@ -32,6 +32,7 @@ const remotion_1 = require("remotion");
|
|
|
32
32
|
const version_1 = require("remotion/version");
|
|
33
33
|
const aws_clients_1 = require("../shared/aws-clients");
|
|
34
34
|
const cleanup_serialized_input_props_1 = require("../shared/cleanup-serialized-input-props");
|
|
35
|
+
const compress_props_1 = require("../shared/compress-props");
|
|
35
36
|
const constants_1 = require("../shared/constants");
|
|
36
37
|
const docs_url_1 = require("../shared/docs-url");
|
|
37
38
|
const invoke_webhook_1 = require("../shared/invoke-webhook");
|
|
@@ -56,15 +57,13 @@ const timer_1 = require("./helpers/timer");
|
|
|
56
57
|
const validate_composition_1 = require("./helpers/validate-composition");
|
|
57
58
|
const write_lambda_error_1 = require("./helpers/write-lambda-error");
|
|
58
59
|
const write_post_render_data_1 = require("./helpers/write-post-render-data");
|
|
59
|
-
const compress_props_1 = require("../shared/compress-props");
|
|
60
60
|
const callFunctionWithRetry = async ({ payload, retries, functionName, }) => {
|
|
61
61
|
try {
|
|
62
62
|
await (0, aws_clients_1.getLambdaClient)((0, get_current_region_1.getCurrentRegionInFunction)()).send(new client_lambda_1.InvokeCommand({
|
|
63
|
-
FunctionName:
|
|
64
|
-
// @ts-expect-error
|
|
63
|
+
FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
|
|
65
64
|
Payload: JSON.stringify(payload),
|
|
66
65
|
InvocationType: 'Event',
|
|
67
|
-
})
|
|
66
|
+
}));
|
|
68
67
|
}
|
|
69
68
|
catch (err) {
|
|
70
69
|
if (err.name === 'ResourceConflictException') {
|
|
@@ -537,6 +536,9 @@ const launchHandler = async (params, options) => {
|
|
|
537
536
|
}
|
|
538
537
|
try {
|
|
539
538
|
await innerLaunchHandler(params, options);
|
|
539
|
+
return {
|
|
540
|
+
type: 'success',
|
|
541
|
+
};
|
|
540
542
|
}
|
|
541
543
|
catch (err) {
|
|
542
544
|
if (process.env.NODE_ENV === 'test') {
|
|
@@ -605,6 +607,7 @@ const launchHandler = async (params, options) => {
|
|
|
605
607
|
console.log(error);
|
|
606
608
|
}
|
|
607
609
|
}
|
|
610
|
+
throw err;
|
|
608
611
|
}
|
|
609
612
|
};
|
|
610
613
|
exports.launchHandler = launchHandler;
|
|
@@ -3,5 +3,7 @@ type Options = {
|
|
|
3
3
|
expectedBucketOwner: string;
|
|
4
4
|
isWarm: boolean;
|
|
5
5
|
};
|
|
6
|
-
export declare const rendererHandler: (params: LambdaPayload, options: Options) => Promise<
|
|
6
|
+
export declare const rendererHandler: (params: LambdaPayload, options: Options) => Promise<{
|
|
7
|
+
type: 'success';
|
|
8
|
+
}>;
|
|
7
9
|
export {};
|
|
@@ -4,20 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.rendererHandler = void 0;
|
|
7
|
-
const client_lambda_1 = require("@aws-sdk/client-lambda");
|
|
8
7
|
const renderer_1 = require("@remotion/renderer");
|
|
9
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
10
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
11
10
|
const version_1 = require("remotion/version");
|
|
12
|
-
const
|
|
11
|
+
const call_lambda_1 = require("../shared/call-lambda");
|
|
13
12
|
const chunk_progress_1 = require("../shared/chunk-progress");
|
|
13
|
+
const compress_props_1 = require("../shared/compress-props");
|
|
14
14
|
const constants_1 = require("../shared/constants");
|
|
15
15
|
const get_browser_instance_1 = require("./helpers/get-browser-instance");
|
|
16
16
|
const get_chromium_executable_path_1 = require("./helpers/get-chromium-executable-path");
|
|
17
17
|
const get_current_region_1 = require("./helpers/get-current-region");
|
|
18
18
|
const io_1 = require("./helpers/io");
|
|
19
19
|
const write_lambda_error_1 = require("./helpers/write-lambda-error");
|
|
20
|
-
const compress_props_1 = require("../shared/compress-props");
|
|
21
20
|
const renderHandler = async (params, options, logs) => {
|
|
22
21
|
var _a;
|
|
23
22
|
if (params.type !== constants_1.LambdaRoutines.renderer) {
|
|
@@ -90,7 +89,10 @@ const renderHandler = async (params, options, logs) => {
|
|
|
90
89
|
expectedBucketOwner: options.expectedBucketOwner,
|
|
91
90
|
framesRendered: renderedFrames,
|
|
92
91
|
renderId: params.renderId,
|
|
93
|
-
}).catch((err) =>
|
|
92
|
+
}).catch((err) => {
|
|
93
|
+
console.log(err);
|
|
94
|
+
return reject(err);
|
|
95
|
+
});
|
|
94
96
|
}
|
|
95
97
|
const allFrames = renderer_1.RenderInternals.getFramesToRender(params.frameRange, params.everyNthFrame);
|
|
96
98
|
if (renderedFrames === allFrames.length) {
|
|
@@ -182,6 +184,8 @@ const renderHandler = async (params, options, logs) => {
|
|
|
182
184
|
...chunkTimingData,
|
|
183
185
|
timings: Object.values(chunkTimingData.timings),
|
|
184
186
|
};
|
|
187
|
+
renderer_1.RenderInternals.Log.verbose('Writing chunk to S3');
|
|
188
|
+
const writeStart = Date.now();
|
|
185
189
|
await (0, io_1.lambdaWriteFile)({
|
|
186
190
|
bucketName: params.bucketName,
|
|
187
191
|
key: (0, constants_1.chunkKeyForIndex)({
|
|
@@ -195,6 +199,10 @@ const renderHandler = async (params, options, logs) => {
|
|
|
195
199
|
downloadBehavior: null,
|
|
196
200
|
customCredentials: null,
|
|
197
201
|
});
|
|
202
|
+
renderer_1.RenderInternals.Log.verbose('Wrote chunk to S3', {
|
|
203
|
+
time: Date.now() - writeStart,
|
|
204
|
+
});
|
|
205
|
+
renderer_1.RenderInternals.Log.verbose('Cleaning up and writing timings');
|
|
198
206
|
await Promise.all([
|
|
199
207
|
node_fs_1.default.promises.rm(outputLocation, { recursive: true }),
|
|
200
208
|
node_fs_1.default.promises.rm(outputPath, { recursive: true }),
|
|
@@ -214,6 +222,7 @@ const renderHandler = async (params, options, logs) => {
|
|
|
214
222
|
customCredentials: null,
|
|
215
223
|
}),
|
|
216
224
|
]);
|
|
225
|
+
return {};
|
|
217
226
|
};
|
|
218
227
|
const rendererHandler = async (params, options) => {
|
|
219
228
|
if (params.type !== constants_1.LambdaRoutines.renderer) {
|
|
@@ -222,6 +231,9 @@ const rendererHandler = async (params, options) => {
|
|
|
222
231
|
const logs = [];
|
|
223
232
|
try {
|
|
224
233
|
await renderHandler(params, options, logs);
|
|
234
|
+
return {
|
|
235
|
+
type: 'success',
|
|
236
|
+
};
|
|
225
237
|
}
|
|
226
238
|
catch (err) {
|
|
227
239
|
if (process.env.NODE_ENV === 'test') {
|
|
@@ -260,13 +272,17 @@ const rendererHandler = async (params, options) => {
|
|
|
260
272
|
retriesLeft: params.retriesLeft - 1,
|
|
261
273
|
attempt: params.attempt + 1,
|
|
262
274
|
};
|
|
263
|
-
await (0,
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
275
|
+
const res = await (0, call_lambda_1.callLambda)({
|
|
276
|
+
functionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
|
|
277
|
+
payload: retryPayload,
|
|
278
|
+
type: constants_1.LambdaRoutines.renderer,
|
|
279
|
+
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
280
|
+
receivedStreamingPayload: () => undefined,
|
|
281
|
+
timeoutInTest: 120000,
|
|
282
|
+
});
|
|
283
|
+
return res;
|
|
269
284
|
}
|
|
285
|
+
throw err;
|
|
270
286
|
}
|
|
271
287
|
};
|
|
272
288
|
exports.rendererHandler = rendererHandler;
|
package/dist/functions/start.js
CHANGED
|
@@ -78,14 +78,15 @@ const startHandler = async (params, options) => {
|
|
|
78
78
|
rendererFunctionName: params.rendererFunctionName,
|
|
79
79
|
audioCodec: params.audioCodec,
|
|
80
80
|
};
|
|
81
|
+
// Don't replace with callLambda(), we want to return before the render is snone
|
|
81
82
|
await (0, aws_clients_1.getLambdaClient)((0, get_current_region_1.getCurrentRegionInFunction)()).send(new client_lambda_1.InvokeCommand({
|
|
82
83
|
FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
|
|
83
|
-
// @ts-expect-error
|
|
84
84
|
Payload: JSON.stringify(payload),
|
|
85
85
|
InvocationType: 'Event',
|
|
86
86
|
}));
|
|
87
87
|
await initialFile;
|
|
88
88
|
return {
|
|
89
|
+
type: 'success',
|
|
89
90
|
bucketName,
|
|
90
91
|
renderId,
|
|
91
92
|
};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import type { LambdaPayload } from '../shared/constants';
|
|
1
|
+
import type { CostsInfo, LambdaPayload } from '../shared/constants';
|
|
2
2
|
type Options = {
|
|
3
|
+
params: LambdaPayload;
|
|
4
|
+
renderId: string;
|
|
3
5
|
expectedBucketOwner: string;
|
|
4
6
|
};
|
|
5
|
-
|
|
7
|
+
type RenderStillLambdaResponsePayload = {
|
|
8
|
+
type: 'success';
|
|
6
9
|
output: string;
|
|
7
10
|
size: number;
|
|
8
11
|
bucketName: string;
|
|
9
|
-
estimatedPrice:
|
|
12
|
+
estimatedPrice: CostsInfo;
|
|
10
13
|
renderId: string;
|
|
11
|
-
}
|
|
12
|
-
export declare const stillHandler: (
|
|
14
|
+
};
|
|
15
|
+
export declare const stillHandler: (options: Options) => Promise<RenderStillLambdaResponsePayload>;
|
|
13
16
|
export {};
|
package/dist/functions/still.js
CHANGED
|
@@ -4,19 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.stillHandler = void 0;
|
|
7
|
-
const client_lambda_1 = require("@aws-sdk/client-lambda");
|
|
8
7
|
const renderer_1 = require("@remotion/renderer");
|
|
9
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
10
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const remotion_1 = require("remotion");
|
|
11
11
|
const version_1 = require("remotion/version");
|
|
12
12
|
const estimate_price_1 = require("../api/estimate-price");
|
|
13
13
|
const get_or_create_bucket_1 = require("../api/get-or-create-bucket");
|
|
14
|
-
const
|
|
14
|
+
const call_lambda_1 = require("../shared/call-lambda");
|
|
15
15
|
const cleanup_serialized_input_props_1 = require("../shared/cleanup-serialized-input-props");
|
|
16
|
+
const compress_props_1 = require("../shared/compress-props");
|
|
16
17
|
const constants_1 = require("../shared/constants");
|
|
17
18
|
const convert_to_serve_url_1 = require("../shared/convert-to-serve-url");
|
|
18
19
|
const make_s3_url_1 = require("../shared/make-s3-url");
|
|
19
|
-
const random_hash_1 = require("../shared/random-hash");
|
|
20
20
|
const validate_download_behavior_1 = require("../shared/validate-download-behavior");
|
|
21
21
|
const validate_outname_1 = require("../shared/validate-outname");
|
|
22
22
|
const validate_privacy_1 = require("../shared/validate-privacy");
|
|
@@ -29,9 +29,7 @@ const get_output_url_from_metadata_1 = require("./helpers/get-output-url-from-me
|
|
|
29
29
|
const io_1 = require("./helpers/io");
|
|
30
30
|
const validate_composition_1 = require("./helpers/validate-composition");
|
|
31
31
|
const write_lambda_error_1 = require("./helpers/write-lambda-error");
|
|
32
|
-
const
|
|
33
|
-
const remotion_1 = require("remotion");
|
|
34
|
-
const innerStillHandler = async (lambdaParams, renderId, options) => {
|
|
32
|
+
const innerStillHandler = async ({ params: lambdaParams, expectedBucketOwner, renderId, }) => {
|
|
35
33
|
var _a, _b, _c, _d, _e, _f;
|
|
36
34
|
if (lambdaParams.type !== constants_1.LambdaRoutines.still) {
|
|
37
35
|
throw new TypeError('Expected still type');
|
|
@@ -57,7 +55,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
|
|
|
57
55
|
const region = (0, get_current_region_1.getCurrentRegionInFunction)();
|
|
58
56
|
const serializedInputPropsWithCustomSchema = await (0, compress_props_1.decompressInputProps)({
|
|
59
57
|
bucketName,
|
|
60
|
-
expectedBucketOwner
|
|
58
|
+
expectedBucketOwner,
|
|
61
59
|
region,
|
|
62
60
|
serialized: lambdaParams.inputProps,
|
|
63
61
|
propsType: 'input-props',
|
|
@@ -118,7 +116,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
|
|
|
118
116
|
body: JSON.stringify(renderMetadata),
|
|
119
117
|
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
120
118
|
privacy: 'private',
|
|
121
|
-
expectedBucketOwner
|
|
119
|
+
expectedBucketOwner,
|
|
122
120
|
downloadBehavior: null,
|
|
123
121
|
customCredentials: null,
|
|
124
122
|
});
|
|
@@ -132,11 +130,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
|
|
|
132
130
|
durationInFrames: composition.durationInFrames,
|
|
133
131
|
}),
|
|
134
132
|
imageFormat: lambdaParams.imageFormat,
|
|
135
|
-
serializedInputPropsWithCustomSchema
|
|
136
|
-
data: lambdaParams.inputProps,
|
|
137
|
-
indent: undefined,
|
|
138
|
-
staticBase: null,
|
|
139
|
-
}).serializedString,
|
|
133
|
+
serializedInputPropsWithCustomSchema,
|
|
140
134
|
overwrite: false,
|
|
141
135
|
puppeteerInstance: browserInstance,
|
|
142
136
|
jpegQuality: (_f = lambdaParams.jpegQuality) !== null && _f !== void 0 ? _f : renderer_1.RenderInternals.DEFAULT_JPEG_QUALITY,
|
|
@@ -164,7 +158,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
|
|
|
164
158
|
key,
|
|
165
159
|
privacy: lambdaParams.privacy,
|
|
166
160
|
body: node_fs_1.default.createReadStream(outputPath),
|
|
167
|
-
expectedBucketOwner
|
|
161
|
+
expectedBucketOwner,
|
|
168
162
|
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
169
163
|
downloadBehavior: lambdaParams.downloadBehavior,
|
|
170
164
|
customCredentials,
|
|
@@ -188,6 +182,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
|
|
|
188
182
|
diskSizeInMb: constants_1.MAX_EPHEMERAL_STORAGE_IN_MB,
|
|
189
183
|
});
|
|
190
184
|
return {
|
|
185
|
+
type: 'success',
|
|
191
186
|
output: (0, get_output_url_from_metadata_1.getOutputUrlFromMetadata)(renderMetadata, bucketName, customCredentials),
|
|
192
187
|
size,
|
|
193
188
|
bucketName,
|
|
@@ -195,14 +190,14 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
|
|
|
195
190
|
renderId,
|
|
196
191
|
};
|
|
197
192
|
};
|
|
198
|
-
const stillHandler = async (
|
|
193
|
+
const stillHandler = async (options) => {
|
|
199
194
|
var _a;
|
|
195
|
+
const { params } = options;
|
|
200
196
|
if (params.type !== constants_1.LambdaRoutines.still) {
|
|
201
197
|
throw new Error('Params must be renderer');
|
|
202
198
|
}
|
|
203
|
-
const renderId = (0, random_hash_1.randomHash)({ randomInTests: true });
|
|
204
199
|
try {
|
|
205
|
-
return innerStillHandler(
|
|
200
|
+
return await innerStillHandler(options);
|
|
206
201
|
}
|
|
207
202
|
catch (err) {
|
|
208
203
|
// If this error is encountered, we can just retry as it
|
|
@@ -210,44 +205,46 @@ const stillHandler = async (params, options) => {
|
|
|
210
205
|
const isBrowserError = err.message.includes('FATAL:zygote_communication_linux.cc') ||
|
|
211
206
|
err.message.includes('error while loading shared libraries: libnss3.so');
|
|
212
207
|
const willRetry = isBrowserError || params.maxRetries > 0;
|
|
213
|
-
if (willRetry) {
|
|
214
|
-
|
|
215
|
-
...params,
|
|
216
|
-
maxRetries: params.maxRetries - 1,
|
|
217
|
-
attempt: params.attempt + 1,
|
|
218
|
-
};
|
|
219
|
-
const res = await (0, aws_clients_1.getLambdaClient)((0, get_current_region_1.getCurrentRegionInFunction)()).send(new client_lambda_1.InvokeCommand({
|
|
220
|
-
FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
|
|
221
|
-
// @ts-expect-error
|
|
222
|
-
Payload: JSON.stringify(retryPayload),
|
|
223
|
-
}));
|
|
224
|
-
const bucketName = (_a = params.bucketName) !== null && _a !== void 0 ? _a : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
|
|
225
|
-
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
226
|
-
})).bucketName;
|
|
227
|
-
// `await` elided on purpose here; using `void` to mark it as intentional
|
|
228
|
-
// eslint-disable-next-line no-void
|
|
229
|
-
void (0, write_lambda_error_1.writeLambdaError)({
|
|
230
|
-
bucketName,
|
|
231
|
-
errorInfo: {
|
|
232
|
-
chunk: null,
|
|
233
|
-
frame: null,
|
|
234
|
-
isFatal: false,
|
|
235
|
-
name: err.name,
|
|
236
|
-
message: err.message,
|
|
237
|
-
stack: err.stack,
|
|
238
|
-
type: 'browser',
|
|
239
|
-
tmpDir: (0, write_lambda_error_1.getTmpDirStateIfENoSp)(err.stack),
|
|
240
|
-
attempt: params.attempt,
|
|
241
|
-
totalAttempts: params.attempt + params.maxRetries,
|
|
242
|
-
willRetry,
|
|
243
|
-
},
|
|
244
|
-
expectedBucketOwner: options.expectedBucketOwner,
|
|
245
|
-
renderId,
|
|
246
|
-
});
|
|
247
|
-
const str = JSON.parse(Buffer.from(res.Payload).toString());
|
|
248
|
-
return str;
|
|
208
|
+
if (!willRetry) {
|
|
209
|
+
throw err;
|
|
249
210
|
}
|
|
250
|
-
|
|
211
|
+
const retryPayload = {
|
|
212
|
+
...params,
|
|
213
|
+
maxRetries: params.maxRetries - 1,
|
|
214
|
+
attempt: params.attempt + 1,
|
|
215
|
+
};
|
|
216
|
+
const res = await (0, call_lambda_1.callLambda)({
|
|
217
|
+
functionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
|
|
218
|
+
payload: retryPayload,
|
|
219
|
+
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
220
|
+
type: constants_1.LambdaRoutines.still,
|
|
221
|
+
receivedStreamingPayload: () => undefined,
|
|
222
|
+
timeoutInTest: 120000,
|
|
223
|
+
});
|
|
224
|
+
const bucketName = (_a = params.bucketName) !== null && _a !== void 0 ? _a : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
|
|
225
|
+
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
226
|
+
})).bucketName;
|
|
227
|
+
// `await` elided on purpose here; using `void` to mark it as intentional
|
|
228
|
+
// eslint-disable-next-line no-void
|
|
229
|
+
void (0, write_lambda_error_1.writeLambdaError)({
|
|
230
|
+
bucketName,
|
|
231
|
+
errorInfo: {
|
|
232
|
+
chunk: null,
|
|
233
|
+
frame: null,
|
|
234
|
+
isFatal: false,
|
|
235
|
+
name: err.name,
|
|
236
|
+
message: err.message,
|
|
237
|
+
stack: err.stack,
|
|
238
|
+
type: 'browser',
|
|
239
|
+
tmpDir: (0, write_lambda_error_1.getTmpDirStateIfENoSp)(err.stack),
|
|
240
|
+
attempt: params.attempt,
|
|
241
|
+
totalAttempts: params.attempt + params.maxRetries,
|
|
242
|
+
willRetry,
|
|
243
|
+
},
|
|
244
|
+
expectedBucketOwner: options.expectedBucketOwner,
|
|
245
|
+
renderId: options.renderId,
|
|
246
|
+
});
|
|
247
|
+
return res;
|
|
251
248
|
}
|
|
252
249
|
};
|
|
253
250
|
exports.stillHandler = stillHandler;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { getFunctions } from './api/get-functions';
|
|
|
23
23
|
import type { GetOrCreateBucketInput, GetOrCreateBucketOutput } from './api/get-or-create-bucket';
|
|
24
24
|
import { getOrCreateBucket } from './api/get-or-create-bucket';
|
|
25
25
|
import { getRegions } from './api/get-regions';
|
|
26
|
-
import type {
|
|
26
|
+
import type { GetRenderProgressInput } from './api/get-render-progress';
|
|
27
27
|
import { getRenderProgress } from './api/get-render-progress';
|
|
28
28
|
import type { GetSitesInput, GetSitesOutput } from './api/get-sites';
|
|
29
29
|
import type { SimulatePermissionsInput, SimulatePermissionsOutput } from './api/iam-validation/simulate';
|
|
@@ -47,7 +47,7 @@ declare const renderMediaOnLambda: (input: RenderMediaOnLambdaInput) => Promise<
|
|
|
47
47
|
/**
|
|
48
48
|
* @deprecated Import this from `@remotion/lambda/client` instead
|
|
49
49
|
*/
|
|
50
|
-
declare const renderStillOnLambda: ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, }: RenderStillOnLambdaInput) => Promise<RenderStillOnLambdaOutput>;
|
|
50
|
+
declare const renderStillOnLambda: ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, onInit, }: RenderStillOnLambdaInput) => Promise<RenderStillOnLambdaOutput>;
|
|
51
51
|
/**
|
|
52
52
|
* @deprecated Import this from `@remotion/lambda/client` instead
|
|
53
53
|
*/
|
|
@@ -57,4 +57,4 @@ declare const presignUrl: <CheckIfObjectExists extends boolean = false>({ region
|
|
|
57
57
|
*/
|
|
58
58
|
declare const getSites: ({ region, forceBucketName, }: GetSitesInput) => Promise<GetSitesOutput>;
|
|
59
59
|
export { deleteSite, deployFunction, deploySite, downloadMedia, getFunctions, getUserPolicy, getRolePolicy, getSites, getOrCreateBucket, getRenderProgress, renderVideoOnLambda, renderMediaOnLambda, simulatePermissions, deleteFunction, getFunctionInfo, estimatePrice, LambdaInternals, renderStillOnLambda, getRegions, getAwsClient, presignUrl, deleteRender, validateWebhookSignature, getCompositionsOnLambda, };
|
|
60
|
-
export type { AwsRegion, RenderProgress, DeploySiteInput, DeploySiteOutput, LambdaLsReturnType, LambdaLSInput, DeleteSiteInput, DeleteSiteOutput, EstimatePriceInput, DeployFunctionInput, DeployFunctionOutput, DeleteFunctionInput, GetFunctionInfoInput, FunctionInfo, GetFunctionsInput, GetSitesInput, GetSitesOutput, DownloadMediaInput, DownloadMediaOutput, GetOrCreateBucketInput, GetOrCreateBucketOutput,
|
|
60
|
+
export type { AwsRegion, RenderProgress, DeploySiteInput, DeploySiteOutput, LambdaLsReturnType, LambdaLSInput, DeleteSiteInput, DeleteSiteOutput, EstimatePriceInput, DeployFunctionInput, DeployFunctionOutput, DeleteFunctionInput, GetFunctionInfoInput, FunctionInfo, GetFunctionsInput, GetSitesInput, GetSitesOutput, DownloadMediaInput, DownloadMediaOutput, GetOrCreateBucketInput, GetOrCreateBucketOutput, GetRenderProgressInput, RenderMediaOnLambdaInput, RenderMediaOnLambdaOutput, RenderStillOnLambdaInput, RenderStillOnLambdaOutput, SimulatePermissionsInput, SimulatePermissionsOutput, GetAwsClientInput, GetAwsClientOutput, CustomCredentials, WebhookPayload, LambdaErrorInfo, EnhancedErrorInfo, DeleteRenderInput, GetCompositionsOnLambdaOutput, GetCompositionsOnLambdaInput, };
|
package/dist/internals.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const LambdaInternals: {
|
|
2
2
|
executeCommand: (args: string[], remotionRoot: string) => Promise<void>;
|
|
3
3
|
makeLambdaRenderMediaPayload: ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, downloadBehavior, muted, overwrite, dumpBrowserLogs, jpegQuality, quality, }: import(".").RenderMediaOnLambdaInput) => Promise<import("./defaults").LambdaStartPayload>;
|
|
4
|
-
getRenderProgressPayload: ({ bucketName, renderId, s3OutputProvider, }: import(".").
|
|
4
|
+
getRenderProgressPayload: ({ bucketName, renderId, s3OutputProvider, }: import(".").GetRenderProgressInput) => import("./defaults").LambdaStatusPayload;
|
|
5
5
|
};
|
|
@@ -27,7 +27,7 @@ export declare const getServiceClient: <T extends keyof ServiceMapping>({ region
|
|
|
27
27
|
}) => ServiceMapping[T];
|
|
28
28
|
export declare const getCloudWatchLogsClient: (region: AwsRegion) => CloudWatchLogsClient;
|
|
29
29
|
export declare const getS3Client: (region: AwsRegion, customCredentials: CustomCredentials | null) => S3Client;
|
|
30
|
-
export declare const getLambdaClient: (region: AwsRegion) => LambdaClient;
|
|
30
|
+
export declare const getLambdaClient: (region: AwsRegion, _timeoutInTest?: number) => LambdaClient;
|
|
31
31
|
export declare const getIamClient: (region: AwsRegion) => IAMClient;
|
|
32
32
|
export declare const getServiceQuotasClient: (region: AwsRegion) => ServiceQuotasClient;
|
|
33
33
|
export declare const getStsClient: (region: AwsRegion) => STSClient;
|
|
@@ -157,7 +157,9 @@ const getS3Client = (region, customCredentials) => {
|
|
|
157
157
|
return (0, exports.getServiceClient)({ region, service: 's3', customCredentials });
|
|
158
158
|
};
|
|
159
159
|
exports.getS3Client = getS3Client;
|
|
160
|
-
const getLambdaClient = (region
|
|
160
|
+
const getLambdaClient = (region,
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
162
|
+
_timeoutInTest) => {
|
|
161
163
|
return (0, exports.getServiceClient)({
|
|
162
164
|
region,
|
|
163
165
|
service: 'lambda',
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import type { StreamingPayloads } from '../functions/helpers/streaming-payloads';
|
|
1
2
|
import type { AwsRegion } from '../pricing/aws-regions';
|
|
2
3
|
import type { LambdaPayloads, LambdaRoutines } from './constants';
|
|
3
4
|
import type { LambdaReturnValues } from './return-values';
|
|
4
|
-
export declare const callLambda: <T extends LambdaRoutines>({ functionName, type, payload, region, }: {
|
|
5
|
+
export declare const callLambda: <T extends LambdaRoutines>({ functionName, type, payload, region, receivedStreamingPayload, timeoutInTest, }: {
|
|
5
6
|
functionName: string;
|
|
6
7
|
type: T;
|
|
7
8
|
payload: Omit<LambdaPayloads[T], "type">;
|
|
8
9
|
region: AwsRegion;
|
|
10
|
+
receivedStreamingPayload: (streamPayload: StreamingPayloads) => void;
|
|
11
|
+
timeoutInTest: number;
|
|
9
12
|
}) => Promise<LambdaReturnValues[T]>;
|