@remotion/lambda 4.0.40 → 4.0.42
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 -1
- package/dist/cli/log.d.ts +4 -4
- package/dist/functions/helpers/check-if-render-exists.js +1 -0
- package/dist/functions/helpers/get-current-region.d.ts +1 -1
- package/dist/functions/helpers/streaming-payloads.d.ts +3 -3
- package/dist/functions/index.js +1 -0
- package/dist/functions/progress.d.ts +1 -0
- package/dist/functions/progress.js +29 -10
- package/dist/functions/streaming/streaming.d.ts +54 -6
- package/dist/functions/streaming/streaming.js +60 -16
- package/package.json +8 -8
- package/remotionlambda-arm64.zip +0 -0
- package/dist/cli/helpers/validate.d.ts +0 -4
- package/dist/cli/helpers/validate.js +0 -8
|
@@ -31,7 +31,7 @@ export type RenderMediaOnLambdaInput = {
|
|
|
31
31
|
frameRange?: FrameRange;
|
|
32
32
|
outName?: OutNameInput;
|
|
33
33
|
timeoutInMilliseconds?: number;
|
|
34
|
-
chromiumOptions?: ChromiumOptions
|
|
34
|
+
chromiumOptions?: Omit<ChromiumOptions, 'enableMultiProcessOnLinux'>;
|
|
35
35
|
scale?: number;
|
|
36
36
|
everyNthFrame?: number;
|
|
37
37
|
numberOfGifLoops?: number | null;
|
package/dist/cli/log.d.ts
CHANGED
|
@@ -2,24 +2,24 @@ export declare const Log: {
|
|
|
2
2
|
verbose: (message?: any, ...optionalParams: any[]) => void;
|
|
3
3
|
verboseAdvanced: (options: {
|
|
4
4
|
indent: boolean;
|
|
5
|
-
logLevel: "
|
|
5
|
+
logLevel: "verbose" | "info" | "warn" | "error";
|
|
6
6
|
} & {
|
|
7
7
|
tag?: string | undefined;
|
|
8
8
|
}, message?: any, ...optionalParams: any[]) => void;
|
|
9
9
|
info: (message?: any, ...optionalParams: any[]) => void;
|
|
10
10
|
infoAdvanced: (options: {
|
|
11
11
|
indent: boolean;
|
|
12
|
-
logLevel: "
|
|
12
|
+
logLevel: "verbose" | "info" | "warn" | "error";
|
|
13
13
|
}, message?: any, ...optionalParams: any[]) => void;
|
|
14
14
|
warn: (message?: any, ...optionalParams: any[]) => void;
|
|
15
15
|
warnAdvanced: (options: {
|
|
16
16
|
indent: boolean;
|
|
17
|
-
logLevel: "
|
|
17
|
+
logLevel: "verbose" | "info" | "warn" | "error";
|
|
18
18
|
}, message?: any, ...optionalParams: any[]) => void;
|
|
19
19
|
error: (message?: any, ...optionalParams: any[]) => void;
|
|
20
20
|
errorAdvanced: (options: {
|
|
21
21
|
indent: boolean;
|
|
22
|
-
logLevel: "
|
|
22
|
+
logLevel: "verbose" | "info" | "warn" | "error";
|
|
23
23
|
} & {
|
|
24
24
|
tag?: string | undefined;
|
|
25
25
|
}, message?: any, ...optionalParams: any[]) => void;
|
|
@@ -8,6 +8,7 @@ const checkIfRenderExists = (contents, renderId, bucketName, region) => {
|
|
|
8
8
|
return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.initalizedMetadataKey)(renderId));
|
|
9
9
|
}));
|
|
10
10
|
if (!initializedExists) {
|
|
11
|
+
// ! Error message is checked in progress handler and will be retried. Make sure to update
|
|
11
12
|
throw new TypeError(`No render with ID "${renderId}" found in bucket ${bucketName} and region ${region}`);
|
|
12
13
|
}
|
|
13
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "
|
|
1
|
+
export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-south-1" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "af-south-1" | "ap-south-1" | "ap-east-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "me-south-1" | "sa-east-1";
|
|
@@ -4,16 +4,16 @@ declare const streamingPayloadSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
4
4
|
type: z.ZodLiteral<"render-id-determined">;
|
|
5
5
|
renderId: z.ZodString;
|
|
6
6
|
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
renderId: string;
|
|
8
7
|
type: "render-id-determined";
|
|
9
|
-
}, {
|
|
10
8
|
renderId: string;
|
|
9
|
+
}, {
|
|
11
10
|
type: "render-id-determined";
|
|
11
|
+
renderId: string;
|
|
12
12
|
}>]>;
|
|
13
13
|
export type StreamingPayloads = z.infer<typeof streamingPayloadSchema>;
|
|
14
14
|
export declare const isStreamingPayload: (str: string) => false | {
|
|
15
|
-
renderId: string;
|
|
16
15
|
type: "render-id-determined";
|
|
16
|
+
renderId: string;
|
|
17
17
|
};
|
|
18
18
|
export declare const sendProgressEvent: (responseStream: ResponseStream, payload: StreamingPayloads) => void;
|
|
19
19
|
export {};
|
package/dist/functions/index.js
CHANGED
|
@@ -88,6 +88,7 @@ const innerHandler = async (params, responseStream, context) => {
|
|
|
88
88
|
const response = await (0, progress_1.progressHandler)(params, {
|
|
89
89
|
expectedBucketOwner: currentUserId,
|
|
90
90
|
timeoutInMilliseconds,
|
|
91
|
+
retriesRemaining: 2,
|
|
91
92
|
});
|
|
92
93
|
responseStream.write(JSON.stringify(response), () => {
|
|
93
94
|
responseStream.end();
|
|
@@ -2,6 +2,7 @@ import type { LambdaPayload, RenderProgress } from '../shared/constants';
|
|
|
2
2
|
type Options = {
|
|
3
3
|
expectedBucketOwner: string;
|
|
4
4
|
timeoutInMilliseconds: number;
|
|
5
|
+
retriesRemaining: number;
|
|
5
6
|
};
|
|
6
7
|
export declare const progressHandler: (lambdaParams: LambdaPayload, options: Options) => Promise<RenderProgress>;
|
|
7
8
|
export {};
|
|
@@ -5,7 +5,7 @@ const version_1 = require("remotion/version");
|
|
|
5
5
|
const constants_1 = require("../shared/constants");
|
|
6
6
|
const get_current_region_1 = require("./helpers/get-current-region");
|
|
7
7
|
const get_progress_1 = require("./helpers/get-progress");
|
|
8
|
-
const progressHandler = (lambdaParams, options) => {
|
|
8
|
+
const progressHandler = async (lambdaParams, options) => {
|
|
9
9
|
var _a;
|
|
10
10
|
if (lambdaParams.type !== constants_1.LambdaRoutines.status) {
|
|
11
11
|
throw new TypeError('Expected status type');
|
|
@@ -16,14 +16,33 @@ const progressHandler = (lambdaParams, options) => {
|
|
|
16
16
|
}
|
|
17
17
|
throw new Error(`Version mismatch: When calling getRenderProgress(), you passed ${process.env.AWS_LAMBDA_FUNCTION_NAME} as the function, which has the version ${version_1.VERSION}, but the @remotion/lambda package you used to invoke the function has version ${lambdaParams.version}. Deploy a new function and use it to call getRenderProgress(). See: https://www.remotion.dev/docs/lambda/upgrading`);
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
try {
|
|
20
|
+
const progress = await (0, get_progress_1.getProgress)({
|
|
21
|
+
bucketName: lambdaParams.bucketName,
|
|
22
|
+
renderId: lambdaParams.renderId,
|
|
23
|
+
expectedBucketOwner: options.expectedBucketOwner,
|
|
24
|
+
region: (0, get_current_region_1.getCurrentRegionInFunction)(),
|
|
25
|
+
memorySizeInMb: Number(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE),
|
|
26
|
+
timeoutInMilliseconds: options.timeoutInMilliseconds,
|
|
27
|
+
customCredentials: (_a = lambdaParams.s3OutputProvider) !== null && _a !== void 0 ? _a : null,
|
|
28
|
+
});
|
|
29
|
+
return progress;
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
if (options.retriesRemaining === 0) {
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
if (err.message.includes('No render with ID')) {
|
|
36
|
+
await new Promise((resolve) => {
|
|
37
|
+
setTimeout(resolve, 1000);
|
|
38
|
+
});
|
|
39
|
+
return (0, exports.progressHandler)(lambdaParams, {
|
|
40
|
+
expectedBucketOwner: options.expectedBucketOwner,
|
|
41
|
+
timeoutInMilliseconds: options.timeoutInMilliseconds,
|
|
42
|
+
retriesRemaining: options.retriesRemaining - 1,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
28
47
|
};
|
|
29
48
|
exports.progressHandler = progressHandler;
|
|
@@ -1,12 +1,60 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
declare const framesRendered: "frames-rendered";
|
|
3
|
+
declare const errorOccurred: "error-occurred";
|
|
4
|
+
declare const renderIdDetermined: "render-id-determined";
|
|
5
|
+
declare const chunkRendered: "chunk-rendered";
|
|
6
|
+
declare const messageTypes: {
|
|
7
|
+
readonly '1': {
|
|
8
|
+
readonly type: "frames-rendered";
|
|
9
|
+
};
|
|
10
|
+
readonly '2': {
|
|
11
|
+
readonly type: "error-occurred";
|
|
12
|
+
};
|
|
13
|
+
readonly '3': {
|
|
14
|
+
readonly type: "render-id-determined";
|
|
15
|
+
};
|
|
16
|
+
readonly '4': {
|
|
17
|
+
readonly type: "chunk-rendered";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
type MessageTypeId = keyof typeof messageTypes;
|
|
21
|
+
type MessageType = (typeof messageTypes)[MessageTypeId]['type'];
|
|
22
|
+
export declare const formatMap: {
|
|
23
|
+
[key in MessageType]: 'json' | 'binary';
|
|
5
24
|
};
|
|
6
|
-
export declare const makePayloadMessage: (nonce: number, data: Buffer, status: 0 | 1) => Buffer;
|
|
7
25
|
export type StreamingPayload = {
|
|
8
|
-
type:
|
|
9
|
-
|
|
26
|
+
type: typeof framesRendered;
|
|
27
|
+
payload: {
|
|
28
|
+
frames: number;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
type: typeof chunkRendered;
|
|
32
|
+
payload: Buffer;
|
|
33
|
+
} | {
|
|
34
|
+
type: typeof errorOccurred;
|
|
35
|
+
payload: {
|
|
36
|
+
error: string;
|
|
37
|
+
};
|
|
38
|
+
} | {
|
|
39
|
+
type: typeof renderIdDetermined;
|
|
40
|
+
payload: {
|
|
41
|
+
renderId: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare const messageTypeIdToMessage: (messageTypeId: MessageTypeId) => MessageType;
|
|
45
|
+
export declare const messageTypeToMessageId: (messageType: MessageType) => MessageTypeId;
|
|
46
|
+
export type OnMessage = (options: {
|
|
47
|
+
successType: 'error' | 'success';
|
|
48
|
+
message: StreamingPayload;
|
|
49
|
+
}) => void;
|
|
50
|
+
export declare const makeStreaming: (options: {
|
|
51
|
+
onMessage: OnMessage;
|
|
52
|
+
}) => {
|
|
53
|
+
addData: (data: Buffer) => void;
|
|
10
54
|
};
|
|
55
|
+
export declare const makePayloadMessage: ({ message, status, }: {
|
|
56
|
+
message: StreamingPayload;
|
|
57
|
+
status: 0 | 1;
|
|
58
|
+
}) => Buffer;
|
|
11
59
|
export type OnStream = (payload: StreamingPayload) => void;
|
|
12
60
|
export {};
|
|
@@ -1,21 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makePayloadMessage = exports.makeStreaming = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.makePayloadMessage = exports.makeStreaming = exports.messageTypeToMessageId = exports.messageTypeIdToMessage = exports.formatMap = void 0;
|
|
4
|
+
const framesRendered = 'frames-rendered';
|
|
5
|
+
const errorOccurred = 'error-occurred';
|
|
6
|
+
const renderIdDetermined = 'render-id-determined';
|
|
7
|
+
const chunkRendered = 'chunk-rendered';
|
|
8
|
+
const messageTypes = {
|
|
9
|
+
'1': { type: framesRendered },
|
|
10
|
+
'2': { type: errorOccurred },
|
|
11
|
+
'3': { type: renderIdDetermined },
|
|
12
|
+
'4': { type: chunkRendered },
|
|
13
|
+
};
|
|
14
|
+
exports.formatMap = {
|
|
15
|
+
[framesRendered]: 'json',
|
|
16
|
+
[errorOccurred]: 'json',
|
|
17
|
+
[renderIdDetermined]: 'json',
|
|
18
|
+
[chunkRendered]: 'binary',
|
|
19
|
+
};
|
|
20
|
+
const messageTypeIdToMessage = (messageTypeId) => {
|
|
21
|
+
const types = messageTypes[messageTypeId];
|
|
22
|
+
if (!types) {
|
|
23
|
+
throw new Error(`Unknown message type id ${messageTypeId}`);
|
|
24
|
+
}
|
|
25
|
+
return types.type;
|
|
26
|
+
};
|
|
27
|
+
exports.messageTypeIdToMessage = messageTypeIdToMessage;
|
|
28
|
+
const messageTypeToMessageId = (messageType) => {
|
|
29
|
+
const id = Object.keys(messageTypes).find((key) => messageTypes[key].type === messageType);
|
|
30
|
+
if (!id) {
|
|
31
|
+
throw new Error(`Unknown message type ${messageType}`);
|
|
32
|
+
}
|
|
33
|
+
return id;
|
|
34
|
+
};
|
|
35
|
+
exports.messageTypeToMessageId = messageTypeToMessageId;
|
|
36
|
+
const magicSeparator = Buffer.from('remotion_buffer:');
|
|
37
|
+
const makeStreaming = (options) => {
|
|
5
38
|
let outputBuffer = Buffer.from('');
|
|
6
|
-
const separator = Buffer.from('remotion_buffer:');
|
|
7
39
|
let unprocessedBuffers = [];
|
|
8
40
|
let missingData = null;
|
|
9
41
|
const processInput = () => {
|
|
10
|
-
let separatorIndex = outputBuffer.indexOf(
|
|
42
|
+
let separatorIndex = outputBuffer.indexOf(magicSeparator);
|
|
11
43
|
if (separatorIndex === -1) {
|
|
12
44
|
return;
|
|
13
45
|
}
|
|
14
|
-
separatorIndex +=
|
|
15
|
-
let
|
|
46
|
+
separatorIndex += magicSeparator.length;
|
|
47
|
+
let messageTypeString = '';
|
|
16
48
|
let lengthString = '';
|
|
17
49
|
let statusString = '';
|
|
18
|
-
// Each message
|
|
50
|
+
// Each message has the structure with `remotion_buffer:{[message_type_id]}:{[length]}`
|
|
19
51
|
// Let's read the buffer to extract the nonce, and if the full length is available,
|
|
20
52
|
// we'll extract the data and pass it to the callback.
|
|
21
53
|
// eslint-disable-next-line no-constant-condition
|
|
@@ -27,7 +59,7 @@ const makeStreaming = (onMessage) => {
|
|
|
27
59
|
break;
|
|
28
60
|
}
|
|
29
61
|
separatorIndex++;
|
|
30
|
-
|
|
62
|
+
messageTypeString += String.fromCharCode(nextDigit);
|
|
31
63
|
}
|
|
32
64
|
// eslint-disable-next-line no-constant-condition
|
|
33
65
|
while (true) {
|
|
@@ -58,7 +90,17 @@ const makeStreaming = (onMessage) => {
|
|
|
58
90
|
return;
|
|
59
91
|
}
|
|
60
92
|
const data = outputBuffer.subarray(separatorIndex + 1, separatorIndex + 1 + Number(lengthString));
|
|
61
|
-
|
|
93
|
+
const messageType = (0, exports.messageTypeIdToMessage)(messageTypeString);
|
|
94
|
+
const payload = {
|
|
95
|
+
type: messageType,
|
|
96
|
+
payload: exports.formatMap[messageType] === 'json'
|
|
97
|
+
? JSON.parse(data.toString('utf-8'))
|
|
98
|
+
: data,
|
|
99
|
+
};
|
|
100
|
+
options.onMessage({
|
|
101
|
+
successType: status === 1 ? 'error' : 'success',
|
|
102
|
+
message: payload,
|
|
103
|
+
});
|
|
62
104
|
missingData = null;
|
|
63
105
|
outputBuffer = outputBuffer.subarray(separatorIndex + Number(lengthString) + 1);
|
|
64
106
|
processInput();
|
|
@@ -66,7 +108,7 @@ const makeStreaming = (onMessage) => {
|
|
|
66
108
|
return {
|
|
67
109
|
addData: (data) => {
|
|
68
110
|
unprocessedBuffers.push(data);
|
|
69
|
-
const separatorIndex = data.indexOf(
|
|
111
|
+
const separatorIndex = data.indexOf(magicSeparator);
|
|
70
112
|
if (separatorIndex === -1) {
|
|
71
113
|
if (missingData) {
|
|
72
114
|
missingData.dataMissing -= data.length;
|
|
@@ -78,22 +120,24 @@ const makeStreaming = (onMessage) => {
|
|
|
78
120
|
unprocessedBuffers.unshift(outputBuffer);
|
|
79
121
|
outputBuffer = Buffer.concat(unprocessedBuffers);
|
|
80
122
|
unprocessedBuffers = [];
|
|
81
|
-
console.log('the unprocessed input is now', new TextDecoder('utf-8').decode(outputBuffer));
|
|
82
123
|
processInput();
|
|
83
124
|
},
|
|
84
125
|
};
|
|
85
126
|
};
|
|
86
127
|
exports.makeStreaming = makeStreaming;
|
|
87
|
-
const makePayloadMessage = (
|
|
128
|
+
const makePayloadMessage = ({ message, status, }) => {
|
|
129
|
+
const body = exports.formatMap[message.type] === 'json'
|
|
130
|
+
? Buffer.from(JSON.stringify(message.payload))
|
|
131
|
+
: message.payload;
|
|
88
132
|
const concat = Buffer.concat([
|
|
89
|
-
|
|
90
|
-
Buffer.from(
|
|
133
|
+
magicSeparator,
|
|
134
|
+
Buffer.from((0, exports.messageTypeToMessageId)(message.type).toString()),
|
|
91
135
|
Buffer.from(':'),
|
|
92
|
-
Buffer.from(
|
|
136
|
+
Buffer.from(body.length.toString()),
|
|
93
137
|
Buffer.from(':'),
|
|
94
138
|
Buffer.from(String(status)),
|
|
95
139
|
Buffer.from(':'),
|
|
96
|
-
|
|
140
|
+
body,
|
|
97
141
|
]);
|
|
98
142
|
return concat;
|
|
99
143
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/lambda",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.42",
|
|
4
4
|
"description": "Distributed renderer for Remotion based on AWS Lambda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"aws-policies": "^1.0.1",
|
|
27
27
|
"mime-types": "2.1.34",
|
|
28
28
|
"zod": "3.21.4",
|
|
29
|
-
"@remotion/
|
|
30
|
-
"@remotion/
|
|
31
|
-
"remotion": "4.0.
|
|
32
|
-
"@remotion/cli": "4.0.
|
|
29
|
+
"@remotion/renderer": "4.0.42",
|
|
30
|
+
"@remotion/bundler": "4.0.42",
|
|
31
|
+
"remotion": "4.0.42",
|
|
32
|
+
"@remotion/cli": "4.0.42"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@jonny/eslint-config": "3.0.266",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"ts-node": "^10.8.0",
|
|
44
44
|
"vitest": "0.31.1",
|
|
45
45
|
"zip-lib": "^0.7.2",
|
|
46
|
-
"@remotion/bundler": "4.0.
|
|
47
|
-
"@remotion/compositor-linux-arm64-gnu": "4.0.
|
|
46
|
+
"@remotion/bundler": "4.0.42",
|
|
47
|
+
"@remotion/compositor-linux-arm64-gnu": "4.0.42"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@remotion/bundler": "4.0.
|
|
50
|
+
"@remotion/bundler": "4.0.42"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
package/remotionlambda-arm64.zip
CHANGED
|
Binary file
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateDurationInFrames = exports.validateDimension = exports.validateFps = void 0;
|
|
4
|
-
/* eslint-disable prefer-destructuring */
|
|
5
|
-
const remotion_1 = require("remotion");
|
|
6
|
-
exports.validateFps = remotion_1.Internals.validateFps;
|
|
7
|
-
exports.validateDimension = remotion_1.Internals.validateDimension;
|
|
8
|
-
exports.validateDurationInFrames = remotion_1.Internals.validateDurationInFrames;
|