@remotion/cloudrun 4.0.21 → 4.0.23
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/.turbo/turbo-build.log +3 -3
- package/dist/api/render-media-on-cloudrun.d.ts +6 -3
- package/dist/api/render-media-on-cloudrun.js +26 -9
- package/dist/api/render-still-on-cloudrun.d.ts +5 -4
- package/dist/api/render-still-on-cloudrun.js +52 -3
- package/dist/cli/commands/render/index.js +7 -52
- package/dist/cli/commands/render/renderMedia.d.ts +2 -0
- package/dist/cli/commands/render/renderMedia.js +156 -0
- package/dist/cli/commands/render/renderStill.d.ts +2 -0
- package/dist/cli/commands/render/renderStill.js +123 -0
- package/dist/cli/commands/still.js +24 -16
- package/dist/cli/helpers/cloudrun-crash-logs.d.ts +2 -0
- package/dist/cli/helpers/cloudrun-crash-logs.js +57 -0
- package/dist/cli/index.js +18 -2
- package/dist/functions/helpers/get-composition-from-body.js +1 -0
- package/dist/functions/helpers/payloads.d.ts +35 -23
- package/dist/functions/helpers/payloads.js +10 -5
- package/dist/functions/helpers/write-cloudrun-error.d.ts +12 -0
- package/dist/functions/helpers/write-cloudrun-error.js +18 -0
- package/dist/functions/index.js +6 -8
- package/dist/functions/render-media-single-thread.js +107 -88
- package/dist/functions/render-still-single-thread.js +82 -65
- package/dist/shared/read-dir.js +4 -2
- package/package.json +7 -7
|
@@ -8,13 +8,14 @@ const remotion_1 = require("remotion");
|
|
|
8
8
|
const download_file_1 = require("../../api/download-file");
|
|
9
9
|
const render_still_on_cloudrun_1 = require("../../api/render-still-on-cloudrun");
|
|
10
10
|
const validate_serveurl_1 = require("../../shared/validate-serveurl");
|
|
11
|
+
const cloudrun_crash_logs_1 = require("../helpers/cloudrun-crash-logs");
|
|
11
12
|
const log_1 = require("../log");
|
|
12
13
|
const renderArgsCheck_1 = require("./render/helpers/renderArgsCheck");
|
|
13
14
|
exports.STILL_COMMAND = 'still';
|
|
14
15
|
const stillCommand = async (args, remotionRoot) => {
|
|
15
16
|
var _a, _b;
|
|
16
17
|
const { serveUrl, cloudRunUrl, outName, forceBucketName, privacy, downloadName, region, } = await (0, renderArgsCheck_1.renderArgsCheck)(exports.STILL_COMMAND, args);
|
|
17
|
-
const { chromiumOptions, envVariables, inputProps, puppeteerTimeout, jpegQuality, stillFrame, scale, height, width, browserExecutable, port, logLevel, } = await cli_1.CliInternals.getCliOptions({
|
|
18
|
+
const { chromiumOptions, envVariables, inputProps, puppeteerTimeout, jpegQuality, stillFrame, scale, height, width, browserExecutable, port, logLevel, offthreadVideoCacheSizeInBytes, } = await cli_1.CliInternals.getCliOptions({
|
|
18
19
|
type: 'still',
|
|
19
20
|
isLambda: true,
|
|
20
21
|
remotionRoot,
|
|
@@ -33,6 +34,7 @@ const stillCommand = async (args, remotionRoot) => {
|
|
|
33
34
|
remotionRoot,
|
|
34
35
|
logLevel,
|
|
35
36
|
webpackConfigOrServeUrl: serveUrl,
|
|
37
|
+
offthreadVideoCacheSizeInBytes,
|
|
36
38
|
});
|
|
37
39
|
const { compositionId } = await cli_1.CliInternals.getCompositionWithDimensionOverride({
|
|
38
40
|
args: args.slice(1),
|
|
@@ -54,6 +56,7 @@ const stillCommand = async (args, remotionRoot) => {
|
|
|
54
56
|
height,
|
|
55
57
|
width,
|
|
56
58
|
server: await server,
|
|
59
|
+
offthreadVideoCacheSizeInBytes,
|
|
57
60
|
});
|
|
58
61
|
composition = compositionId;
|
|
59
62
|
}
|
|
@@ -112,21 +115,26 @@ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
|
|
|
112
115
|
logLevel: config_1.ConfigInternals.Logging.getLogLevel(),
|
|
113
116
|
delayRenderTimeoutInMilliseconds: puppeteerTimeout,
|
|
114
117
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
log_1.Log.info(
|
|
123
|
-
log_1.Log.info(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
118
|
+
if (res.type === 'crash') {
|
|
119
|
+
(0, cloudrun_crash_logs_1.displayCrashLogs)(res);
|
|
120
|
+
}
|
|
121
|
+
else if (res.type === 'success') {
|
|
122
|
+
doneIn = Date.now() - renderStart;
|
|
123
|
+
updateProgress(true);
|
|
124
|
+
log_1.Log.info(cli_1.CliInternals.chalk.gray(`Cloud Storage Uri = ${res.cloudStorageUri}`));
|
|
125
|
+
log_1.Log.info(cli_1.CliInternals.chalk.gray(`Render ID = ${res.renderId}`));
|
|
126
|
+
log_1.Log.info(cli_1.CliInternals.chalk.gray(`${Math.round(Number(res.size) / 1000)} KB, Privacy: ${res.privacy}, Bucket: ${res.bucketName}`));
|
|
127
|
+
log_1.Log.info(cli_1.CliInternals.chalk.blue(`○ ${res.publicUrl}`));
|
|
128
|
+
if (downloadName) {
|
|
129
|
+
log_1.Log.info('');
|
|
130
|
+
log_1.Log.info('downloading file...');
|
|
131
|
+
const { outputPath: destination } = await (0, download_file_1.downloadFile)({
|
|
132
|
+
bucketName: res.bucketName,
|
|
133
|
+
gsutilURI: res.cloudStorageUri,
|
|
134
|
+
downloadName,
|
|
135
|
+
});
|
|
136
|
+
log_1.Log.info(cli_1.CliInternals.chalk.blueBright(`Downloaded file to ${destination}!`));
|
|
137
|
+
}
|
|
130
138
|
}
|
|
131
139
|
};
|
|
132
140
|
exports.stillCommand = stillCommand;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.displayCrashLogs = void 0;
|
|
4
|
+
const cli_1 = require("@remotion/cli");
|
|
5
|
+
const extract_mem_from_url_1 = require("../../api/helpers/extract-mem-from-url");
|
|
6
|
+
const extract_time_from_url_1 = require("../../api/helpers/extract-time-from-url");
|
|
7
|
+
const get_cloud_logging_client_1 = require("../../api/helpers/get-cloud-logging-client");
|
|
8
|
+
const log_1 = require("../log");
|
|
9
|
+
const displayCrashLogs = async (res) => {
|
|
10
|
+
let timeoutPreMsg = '';
|
|
11
|
+
const timeout = (0, extract_time_from_url_1.extractTimeoutFromURL)(res.cloudRunEndpoint);
|
|
12
|
+
const memoryLimit = (0, extract_mem_from_url_1.extractMemoryFromURL)(res.cloudRunEndpoint);
|
|
13
|
+
if (timeout && res.requestElapsedTimeInSeconds + 10 > timeout) {
|
|
14
|
+
timeoutPreMsg = `Render call likely timed out. Service timeout is ${timeout} seconds, and render took at least ${res.requestElapsedTimeInSeconds.toFixed(1)} seconds.\n`;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
timeoutPreMsg = `Crash unlikely due to timeout. Render took ${res.requestElapsedTimeInSeconds.toFixed(1)} seconds, below the timeout of ${timeout} seconds.\n`;
|
|
18
|
+
}
|
|
19
|
+
log_1.Log.error(`Error rendering on Cloud Run. The Cloud Run service did not return a response.\n
|
|
20
|
+
${timeoutPreMsg}The crash may be due to the service exceeding its memory limit of ${memoryLimit}.
|
|
21
|
+
Full logs are available at https://console.cloud.google.com/run?project=${process.env.REMOTION_GCP_PROJECT_ID}\n`);
|
|
22
|
+
const cloudLoggingClient = (0, get_cloud_logging_client_1.getCloudLoggingClient)();
|
|
23
|
+
const listLogEntriesRequest = {
|
|
24
|
+
resourceNames: [`projects/${process.env.REMOTION_GCP_PROJECT_ID}`],
|
|
25
|
+
filter: `logName=projects/${process.env.REMOTION_GCP_PROJECT_ID}/logs/run.googleapis.com%2Fvarlog%2Fsystem AND (severity=WARNING OR severity=ERROR) AND timestamp >= "${res.requestStartTime}"`,
|
|
26
|
+
};
|
|
27
|
+
const logCheckCountdown = cli_1.CliInternals.createOverwriteableCliOutput({
|
|
28
|
+
quiet: cli_1.CliInternals.quietFlagProvided(),
|
|
29
|
+
cancelSignal: null,
|
|
30
|
+
updatesDontOverwrite: false,
|
|
31
|
+
indent: false,
|
|
32
|
+
});
|
|
33
|
+
await (() => {
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
let timeLeft = 30;
|
|
36
|
+
const intervalId = setInterval(() => {
|
|
37
|
+
logCheckCountdown.update(`GCP Cloud Logging takes time to ingest and index logs.\nFetching recent error/warning logs in ${timeLeft} seconds`, false);
|
|
38
|
+
timeLeft--;
|
|
39
|
+
if (timeLeft < 0) {
|
|
40
|
+
logCheckCountdown.update('Fetching logs...\n\n', false);
|
|
41
|
+
clearInterval(intervalId);
|
|
42
|
+
resolve();
|
|
43
|
+
}
|
|
44
|
+
}, 1000);
|
|
45
|
+
});
|
|
46
|
+
})();
|
|
47
|
+
const iterableLogListEntries = await cloudLoggingClient.listLogEntriesAsync(listLogEntriesRequest);
|
|
48
|
+
for await (const logResponse of iterableLogListEntries) {
|
|
49
|
+
const responseDate = new Date(Number(logResponse.timestamp.seconds) * 1000 +
|
|
50
|
+
Number(logResponse.timestamp.nanos) / 1000000);
|
|
51
|
+
const convertedDate = responseDate.toLocaleString();
|
|
52
|
+
log_1.Log.info(convertedDate);
|
|
53
|
+
log_1.Log.info(logResponse.textPayload);
|
|
54
|
+
log_1.Log.info();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.displayCrashLogs = displayCrashLogs;
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeCommand = void 0;
|
|
4
|
+
const cli_1 = require("@remotion/cli");
|
|
5
|
+
const config_1 = require("@remotion/cli/config");
|
|
6
|
+
const renderer_1 = require("@remotion/renderer");
|
|
4
7
|
const args_1 = require("./args");
|
|
5
8
|
const permissions_1 = require("./commands/permissions");
|
|
6
9
|
const regions_1 = require("./commands/regions");
|
|
@@ -43,13 +46,26 @@ const matchCommand = (args, remotionRoot) => {
|
|
|
43
46
|
(0, quit_1.quit)(1);
|
|
44
47
|
};
|
|
45
48
|
const executeCommand = async (args, remotionRoot) => {
|
|
49
|
+
var _a, _b;
|
|
46
50
|
try {
|
|
47
51
|
await matchCommand(args, remotionRoot);
|
|
48
52
|
}
|
|
49
53
|
catch (err) {
|
|
50
54
|
const error = err;
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
if (error instanceof renderer_1.RenderInternals.SymbolicateableError) {
|
|
56
|
+
await cli_1.CliInternals.handleCommonError(error, config_1.ConfigInternals.Logging.getLogLevel());
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const frames = renderer_1.RenderInternals.parseStack((_b = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split('\n')) !== null && _b !== void 0 ? _b : []);
|
|
60
|
+
const errorWithStackFrame = new renderer_1.RenderInternals.SymbolicateableError({
|
|
61
|
+
message: error.message,
|
|
62
|
+
frame: null,
|
|
63
|
+
name: error.name,
|
|
64
|
+
stack: error.stack,
|
|
65
|
+
stackFrame: frames,
|
|
66
|
+
});
|
|
67
|
+
await cli_1.CliInternals.handleCommonError(errorWithStackFrame, config_1.ConfigInternals.Logging.getLogLevel());
|
|
68
|
+
}
|
|
53
69
|
(0, quit_1.quit)(1);
|
|
54
70
|
}
|
|
55
71
|
};
|
|
@@ -18,6 +18,7 @@ const getCompositionFromBody = async (body) => {
|
|
|
18
18
|
puppeteerInstance: undefined,
|
|
19
19
|
server: undefined,
|
|
20
20
|
timeoutInMilliseconds: body.delayRenderTimeoutInMilliseconds,
|
|
21
|
+
offthreadVideoCacheSizeInBytes: body.offthreadVideoCacheSizeInBytes,
|
|
21
22
|
});
|
|
22
23
|
if (propsSize > 10000000) {
|
|
23
24
|
renderer_1.RenderInternals.Log.warn(`The props of your composition are large (${propsSize} bytes). This may cause slowdown.`);
|
|
@@ -16,6 +16,7 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
16
16
|
imageFormat: z.ZodEnum<["png", "jpeg", "none"]>;
|
|
17
17
|
scale: z.ZodNumber;
|
|
18
18
|
proResProfile: z.ZodNullable<z.ZodEnum<["4444-xq", "4444", "hq", "standard", "light", "proxy"]>>;
|
|
19
|
+
x264Preset: z.ZodNullable<z.ZodEnum<["ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow", "placebo"]>>;
|
|
19
20
|
everyNthFrame: z.ZodNumber;
|
|
20
21
|
numberOfGifLoops: z.ZodNullable<z.ZodNumber>;
|
|
21
22
|
frameRange: z.ZodNullable<z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodNumber]>>;
|
|
@@ -48,9 +49,10 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
48
49
|
concurrency: z.ZodNullable<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
49
50
|
enforceAudioTrack: z.ZodBoolean;
|
|
50
51
|
preferLossless: z.ZodBoolean;
|
|
52
|
+
offthreadVideoCacheSizeInBytes: z.ZodNullable<z.ZodNumber>;
|
|
51
53
|
}, "strip", z.ZodTypeAny, {
|
|
52
|
-
serveUrl: string;
|
|
53
54
|
type: "media";
|
|
55
|
+
serveUrl: string;
|
|
54
56
|
composition: string;
|
|
55
57
|
codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
|
|
56
58
|
serializedInputPropsWithCustomSchema: string;
|
|
@@ -63,6 +65,7 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
63
65
|
imageFormat: "png" | "jpeg" | "none";
|
|
64
66
|
scale: number;
|
|
65
67
|
proResProfile: "4444-xq" | "4444" | "hq" | "standard" | "light" | "proxy" | null;
|
|
68
|
+
x264Preset: "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "medium" | "slow" | "slower" | "veryslow" | "placebo" | null;
|
|
66
69
|
everyNthFrame: number;
|
|
67
70
|
numberOfGifLoops: number | null;
|
|
68
71
|
frameRange: ((number | [number, number]) & (number | [number, number] | undefined)) | null;
|
|
@@ -74,6 +77,7 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
74
77
|
concurrency: string | number | null;
|
|
75
78
|
enforceAudioTrack: boolean;
|
|
76
79
|
preferLossless: boolean;
|
|
80
|
+
offthreadVideoCacheSizeInBytes: number | null;
|
|
77
81
|
forceHeight?: number | null | undefined;
|
|
78
82
|
forceWidth?: number | null | undefined;
|
|
79
83
|
chromiumOptions?: {
|
|
@@ -86,8 +90,8 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
86
90
|
outName?: string | undefined;
|
|
87
91
|
privacy?: "public" | "private" | undefined;
|
|
88
92
|
}, {
|
|
89
|
-
serveUrl: string;
|
|
90
93
|
type: "media";
|
|
94
|
+
serveUrl: string;
|
|
91
95
|
composition: string;
|
|
92
96
|
codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
|
|
93
97
|
serializedInputPropsWithCustomSchema: string;
|
|
@@ -100,6 +104,7 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
100
104
|
imageFormat: "png" | "jpeg" | "none";
|
|
101
105
|
scale: number;
|
|
102
106
|
proResProfile: "4444-xq" | "4444" | "hq" | "standard" | "light" | "proxy" | null;
|
|
107
|
+
x264Preset: "ultrafast" | "superfast" | "veryfast" | "faster" | "fast" | "medium" | "slow" | "slower" | "veryslow" | "placebo" | null;
|
|
103
108
|
everyNthFrame: number;
|
|
104
109
|
numberOfGifLoops: number | null;
|
|
105
110
|
frameRange: ((number | [number, number]) & (number | [number, number] | undefined)) | null;
|
|
@@ -111,6 +116,7 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
111
116
|
concurrency: string | number | null;
|
|
112
117
|
enforceAudioTrack: boolean;
|
|
113
118
|
preferLossless: boolean;
|
|
119
|
+
offthreadVideoCacheSizeInBytes: number | null;
|
|
114
120
|
forceHeight?: number | null | undefined;
|
|
115
121
|
forceWidth?: number | null | undefined;
|
|
116
122
|
chromiumOptions?: {
|
|
@@ -158,9 +164,10 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
158
164
|
frame: z.ZodNumber;
|
|
159
165
|
delayRenderTimeoutInMilliseconds: z.ZodNumber;
|
|
160
166
|
logLevel: z.ZodEnum<["verbose", "info", "warn", "error"]>;
|
|
167
|
+
offthreadVideoCacheSizeInBytes: z.ZodNullable<z.ZodNumber>;
|
|
161
168
|
}, "strip", z.ZodTypeAny, {
|
|
162
|
-
serveUrl: string;
|
|
163
169
|
type: "still";
|
|
170
|
+
serveUrl: string;
|
|
164
171
|
composition: string;
|
|
165
172
|
serializedInputPropsWithCustomSchema: string;
|
|
166
173
|
imageFormat: "png" | "jpeg" | "pdf" | "webp";
|
|
@@ -170,6 +177,7 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
170
177
|
privacy: "public" | "private";
|
|
171
178
|
logLevel: "error" | "verbose" | "info" | "warn";
|
|
172
179
|
delayRenderTimeoutInMilliseconds: number;
|
|
180
|
+
offthreadVideoCacheSizeInBytes: number | null;
|
|
173
181
|
frame: number;
|
|
174
182
|
forceHeight?: number | null | undefined;
|
|
175
183
|
forceWidth?: number | null | undefined;
|
|
@@ -183,8 +191,8 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
183
191
|
} | undefined;
|
|
184
192
|
outName?: string | undefined;
|
|
185
193
|
}, {
|
|
186
|
-
serveUrl: string;
|
|
187
194
|
type: "still";
|
|
195
|
+
serveUrl: string;
|
|
188
196
|
composition: string;
|
|
189
197
|
serializedInputPropsWithCustomSchema: string;
|
|
190
198
|
imageFormat: "png" | "jpeg" | "pdf" | "webp";
|
|
@@ -194,6 +202,7 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
194
202
|
privacy: "public" | "private";
|
|
195
203
|
logLevel: "error" | "verbose" | "info" | "warn";
|
|
196
204
|
delayRenderTimeoutInMilliseconds: number;
|
|
205
|
+
offthreadVideoCacheSizeInBytes: number | null;
|
|
197
206
|
frame: number;
|
|
198
207
|
forceHeight?: number | null | undefined;
|
|
199
208
|
forceWidth?: number | null | undefined;
|
|
@@ -208,20 +217,23 @@ export declare const CloudRunPayload: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
208
217
|
outName?: string | undefined;
|
|
209
218
|
}>]>;
|
|
210
219
|
declare const renderFailResponsePayload: z.ZodObject<{
|
|
211
|
-
|
|
212
|
-
|
|
220
|
+
type: z.ZodLiteral<"error">;
|
|
221
|
+
message: z.ZodString;
|
|
222
|
+
name: z.ZodString;
|
|
213
223
|
stack: z.ZodString;
|
|
214
224
|
}, "strip", z.ZodTypeAny, {
|
|
215
|
-
|
|
216
|
-
|
|
225
|
+
type: "error";
|
|
226
|
+
message: string;
|
|
227
|
+
name: string;
|
|
217
228
|
stack: string;
|
|
218
229
|
}, {
|
|
219
|
-
|
|
220
|
-
|
|
230
|
+
type: "error";
|
|
231
|
+
message: string;
|
|
232
|
+
name: string;
|
|
221
233
|
stack: string;
|
|
222
234
|
}>;
|
|
223
235
|
declare const renderStillOnCloudrunResponsePayload: z.ZodObject<{
|
|
224
|
-
|
|
236
|
+
type: z.ZodLiteral<"success">;
|
|
225
237
|
publicUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
226
238
|
cloudStorageUri: z.ZodString;
|
|
227
239
|
size: z.ZodNumber;
|
|
@@ -230,23 +242,23 @@ declare const renderStillOnCloudrunResponsePayload: z.ZodObject<{
|
|
|
230
242
|
privacy: z.ZodEnum<["public-read", "project-private"]>;
|
|
231
243
|
}, "strip", z.ZodTypeAny, {
|
|
232
244
|
bucketName: string;
|
|
233
|
-
|
|
234
|
-
status: "success";
|
|
245
|
+
type: "success";
|
|
235
246
|
privacy: "public-read" | "project-private";
|
|
236
247
|
cloudStorageUri: string;
|
|
248
|
+
size: number;
|
|
237
249
|
renderId: string;
|
|
238
250
|
publicUrl?: string | null | undefined;
|
|
239
251
|
}, {
|
|
240
252
|
bucketName: string;
|
|
241
|
-
|
|
242
|
-
status: "success";
|
|
253
|
+
type: "success";
|
|
243
254
|
privacy: "public-read" | "project-private";
|
|
244
255
|
cloudStorageUri: string;
|
|
256
|
+
size: number;
|
|
245
257
|
renderId: string;
|
|
246
258
|
publicUrl?: string | null | undefined;
|
|
247
259
|
}>;
|
|
248
260
|
declare const renderMediaOnCloudrunResponsePayload: z.ZodObject<{
|
|
249
|
-
|
|
261
|
+
type: z.ZodLiteral<"success">;
|
|
250
262
|
publicUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
251
263
|
cloudStorageUri: z.ZodString;
|
|
252
264
|
size: z.ZodNumber;
|
|
@@ -255,38 +267,38 @@ declare const renderMediaOnCloudrunResponsePayload: z.ZodObject<{
|
|
|
255
267
|
privacy: z.ZodEnum<["public-read", "project-private"]>;
|
|
256
268
|
}, "strip", z.ZodTypeAny, {
|
|
257
269
|
bucketName: string;
|
|
258
|
-
|
|
259
|
-
status: "success";
|
|
270
|
+
type: "success";
|
|
260
271
|
privacy: "public-read" | "project-private";
|
|
261
272
|
cloudStorageUri: string;
|
|
273
|
+
size: number;
|
|
262
274
|
renderId: string;
|
|
263
275
|
publicUrl?: string | null | undefined;
|
|
264
276
|
}, {
|
|
265
277
|
bucketName: string;
|
|
266
|
-
|
|
267
|
-
status: "success";
|
|
278
|
+
type: "success";
|
|
268
279
|
privacy: "public-read" | "project-private";
|
|
269
280
|
cloudStorageUri: string;
|
|
281
|
+
size: number;
|
|
270
282
|
renderId: string;
|
|
271
283
|
publicUrl?: string | null | undefined;
|
|
272
284
|
}>;
|
|
273
285
|
declare const cloudRunCrashResponse: z.ZodObject<{
|
|
274
|
-
|
|
286
|
+
type: z.ZodLiteral<"crash">;
|
|
275
287
|
cloudRunEndpoint: z.ZodString;
|
|
276
288
|
message: z.ZodLiteral<"Service crashed without sending a response. Check the logs in GCP console.">;
|
|
277
289
|
requestStartTime: z.ZodString;
|
|
278
290
|
requestCrashTime: z.ZodString;
|
|
279
291
|
requestElapsedTimeInSeconds: z.ZodNumber;
|
|
280
292
|
}, "strip", z.ZodTypeAny, {
|
|
293
|
+
type: "crash";
|
|
281
294
|
message: "Service crashed without sending a response. Check the logs in GCP console.";
|
|
282
|
-
status: "crash";
|
|
283
295
|
cloudRunEndpoint: string;
|
|
284
296
|
requestStartTime: string;
|
|
285
297
|
requestCrashTime: string;
|
|
286
298
|
requestElapsedTimeInSeconds: number;
|
|
287
299
|
}, {
|
|
300
|
+
type: "crash";
|
|
288
301
|
message: "Service crashed without sending a response. Check the logs in GCP console.";
|
|
289
|
-
status: "crash";
|
|
290
302
|
cloudRunEndpoint: string;
|
|
291
303
|
requestStartTime: string;
|
|
292
304
|
requestCrashTime: string;
|
|
@@ -10,6 +10,7 @@ const pixelFormat = zod_1.z.enum(renderer_1.RenderInternals.validPixelFormats);
|
|
|
10
10
|
const videoImageFormat = zod_1.z.enum(renderer_1.RenderInternals.validVideoImageFormats);
|
|
11
11
|
const stillImageFormat = zod_1.z.enum(renderer_1.RenderInternals.validStillImageFormats);
|
|
12
12
|
const proResProfile = zod_1.z.enum(client_1.BrowserSafeApis.proResProfileOptions).nullable();
|
|
13
|
+
const x264Preset = zod_1.z.enum(client_1.BrowserSafeApis.x264PresetOptions).nullable();
|
|
13
14
|
const chromiumOptions = zod_1.z.object({
|
|
14
15
|
ignoreCertificateErrors: zod_1.z.boolean().optional(),
|
|
15
16
|
disableWebSecurity: zod_1.z.boolean().optional(),
|
|
@@ -36,6 +37,7 @@ exports.CloudRunPayload = zod_1.z.discriminatedUnion('type', [
|
|
|
36
37
|
imageFormat: videoImageFormat,
|
|
37
38
|
scale: zod_1.z.number(),
|
|
38
39
|
proResProfile,
|
|
40
|
+
x264Preset,
|
|
39
41
|
everyNthFrame: zod_1.z.number(),
|
|
40
42
|
numberOfGifLoops: zod_1.z.number().nullable(),
|
|
41
43
|
frameRange: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()]).or(zod_1.z.number()).nullable(),
|
|
@@ -50,6 +52,7 @@ exports.CloudRunPayload = zod_1.z.discriminatedUnion('type', [
|
|
|
50
52
|
concurrency: zod_1.z.number().or(zod_1.z.string()).nullable(),
|
|
51
53
|
enforceAudioTrack: zod_1.z.boolean(),
|
|
52
54
|
preferLossless: zod_1.z.boolean(),
|
|
55
|
+
offthreadVideoCacheSizeInBytes: zod_1.z.number().nullable(),
|
|
53
56
|
}),
|
|
54
57
|
zod_1.z.object({
|
|
55
58
|
type: zod_1.z.literal('still'),
|
|
@@ -69,15 +72,17 @@ exports.CloudRunPayload = zod_1.z.discriminatedUnion('type', [
|
|
|
69
72
|
frame: zod_1.z.number(),
|
|
70
73
|
delayRenderTimeoutInMilliseconds: zod_1.z.number(),
|
|
71
74
|
logLevel,
|
|
75
|
+
offthreadVideoCacheSizeInBytes: zod_1.z.number().nullable(),
|
|
72
76
|
}),
|
|
73
77
|
]);
|
|
74
78
|
const renderFailResponsePayload = zod_1.z.object({
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
type: zod_1.z.literal('error'),
|
|
80
|
+
message: zod_1.z.string(),
|
|
81
|
+
name: zod_1.z.string(),
|
|
77
82
|
stack: zod_1.z.string(),
|
|
78
83
|
});
|
|
79
84
|
const renderStillOnCloudrunResponsePayload = zod_1.z.object({
|
|
80
|
-
|
|
85
|
+
type: zod_1.z.literal('success'),
|
|
81
86
|
publicUrl: zod_1.z.string().optional().nullable(),
|
|
82
87
|
cloudStorageUri: zod_1.z.string(),
|
|
83
88
|
size: zod_1.z.number(),
|
|
@@ -86,7 +91,7 @@ const renderStillOnCloudrunResponsePayload = zod_1.z.object({
|
|
|
86
91
|
privacy: zod_1.z.enum(['public-read', 'project-private']),
|
|
87
92
|
});
|
|
88
93
|
const renderMediaOnCloudrunResponsePayload = zod_1.z.object({
|
|
89
|
-
|
|
94
|
+
type: zod_1.z.literal('success'),
|
|
90
95
|
publicUrl: zod_1.z.string().optional().nullable(),
|
|
91
96
|
cloudStorageUri: zod_1.z.string(),
|
|
92
97
|
size: zod_1.z.number(),
|
|
@@ -95,7 +100,7 @@ const renderMediaOnCloudrunResponsePayload = zod_1.z.object({
|
|
|
95
100
|
privacy: zod_1.z.enum(['public-read', 'project-private']),
|
|
96
101
|
});
|
|
97
102
|
const cloudRunCrashResponse = zod_1.z.object({
|
|
98
|
-
|
|
103
|
+
type: zod_1.z.literal('crash'),
|
|
99
104
|
cloudRunEndpoint: zod_1.z.string(),
|
|
100
105
|
message: zod_1.z.literal('Service crashed without sending a response. Check the logs in GCP console.'),
|
|
101
106
|
requestStartTime: zod_1.z.string().datetime(),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type CloudrunErrorInfo = {
|
|
2
|
+
type: 'renderer' | 'browser' | 'stitcher' | 'webhook';
|
|
3
|
+
message: string;
|
|
4
|
+
name: string;
|
|
5
|
+
stack: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const writeCloudrunError: ({ bucketName, renderId, errorInfo, publicUpload, }: {
|
|
8
|
+
bucketName: string;
|
|
9
|
+
renderId: string;
|
|
10
|
+
errorInfo: CloudrunErrorInfo;
|
|
11
|
+
publicUpload: boolean;
|
|
12
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.writeCloudrunError = void 0;
|
|
7
|
+
const storage_1 = require("@google-cloud/storage");
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const writeCloudrunError = async ({ bucketName, renderId, errorInfo, publicUpload, }) => {
|
|
10
|
+
const storage = new storage_1.Storage();
|
|
11
|
+
const tempFilePath = '/tmp/errorInfo.txt';
|
|
12
|
+
node_fs_1.default.writeFileSync(tempFilePath, JSON.stringify(errorInfo));
|
|
13
|
+
await storage.bucket(bucketName).upload(tempFilePath, {
|
|
14
|
+
destination: `renders/${renderId}/error.txt`,
|
|
15
|
+
predefinedAcl: publicUpload ? 'publicRead' : 'projectPrivate',
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.writeCloudrunError = writeCloudrunError;
|
package/dist/functions/index.js
CHANGED
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.renderOnCloudRun = void 0;
|
|
4
4
|
const renderer_1 = require("@remotion/renderer");
|
|
5
|
-
const log_1 = require("../cli/log");
|
|
6
5
|
const payloads_1 = require("./helpers/payloads");
|
|
7
6
|
const render_media_single_thread_1 = require("./render-media-single-thread");
|
|
8
7
|
const render_still_single_thread_1 = require("./render-still-single-thread");
|
|
9
8
|
const renderOnCloudRun = async (req, res) => {
|
|
10
|
-
var _a;
|
|
11
9
|
try {
|
|
12
|
-
log_1.Log.info('renderOnCloudRun', req.body);
|
|
13
10
|
const body = payloads_1.CloudRunPayload.parse(req.body);
|
|
14
11
|
const renderType = body.type;
|
|
15
12
|
renderer_1.RenderInternals.setLogLevel(body.logLevel);
|
|
@@ -27,13 +24,14 @@ const renderOnCloudRun = async (req, res) => {
|
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
catch (err) {
|
|
30
|
-
log_1.Log.error('Error while rendering', err);
|
|
31
27
|
const response = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
type: 'error',
|
|
29
|
+
message: err.message,
|
|
30
|
+
name: err.name,
|
|
31
|
+
stack: err.stack,
|
|
35
32
|
};
|
|
36
|
-
res.
|
|
33
|
+
res.write(JSON.stringify(response));
|
|
34
|
+
res.end();
|
|
37
35
|
}
|
|
38
36
|
};
|
|
39
37
|
exports.renderOnCloudRun = renderOnCloudRun;
|