@remotion/lambda-client 4.0.267 → 4.0.268

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.
@@ -10,7 +10,7 @@ import { ServiceQuotasClient } from "@aws-sdk/client-service-quotas";
10
10
  import { STSClient } from "@aws-sdk/client-sts";
11
11
 
12
12
  // ../serverless-client/dist/esm/index.mjs
13
- import { createRequire as createRequire2 } from "node:module";
13
+ import * as tty from "tty";
14
14
  var __create = Object.create;
15
15
  var __getProtoOf = Object.getPrototypeOf;
16
16
  var __defProp = Object.defineProperty;
@@ -28,642 +28,6 @@ var __toESM = (mod, isNodeMode, target) => {
28
28
  return to;
29
29
  };
30
30
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
31
- var __require2 = /* @__PURE__ */ createRequire2(import.meta.url);
32
- var require_is_color_supported = __commonJS((exports) => {
33
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
34
- if (k2 === undefined)
35
- k2 = k;
36
- var desc = Object.getOwnPropertyDescriptor(m, k);
37
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
38
- desc = { enumerable: true, get: function() {
39
- return m[k];
40
- } };
41
- }
42
- Object.defineProperty(o, k2, desc);
43
- } : function(o, m, k, k2) {
44
- if (k2 === undefined)
45
- k2 = k;
46
- o[k2] = m[k];
47
- });
48
- var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
49
- Object.defineProperty(o, "default", { enumerable: true, value: v });
50
- } : function(o, v) {
51
- o["default"] = v;
52
- });
53
- var __importStar = exports && exports.__importStar || function(mod) {
54
- if (mod && mod.__esModule)
55
- return mod;
56
- var result = {};
57
- if (mod != null) {
58
- for (var k in mod)
59
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
60
- __createBinding(result, mod, k);
61
- }
62
- __setModuleDefault(result, mod);
63
- return result;
64
- };
65
- Object.defineProperty(exports, "__esModule", { value: true });
66
- exports.isColorSupported = undefined;
67
- var tty = __importStar(__require2("tty"));
68
- var isColorSupported = () => {
69
- var _a;
70
- const env = process.env || {};
71
- const isForceDisabled = "NO_COLOR" in env;
72
- if (isForceDisabled) {
73
- return false;
74
- }
75
- const isForced = "FORCE_COLOR" in env;
76
- if (isForced) {
77
- return true;
78
- }
79
- const isWindows = process.platform === "win32";
80
- const isCompatibleTerminal = ((_a = tty === null || tty === undefined ? undefined : tty.isatty) === null || _a === undefined ? undefined : _a.call(tty, 1)) && env.TERM && env.TERM !== "dumb";
81
- const isCI = "CI" in env && (("GITHUB_ACTIONS" in env) || ("GITLAB_CI" in env) || ("CIRCLECI" in env));
82
- return isWindows || isCompatibleTerminal || isCI;
83
- };
84
- exports.isColorSupported = isColorSupported;
85
- });
86
- var require_chalk = __commonJS((exports) => {
87
- Object.defineProperty(exports, "__esModule", { value: true });
88
- exports.chalk = undefined;
89
- var is_color_supported_1 = require_is_color_supported();
90
- exports.chalk = (() => {
91
- const colors = {
92
- enabled: () => (0, is_color_supported_1.isColorSupported)(),
93
- visible: true,
94
- styles: {},
95
- keys: {}
96
- };
97
- const ansi = (st) => {
98
- const open = `\x1B[${st.codes[0]}m`;
99
- const close = `\x1B[${st.codes[1]}m`;
100
- const regex = new RegExp(`\\u001b\\[${st.codes[1]}m`, "g");
101
- st.wrap = (input, newline) => {
102
- if (input.includes(close))
103
- input = input.replace(regex, close + open);
104
- const output = open + input + close;
105
- return newline ? output.replace(/\r*\n/g, `${close}$&${open}`) : output;
106
- };
107
- return st;
108
- };
109
- const wrap = (sty, input, newline) => {
110
- var _a;
111
- return (_a = sty.wrap) === null || _a === undefined ? undefined : _a.call(sty, input, newline);
112
- };
113
- const style = (input, stack) => {
114
- if (input === "" || input === null || input === undefined)
115
- return "";
116
- if (colors.enabled() === false)
117
- return input;
118
- if (colors.visible === false)
119
- return "";
120
- let str = String(input);
121
- const nl = str.includes(`
122
- `);
123
- let n = stack.length;
124
- while (n-- > 0)
125
- str = wrap(colors.styles[stack[n]], str, nl);
126
- return str;
127
- };
128
- const define = (name, codes, type) => {
129
- colors.styles[name] = ansi({ name, codes });
130
- const keys = colors.keys[type] || (colors.keys[type] = []);
131
- keys.push(name);
132
- Reflect.defineProperty(colors, name, {
133
- configurable: true,
134
- enumerable: true,
135
- set(value) {
136
- var _a;
137
- (_a = colors.alias) === null || _a === undefined || _a.call(colors, name, value);
138
- },
139
- get() {
140
- const color = (input) => style(input, color.stack);
141
- Reflect.setPrototypeOf(color, colors);
142
- color.stack = this.stack ? this.stack.concat(name) : [name];
143
- return color;
144
- }
145
- });
146
- };
147
- define("reset", [0, 0], "modifier");
148
- define("bold", [1, 22], "modifier");
149
- define("dim", [2, 22], "modifier");
150
- define("italic", [3, 23], "modifier");
151
- define("underline", [4, 24], "modifier");
152
- define("inverse", [7, 27], "modifier");
153
- define("hidden", [8, 28], "modifier");
154
- define("strikethrough", [9, 29], "modifier");
155
- define("black", [30, 39], "color");
156
- define("red", [31, 39], "color");
157
- define("green", [32, 39], "color");
158
- define("yellow", [33, 39], "color");
159
- define("blue", [34, 39], "color");
160
- define("magenta", [35, 39], "color");
161
- define("cyan", [36, 39], "color");
162
- define("white", [37, 39], "color");
163
- define("gray", [90, 39], "color");
164
- define("grey", [90, 39], "color");
165
- define("bgBlack", [40, 49], "bg");
166
- define("bgRed", [41, 49], "bg");
167
- define("bgGreen", [42, 49], "bg");
168
- define("bgYellow", [43, 49], "bg");
169
- define("bgBlue", [44, 49], "bg");
170
- define("bgMagenta", [45, 49], "bg");
171
- define("bgWhite", [47, 49], "bg");
172
- define("blackBright", [90, 39], "bright");
173
- define("redBright", [91, 39], "bright");
174
- define("greenBright", [92, 39], "bright");
175
- define("yellowBright", [93, 39], "bright");
176
- define("blueBright", [94, 39], "bright");
177
- define("magentaBright", [95, 39], "bright");
178
- define("whiteBright", [97, 39], "bright");
179
- define("bgBlackBright", [100, 49], "bgBright");
180
- define("bgRedBright", [101, 49], "bgBright");
181
- define("bgGreenBright", [102, 49], "bgBright");
182
- define("bgYellowBright", [103, 49], "bgBright");
183
- define("bgBlueBright", [104, 49], "bgBright");
184
- define("bgMagentaBright", [105, 49], "bgBright");
185
- define("bgWhiteBright", [107, 49], "bgBright");
186
- colors.alias = (name, color) => {
187
- const fn = colors[color];
188
- if (typeof fn !== "function") {
189
- throw new TypeError("Expected alias to be the name of an existing color (string) or a function");
190
- }
191
- if (!fn.stack) {
192
- Reflect.defineProperty(fn, "name", { value: name });
193
- colors.styles[name] = fn;
194
- fn.stack = [name];
195
- }
196
- Reflect.defineProperty(colors, name, {
197
- configurable: true,
198
- enumerable: true,
199
- set(value) {
200
- var _a;
201
- (_a = colors.alias) === null || _a === undefined || _a.call(colors, name, value);
202
- },
203
- get() {
204
- const col = (input) => style(input, col.stack);
205
- Reflect.setPrototypeOf(col, colors);
206
- col.stack = this.stack ? this.stack.concat(fn.stack) : fn.stack;
207
- return col;
208
- }
209
- });
210
- };
211
- return colors;
212
- })();
213
- });
214
- var require_log_level = __commonJS((exports) => {
215
- Object.defineProperty(exports, "__esModule", { value: true });
216
- exports.isEqualOrBelowLogLevel = exports.isValidLogLevel = exports.logLevels = undefined;
217
- exports.logLevels = ["trace", "verbose", "info", "warn", "error"];
218
- var getNumberForLogLevel = (level) => {
219
- return exports.logLevels.indexOf(level);
220
- };
221
- var isValidLogLevel = (level) => {
222
- return getNumberForLogLevel(level) > -1;
223
- };
224
- exports.isValidLogLevel = isValidLogLevel;
225
- var isEqualOrBelowLogLevel = (currentLevel, level) => {
226
- return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);
227
- };
228
- exports.isEqualOrBelowLogLevel = isEqualOrBelowLogLevel;
229
- });
230
- var require_version = __commonJS((exports) => {
231
- Object.defineProperty(exports, "__esModule", { value: true });
232
- exports.VERSION = undefined;
233
- exports.VERSION = "4.0.267";
234
- });
235
- var require_find_closest_package_json = __commonJS((exports) => {
236
- var __importDefault = exports && exports.__importDefault || function(mod) {
237
- return mod && mod.__esModule ? mod : { default: mod };
238
- };
239
- Object.defineProperty(exports, "__esModule", { value: true });
240
- exports.findRemotionRoot = exports.findClosestPackageJson = undefined;
241
- var node_fs_1 = __importDefault(__require2("node:fs"));
242
- var node_path_1 = __importDefault(__require2("node:path"));
243
- var recursionLimit = 5;
244
- var findClosestPackageJson = () => {
245
- let currentDir = process.cwd();
246
- let possiblePackageJson = "";
247
- for (let i = 0;i < recursionLimit; i++) {
248
- possiblePackageJson = node_path_1.default.join(currentDir, "package.json");
249
- const exists = node_fs_1.default.existsSync(possiblePackageJson);
250
- if (exists) {
251
- return possiblePackageJson;
252
- }
253
- currentDir = node_path_1.default.dirname(currentDir);
254
- }
255
- return null;
256
- };
257
- exports.findClosestPackageJson = findClosestPackageJson;
258
- var findRemotionRoot = () => {
259
- const closestPackageJson = (0, exports.findClosestPackageJson)();
260
- if (closestPackageJson === null) {
261
- return process.cwd();
262
- }
263
- return node_path_1.default.dirname(closestPackageJson);
264
- };
265
- exports.findRemotionRoot = findRemotionRoot;
266
- });
267
- var require_is_serve_url = __commonJS((exports) => {
268
- Object.defineProperty(exports, "__esModule", { value: true });
269
- exports.isServeUrl = undefined;
270
- var isServeUrl = (potentialUrl) => {
271
- if (typeof potentialUrl === "undefined") {
272
- throw new Error("serveUrl is undefined");
273
- }
274
- if (potentialUrl.startsWith("www.") || potentialUrl.includes("amazonaws.com")) {
275
- return true;
276
- }
277
- return potentialUrl.startsWith("https://") || potentialUrl.startsWith("http://");
278
- };
279
- exports.isServeUrl = isServeUrl;
280
- });
281
- var require_repro = __commonJS((exports) => {
282
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
283
- if (k2 === undefined)
284
- k2 = k;
285
- var desc = Object.getOwnPropertyDescriptor(m, k);
286
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
287
- desc = { enumerable: true, get: function() {
288
- return m[k];
289
- } };
290
- }
291
- Object.defineProperty(o, k2, desc);
292
- } : function(o, m, k, k2) {
293
- if (k2 === undefined)
294
- k2 = k;
295
- o[k2] = m[k];
296
- });
297
- var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
298
- Object.defineProperty(o, "default", { enumerable: true, value: v });
299
- } : function(o, v) {
300
- o["default"] = v;
301
- });
302
- var __importStar = exports && exports.__importStar || function(mod) {
303
- if (mod && mod.__esModule)
304
- return mod;
305
- var result = {};
306
- if (mod != null) {
307
- for (var k in mod)
308
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
309
- __createBinding(result, mod, k);
310
- }
311
- __setModuleDefault(result, mod);
312
- return result;
313
- };
314
- var __importDefault = exports && exports.__importDefault || function(mod) {
315
- return mod && mod.__esModule ? mod : { default: mod };
316
- };
317
- Object.defineProperty(exports, "__esModule", { value: true });
318
- exports.isReproEnabled = exports.disableRepro = exports.enableRepro = exports.writeInRepro = exports.getReproWriter = undefined;
319
- var node_child_process_1 = __require2("node:child_process");
320
- var node_fs_1 = __importStar(__require2("node:fs"));
321
- var node_os_1 = __importDefault(__require2("node:os"));
322
- var node_path_1 = __importDefault(__require2("node:path"));
323
- var version_1 = require_version();
324
- var chalk_1 = require_chalk();
325
- var find_closest_package_json_1 = require_find_closest_package_json();
326
- var is_serve_url_1 = require_is_serve_url();
327
- var logger_1 = require_logger();
328
- var REPRO_DIR = ".remotionrepro";
329
- var LOG_FILE_NAME = "logs.txt";
330
- var INPUT_DIR = "bundle";
331
- var OUTPUT_DIR = "output";
332
- var LINE_SPLIT = `
333
- `;
334
- var getZipFileName = (name) => `remotion-repro-${name}-${Date.now()}.zip`;
335
- var readyDirSync = (dir) => {
336
- let items;
337
- try {
338
- items = node_fs_1.default.readdirSync(dir);
339
- } catch (_a) {
340
- return node_fs_1.default.mkdirSync(dir, { recursive: true });
341
- }
342
- items.forEach((item) => {
343
- item = node_path_1.default.join(dir, item);
344
- node_fs_1.default.rmSync(item, { recursive: true, force: true });
345
- });
346
- };
347
- var zipFolder = ({ sourceFolder, targetZip, indent, logLevel }) => {
348
- const platform = node_os_1.default.platform();
349
- try {
350
- logger_1.Log.info({ indent, logLevel }, "+ Creating reproduction ZIP");
351
- if (platform === "win32") {
352
- (0, node_child_process_1.execSync)(`powershell.exe Compress-Archive -Path "${sourceFolder}" -DestinationPath "${targetZip}"`);
353
- } else {
354
- (0, node_child_process_1.execSync)(`zip -r "${targetZip}" "${sourceFolder}"`);
355
- }
356
- (0, node_fs_1.rmSync)(sourceFolder, { recursive: true });
357
- logger_1.Log.info({ indent, logLevel }, `${chalk_1.chalk.blue(`+ Repro: ${targetZip}`)}`);
358
- } catch (error) {
359
- logger_1.Log.error({ indent, logLevel }, `Failed to zip repro folder, The repro folder is ${sourceFolder}. You can try manually zip it.`);
360
- logger_1.Log.error({ indent, logLevel }, error);
361
- }
362
- };
363
- var reproWriter = (name) => {
364
- const root = (0, find_closest_package_json_1.findRemotionRoot)();
365
- const reproFolder = node_path_1.default.join(root, REPRO_DIR);
366
- const logPath = node_path_1.default.join(reproFolder, LOG_FILE_NAME);
367
- const zipFile = node_path_1.default.join(root, getZipFileName(name));
368
- readyDirSync(reproFolder);
369
- const reproLogWriteStream = node_fs_1.default.createWriteStream(logPath, { flags: "a" });
370
- const serializeArgs = (args) => JSON.stringify(args);
371
- const writeLine = (level, ...args) => {
372
- if (!args.length)
373
- return;
374
- const startTime = new Date().toISOString();
375
- const line = `[${startTime}] ${level} ${serializeArgs(args)}`;
376
- reproLogWriteStream.write(line + LINE_SPLIT);
377
- };
378
- const start = ({ serveUrl, serializedInputPropsWithCustomSchema, serializedResolvedPropsWithCustomSchema }) => {
379
- const isServe = (0, is_serve_url_1.isServeUrl)(serveUrl);
380
- if (!isServe) {
381
- const inputDir = node_path_1.default.resolve(reproFolder, INPUT_DIR);
382
- readyDirSync(inputDir);
383
- node_fs_1.default.cpSync(serveUrl, inputDir, { recursive: true });
384
- }
385
- const serializedProps = node_path_1.default.resolve(reproFolder, "input-props.json");
386
- node_fs_1.default.writeFileSync(serializedProps, serializedInputPropsWithCustomSchema);
387
- const serializedResolvedProps = node_path_1.default.resolve(reproFolder, "resolved-props.json");
388
- node_fs_1.default.writeFileSync(serializedResolvedProps, serializedResolvedPropsWithCustomSchema);
389
- writeLine("info", [`Args: ${JSON.stringify(process.argv)}`]);
390
- writeLine("info", [`Node/Bun version: ${process.version}`]);
391
- writeLine("info", [`OS: ${process.platform}-${process.arch}`]);
392
- writeLine("info", [`Serve URL: ${serveUrl}`]);
393
- writeLine("info", [`Remotion version: ${version_1.VERSION}`]);
394
- };
395
- const onRenderSucceed = ({ indent, logLevel, output }) => {
396
- return new Promise((resolve, reject) => {
397
- try {
398
- if (output) {
399
- const outputDir = node_path_1.default.resolve(reproFolder, OUTPUT_DIR);
400
- readyDirSync(outputDir);
401
- const fileName = node_path_1.default.basename(output);
402
- const targetPath = node_path_1.default.join(outputDir, fileName);
403
- node_fs_1.default.copyFileSync(output, targetPath);
404
- }
405
- (0, exports.disableRepro)();
406
- reproLogWriteStream.end(() => {
407
- reproLogWriteStream.close(() => {
408
- zipFolder({
409
- sourceFolder: reproFolder,
410
- targetZip: zipFile,
411
- indent,
412
- logLevel
413
- });
414
- resolve();
415
- });
416
- });
417
- } catch (error) {
418
- logger_1.Log.error({ indent: false, logLevel }, `repro render success error:`);
419
- logger_1.Log.error({ indent: false, logLevel }, error);
420
- reject(error);
421
- }
422
- });
423
- };
424
- return {
425
- start,
426
- writeLine,
427
- onRenderSucceed
428
- };
429
- };
430
- var reproWriteInstance = null;
431
- var getReproWriter = () => {
432
- if (!reproWriteInstance) {
433
- throw new Error("reproWriteInstance is not initialized");
434
- }
435
- return reproWriteInstance;
436
- };
437
- exports.getReproWriter = getReproWriter;
438
- var writeInRepro = (level, ...args) => {
439
- if ((0, exports.isReproEnabled)()) {
440
- (0, exports.getReproWriter)().writeLine(level, ...args);
441
- }
442
- };
443
- exports.writeInRepro = writeInRepro;
444
- var shouldRepro = false;
445
- var enableRepro = ({ serveUrl, compositionName, serializedInputPropsWithCustomSchema, serializedResolvedPropsWithCustomSchema }) => {
446
- shouldRepro = true;
447
- reproWriteInstance = reproWriter(compositionName);
448
- (0, exports.getReproWriter)().start({
449
- serveUrl,
450
- serializedInputPropsWithCustomSchema,
451
- serializedResolvedPropsWithCustomSchema
452
- });
453
- };
454
- exports.enableRepro = enableRepro;
455
- var disableRepro = () => {
456
- shouldRepro = false;
457
- };
458
- exports.disableRepro = disableRepro;
459
- var isReproEnabled = () => shouldRepro;
460
- exports.isReproEnabled = isReproEnabled;
461
- });
462
- var require_truthy = __commonJS((exports) => {
463
- Object.defineProperty(exports, "__esModule", { value: true });
464
- exports.truthy = truthy2;
465
- function truthy2(value) {
466
- return Boolean(value);
467
- }
468
- });
469
- var require_logger = __commonJS((exports) => {
470
- Object.defineProperty(exports, "__esModule", { value: true });
471
- exports.Log = exports.secondverboseTag = exports.verboseTag = exports.INDENT_TOKEN = undefined;
472
- var chalk_1 = require_chalk();
473
- var is_color_supported_1 = require_is_color_supported();
474
- var log_level_1 = require_log_level();
475
- var repro_1 = require_repro();
476
- var truthy_1 = require_truthy();
477
- exports.INDENT_TOKEN = chalk_1.chalk.gray("│");
478
- var verboseTag = (str) => {
479
- return (0, is_color_supported_1.isColorSupported)() ? chalk_1.chalk.bgBlack(` ${str} `) : `[${str}]`;
480
- };
481
- exports.verboseTag = verboseTag;
482
- var secondverboseTag = (str) => {
483
- return (0, is_color_supported_1.isColorSupported)() ? chalk_1.chalk.bgWhite(` ${str} `) : `[${str}]`;
484
- };
485
- exports.secondverboseTag = secondverboseTag;
486
- exports.Log = {
487
- trace: (options, ...args) => {
488
- (0, repro_1.writeInRepro)("trace", ...args);
489
- if ((0, log_level_1.isEqualOrBelowLogLevel)(options.logLevel, "trace")) {
490
- if (args.length === 0) {
491
- return process.stdout.write(`
492
- `);
493
- }
494
- return console.log(...[
495
- options.indent ? exports.INDENT_TOKEN : null,
496
- options.tag ? (0, exports.verboseTag)(options.tag) : null
497
- ].filter(truthy_1.truthy).concat(args.map((a) => chalk_1.chalk.gray(a))));
498
- }
499
- },
500
- verbose: (options, ...args) => {
501
- (0, repro_1.writeInRepro)("verbose", ...args);
502
- if ((0, log_level_1.isEqualOrBelowLogLevel)(options.logLevel, "verbose")) {
503
- if (args.length === 0) {
504
- return process.stdout.write(`
505
- `);
506
- }
507
- return console.log(...[
508
- options.indent ? exports.INDENT_TOKEN : null,
509
- options.tag ? (0, exports.verboseTag)(options.tag) : null
510
- ].filter(truthy_1.truthy).concat(args.map((a) => chalk_1.chalk.gray(a))));
511
- }
512
- },
513
- info: (options, ...args) => {
514
- (0, repro_1.writeInRepro)("info", ...args);
515
- if ((0, log_level_1.isEqualOrBelowLogLevel)(options.logLevel, "info")) {
516
- if (args.length === 0) {
517
- return process.stdout.write(`
518
- `);
519
- }
520
- return console.log(...[options.indent ? exports.INDENT_TOKEN : null].filter(truthy_1.truthy).concat(args !== null && args !== undefined ? args : []));
521
- }
522
- },
523
- warn: (options, ...args) => {
524
- (0, repro_1.writeInRepro)("warn", ...args);
525
- if ((0, log_level_1.isEqualOrBelowLogLevel)(options.logLevel, "warn")) {
526
- if (args.length === 0) {
527
- return process.stdout.write(`
528
- `);
529
- }
530
- return console.warn(...[options.indent ? chalk_1.chalk.yellow(exports.INDENT_TOKEN) : null].filter(truthy_1.truthy).concat(args.map((a) => chalk_1.chalk.yellow(a))));
531
- }
532
- },
533
- error: (options, ...args) => {
534
- (0, repro_1.writeInRepro)("error", ...args);
535
- if ((0, log_level_1.isEqualOrBelowLogLevel)(options.logLevel, "error")) {
536
- if (args.length === 0) {
537
- return process.stdout.write(`
538
- `);
539
- }
540
- return console.error(...[
541
- options.indent ? exports.INDENT_TOKEN : null,
542
- options.tag ? (0, exports.verboseTag)(options.tag) : null
543
- ].filter(truthy_1.truthy).concat(args.map((a) => chalk_1.chalk.red(a))));
544
- }
545
- }
546
- };
547
- });
548
- var require_print_useful_error_message = __commonJS((exports) => {
549
- Object.defineProperty(exports, "__esModule", { value: true });
550
- exports.printUsefulErrorMessage = undefined;
551
- var logger_1 = require_logger();
552
- var truthy_1 = require_truthy();
553
- var alreadyPrintedCache = [];
554
- var printUsefulErrorMessage = (err, logLevel, indent) => {
555
- var _a, _b;
556
- const errorStack = err.stack;
557
- if (errorStack && alreadyPrintedCache.includes(errorStack)) {
558
- return;
559
- }
560
- if (errorStack) {
561
- alreadyPrintedCache.push(errorStack);
562
- alreadyPrintedCache = alreadyPrintedCache.slice(-10);
563
- }
564
- if (err.message.includes("Could not play video with")) {
565
- logger_1.Log.info({ indent, logLevel });
566
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/media-playback-error");
567
- }
568
- if (err.message.includes("A delayRender()") && err.message.includes("was called but not cleared after")) {
569
- logger_1.Log.info({ indent, logLevel });
570
- if (err.message.includes("/proxy")) {
571
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/troubleshooting/delay-render-proxy");
572
- }
573
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/timeout");
574
- }
575
- if (err.message.includes("Target closed")) {
576
- logger_1.Log.info({ indent, logLevel });
577
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/target-closed");
578
- }
579
- if (err.message.includes("Timed out evaluating")) {
580
- logger_1.Log.info({ indent, logLevel });
581
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/troubleshooting/timed-out-page-function");
582
- }
583
- if (err.message.includes("ENAMETOOLONG")) {
584
- logger_1.Log.info({ indent, logLevel });
585
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/enametoolong");
586
- }
587
- if (err.message.includes("Member must have value less than or equal to 3008")) {
588
- logger_1.Log.info({ indent, logLevel });
589
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error indicates that you have a AWS account on the free tier or have been limited by your organization. Often times this can be solved by adding a credit card. See also: https://repost.aws/questions/QUKruWYNDYTSmP17jCnIz6IQ/questions/QUKruWYNDYTSmP17jCnIz6IQ/unable-to-set-lambda-memory-over-3008mb");
590
- }
591
- if ((_a = err.stack) === null || _a === undefined ? undefined : _a.includes("TooManyRequestsException: Rate Exceeded.")) {
592
- logger_1.Log.info({ indent, logLevel });
593
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error indicates that your Lambda concurrency limit is too low. See: https://www.remotion.dev/docs/lambda/troubleshooting/rate-limit");
594
- }
595
- if (err.message.includes("Error creating WebGL context")) {
596
- logger_1.Log.info({ indent, logLevel });
597
- logger_1.Log.warn({
598
- indent,
599
- logLevel
600
- }, '\uD83D\uDCA1 You might need to set the OpenGL renderer to "angle-egl", "angle" (or "swangle" if rendering on lambda). Learn why at https://www.remotion.dev/docs/three');
601
- logger_1.Log.warn({
602
- indent,
603
- logLevel
604
- }, "\uD83D\uDCA1 Check how it's done at https://www.remotion.dev/docs/chromium-flags#--gl");
605
- }
606
- if (err.message.includes("The bucket does not allow ACLs")) {
607
- logger_1.Log.info({ indent, logLevel });
608
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Fix for this issue: https://remotion.dev/docs/lambda/troubleshooting/bucket-disallows-acl");
609
- }
610
- if (err.message.includes("Minified React error #306")) {
611
- const componentName = (_b = err.message.match(/<\w+>/)) === null || _b === undefined ? undefined : _b[0];
612
- logger_1.Log.info({ indent, logLevel }, [
613
- "\uD83D\uDCA1 This error indicates that the component",
614
- componentName ? `(${componentName})` : null,
615
- "you are trying to render is not imported correctly."
616
- ].filter(truthy_1.truthy).join(" "));
617
- logger_1.Log.info({ indent, logLevel });
618
- logger_1.Log.info({ indent, logLevel }, " Check the root file and ensure that the component is not undefined.");
619
- logger_1.Log.info({ indent, logLevel }, " Oftentimes, this happens if the component is missing the `export` keyword");
620
- logger_1.Log.info({ indent, logLevel }, " or if the component was renamed and the import statement not properly adjusted.");
621
- }
622
- if (err.message.includes("GLIBC_")) {
623
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Remotion requires at least Libc 2.35.");
624
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue: https://github.com/remotion-dev/remotion/issues/2439");
625
- }
626
- if (err.message.includes("EBADF")) {
627
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error might be fixed by changing your Node version:");
628
- logger_1.Log.info({ indent, logLevel }, " https://github.com/remotion-dev/remotion/issues/2452");
629
- }
630
- if (err.message.includes("routines::unsupported")) {
631
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error might happen if using Cloud Run with credentials that have a newline at the end or are otherwise badly encoded.");
632
- logger_1.Log.info({ indent, logLevel }, " https://github.com/remotion-dev/remotion/issues/3864");
633
- }
634
- if (err.message.includes("Failed to fetch")) {
635
- logger_1.Log.info({ indent, logLevel }, "\uD83D\uDCA1 On Lambda, one reason this could happen is that Chrome is rejecting an asset to be loaded when it is running low on disk space.");
636
- logger_1.Log.info({ indent, logLevel }, "Try increasing the disk size of your Lambda function.");
637
- }
638
- };
639
- exports.printUsefulErrorMessage = printUsefulErrorMessage;
640
- });
641
- var require_wrap_with_error_handling = __commonJS((exports) => {
642
- Object.defineProperty(exports, "__esModule", { value: true });
643
- exports.wrapWithErrorHandling = undefined;
644
- var print_useful_error_message_1 = require_print_useful_error_message();
645
- var wrapWithErrorHandling = (fn) => {
646
- return async (...args) => {
647
- try {
648
- return await fn(...args);
649
- } catch (err) {
650
- const { indent } = args[0];
651
- const { logLevel } = args[0];
652
- (0, print_useful_error_message_1.printUsefulErrorMessage)(err, logLevel, indent);
653
- throw err;
654
- }
655
- };
656
- };
657
- exports.wrapWithErrorHandling = wrapWithErrorHandling;
658
- });
659
- var require_error_handling = __commonJS((exports) => {
660
- Object.defineProperty(exports, "__esModule", { value: true });
661
- exports.wrapWithErrorHandling = undefined;
662
- var wrap_with_error_handling_1 = require_wrap_with_error_handling();
663
- Object.defineProperty(exports, "wrapWithErrorHandling", { enumerable: true, get: function() {
664
- return wrap_with_error_handling_1.wrapWithErrorHandling;
665
- } });
666
- });
667
31
  var require_make_stream_payload_message = __commonJS((exports) => {
668
32
  Object.defineProperty(exports, "__esModule", { value: true });
669
33
  exports.makeStreamPayloadMessage = exports.magicWordStr = undefined;
@@ -794,799 +158,53 @@ var require_make_streamer = __commonJS((exports) => {
794
158
  outputBuffer = newBuffer;
795
159
  unprocessedBuffers = [];
796
160
  processInput();
797
- };
798
- return {
799
- onData,
800
- getOutputBuffer: () => outputBuffer,
801
- clear: () => {
802
- unprocessedBuffers = [];
803
- outputBuffer = new Uint8Array(0);
804
- }
805
- };
806
- };
807
- exports.makeStreamer = makeStreamer;
808
- var makeStreamPayloadMessage = ({ status, body, nonce }) => {
809
- const nonceArr = new TextEncoder().encode(nonce);
810
- const magicWordArr = new TextEncoder().encode(exports.streamingKey);
811
- const separatorArr = new TextEncoder().encode(":");
812
- const bodyLengthArr = new TextEncoder().encode(body.length.toString());
813
- const statusArr = new TextEncoder().encode(String(status));
814
- const totalLength = nonceArr.length + magicWordArr.length + separatorArr.length * 3 + bodyLengthArr.length + statusArr.length + body.length;
815
- const concat = new Uint8Array(totalLength);
816
- let offset = 0;
817
- const appendToConcat = (data) => {
818
- concat.set(data, offset);
819
- offset += data.length;
820
- };
821
- appendToConcat(magicWordArr);
822
- appendToConcat(nonceArr);
823
- appendToConcat(separatorArr);
824
- appendToConcat(bodyLengthArr);
825
- appendToConcat(separatorArr);
826
- appendToConcat(statusArr);
827
- appendToConcat(separatorArr);
828
- appendToConcat(body);
829
- return concat;
830
- };
831
- exports.makeStreamPayloadMessage = makeStreamPayloadMessage;
832
- });
833
- var require_dist = __commonJS((exports) => {
834
- Object.defineProperty(exports, "__esModule", { value: true });
835
- exports.makeStreamer = exports.makeStreamPayloadMessage = undefined;
836
- var make_stream_payload_message_1 = require_make_stream_payload_message();
837
- Object.defineProperty(exports, "makeStreamPayloadMessage", { enumerable: true, get: function() {
838
- return make_stream_payload_message_1.makeStreamPayloadMessage;
839
- } });
840
- var make_streamer_1 = require_make_streamer();
841
- Object.defineProperty(exports, "makeStreamer", { enumerable: true, get: function() {
842
- return make_streamer_1.makeStreamer;
843
- } });
844
- });
845
- var require_is_audio_codec = __commonJS((exports) => {
846
- Object.defineProperty(exports, "__esModule", { value: true });
847
- exports.isAudioCodec = undefined;
848
- var isAudioCodec = (codec) => {
849
- return codec === "mp3" || codec === "aac" || codec === "wav";
850
- };
851
- exports.isAudioCodec = isAudioCodec;
852
- });
853
- var require_crf = __commonJS((exports) => {
854
- Object.defineProperty(exports, "__esModule", { value: true });
855
- exports.validateQualitySettings = exports.getValidCrfRanges = exports.getDefaultCrfForCodec = undefined;
856
- var is_audio_codec_1 = require_is_audio_codec();
857
- var defaultCrfMap = {
858
- h264: 18,
859
- h265: 23,
860
- vp8: 9,
861
- vp9: 28,
862
- prores: null,
863
- gif: null,
864
- "h264-mkv": 18,
865
- "h264-ts": 18,
866
- aac: null,
867
- mp3: null,
868
- wav: null
869
- };
870
- var getDefaultCrfForCodec = (codec) => {
871
- const val = defaultCrfMap[codec];
872
- if (val === undefined) {
873
- throw new TypeError(`Got unexpected codec "${codec}"`);
874
- }
875
- return val;
876
- };
877
- exports.getDefaultCrfForCodec = getDefaultCrfForCodec;
878
- var crfRanges = {
879
- h264: [1, 51],
880
- h265: [0, 51],
881
- vp8: [4, 63],
882
- vp9: [0, 63],
883
- prores: [0, 0],
884
- gif: [0, 0],
885
- "h264-mkv": [1, 51],
886
- "h264-ts": [1, 51],
887
- aac: [0, 0],
888
- mp3: [0, 0],
889
- wav: [0, 0]
890
- };
891
- var getValidCrfRanges = (codec) => {
892
- const val = crfRanges[codec];
893
- if (val === undefined) {
894
- throw new TypeError(`Got unexpected codec "${codec}"`);
895
- }
896
- return val;
897
- };
898
- exports.getValidCrfRanges = getValidCrfRanges;
899
- var validateQualitySettings = ({ codec, crf, videoBitrate, encodingMaxRate, encodingBufferSize, hardwareAcceleration }) => {
900
- if (crf && videoBitrate) {
901
- throw new Error('"crf" and "videoBitrate" can not both be set. Choose one of either.');
902
- }
903
- if (crf && hardwareAcceleration === "required") {
904
- throw new Error('"crf" option is not supported with hardware acceleration');
905
- }
906
- if (encodingMaxRate && !encodingBufferSize) {
907
- throw new Error('"encodingMaxRate" can not be set without also setting "encodingBufferSize".');
908
- }
909
- const bufSizeArray = encodingBufferSize ? ["-bufsize", encodingBufferSize] : [];
910
- const maxRateArray = encodingMaxRate ? ["-maxrate", encodingMaxRate] : [];
911
- if (videoBitrate) {
912
- if (codec === "prores") {
913
- console.warn("ProRes does not support videoBitrate. Ignoring.");
914
- return [];
915
- }
916
- if ((0, is_audio_codec_1.isAudioCodec)(codec)) {
917
- console.warn(`${codec} does not support videoBitrate. Ignoring.`);
918
- return [];
919
- }
920
- return ["-b:v", videoBitrate, ...bufSizeArray, ...maxRateArray];
921
- }
922
- if (crf === null || typeof crf === "undefined") {
923
- const actualCrf = (0, exports.getDefaultCrfForCodec)(codec);
924
- if (actualCrf === null) {
925
- return [...bufSizeArray, ...maxRateArray];
926
- }
927
- return ["-crf", String(actualCrf), ...bufSizeArray, ...maxRateArray];
928
- }
929
- if (typeof crf !== "number") {
930
- throw new TypeError("Expected CRF to be a number, but is " + JSON.stringify(crf));
931
- }
932
- const range = (0, exports.getValidCrfRanges)(codec);
933
- if (crf === 0 && (codec === "h264" || codec === "h264-mkv" || codec === "h264-ts")) {
934
- throw new TypeError("Setting the CRF to 0 with a H264 codec is not supported anymore because of it's inconsistencies between platforms. Videos with CRF 0 cannot be played on iOS/macOS. 0 is a extreme value with inefficient settings which you probably do not want. Set CRF to a higher value to fix this error.");
935
- }
936
- if (crf < range[0] || crf > range[1]) {
937
- if (range[0] === 0 && range[1] === 0) {
938
- throw new TypeError(`The "${codec}" codec does not support the --crf option.`);
939
- }
940
- throw new TypeError(`CRF must be between ${range[0]} and ${range[1]} for codec ${codec}. Passed: ${crf}`);
941
- }
942
- if (codec === "prores") {
943
- console.warn('ProRes does not support the "crf" option. Ignoring.');
944
- return [];
945
- }
946
- if ((0, is_audio_codec_1.isAudioCodec)(codec)) {
947
- console.warn(`${codec} does not support the "crf" option. Ignoring.`);
948
- return [];
949
- }
950
- return ["-crf", String(crf), ...bufSizeArray, ...maxRateArray];
951
- };
952
- exports.validateQualitySettings = validateQualitySettings;
953
- });
954
- var require_codec_supports_media = __commonJS((exports) => {
955
- Object.defineProperty(exports, "__esModule", { value: true });
956
- exports.codecSupportsVideoBitrate = exports.codecSupportsCrf = exports.codecSupportsMedia = undefined;
957
- var crf_1 = require_crf();
958
- var support = {
959
- "h264-mkv": {
960
- audio: true,
961
- video: true
962
- },
963
- aac: {
964
- audio: true,
965
- video: false
966
- },
967
- gif: {
968
- video: true,
969
- audio: false
970
- },
971
- h264: {
972
- video: true,
973
- audio: true
974
- },
975
- "h264-ts": {
976
- video: true,
977
- audio: true
978
- },
979
- h265: {
980
- video: true,
981
- audio: true
982
- },
983
- mp3: {
984
- audio: true,
985
- video: false
986
- },
987
- prores: {
988
- audio: true,
989
- video: true
990
- },
991
- vp8: {
992
- audio: true,
993
- video: true
994
- },
995
- vp9: {
996
- audio: true,
997
- video: true
998
- },
999
- wav: {
1000
- audio: true,
1001
- video: false
1002
- }
1003
- };
1004
- var codecSupportsMedia = (codec) => {
1005
- return support[codec];
1006
- };
1007
- exports.codecSupportsMedia = codecSupportsMedia;
1008
- var codecSupportsVideoBitrateMap = {
1009
- "h264-mkv": true,
1010
- "h264-ts": true,
1011
- aac: false,
1012
- gif: false,
1013
- h264: true,
1014
- h265: true,
1015
- mp3: false,
1016
- prores: false,
1017
- vp8: true,
1018
- vp9: true,
1019
- wav: false
1020
- };
1021
- var codecSupportsCrf = (codec) => {
1022
- const range = (0, crf_1.getValidCrfRanges)(codec);
1023
- return range[0] !== range[1];
1024
- };
1025
- exports.codecSupportsCrf = codecSupportsCrf;
1026
- var codecSupportsVideoBitrate = (codec) => {
1027
- return codecSupportsVideoBitrateMap[codec];
1028
- };
1029
- exports.codecSupportsVideoBitrate = codecSupportsVideoBitrate;
1030
- });
1031
- var require_get_duration_from_frame_range = __commonJS((exports) => {
1032
- Object.defineProperty(exports, "__esModule", { value: true });
1033
- exports.getFramesToRender = undefined;
1034
- var getFramesToRender = (frameRange, everyNthFrame) => {
1035
- if (everyNthFrame === 0) {
1036
- throw new Error("everyNthFrame cannot be 0");
1037
- }
1038
- return new Array(frameRange[1] - frameRange[0] + 1).fill(true).map((_, index) => {
1039
- return index + frameRange[0];
1040
- }).filter((index) => {
1041
- return index % everyNthFrame === 0;
1042
- });
1043
- };
1044
- exports.getFramesToRender = getFramesToRender;
1045
- });
1046
- var require_codec = __commonJS((exports) => {
1047
- Object.defineProperty(exports, "__esModule", { value: true });
1048
- exports.DEFAULT_CODEC = exports.validCodecs = undefined;
1049
- exports.validCodecs = [
1050
- "h264",
1051
- "h265",
1052
- "vp8",
1053
- "vp9",
1054
- "mp3",
1055
- "aac",
1056
- "wav",
1057
- "prores",
1058
- "h264-mkv",
1059
- "h264-ts",
1060
- "gif"
1061
- ];
1062
- exports.DEFAULT_CODEC = "h264";
1063
- });
1064
- var require_file_extensions = __commonJS((exports) => {
1065
- Object.defineProperty(exports, "__esModule", { value: true });
1066
- exports.defaultFileExtensionMap = undefined;
1067
- exports.defaultFileExtensionMap = {
1068
- "h264-mkv": {
1069
- default: "mkv",
1070
- forAudioCodec: {
1071
- "pcm-16": { possible: ["mkv"], default: "mkv" },
1072
- mp3: { possible: ["mkv"], default: "mkv" }
1073
- }
1074
- },
1075
- "h264-ts": {
1076
- default: "ts",
1077
- forAudioCodec: {
1078
- "pcm-16": { possible: ["ts"], default: "ts" },
1079
- aac: { possible: ["ts"], default: "ts" }
1080
- }
1081
- },
1082
- aac: {
1083
- default: "aac",
1084
- forAudioCodec: {
1085
- aac: {
1086
- possible: ["aac", "3gp", "m4a", "m4b", "mpg", "mpeg"],
1087
- default: "aac"
1088
- },
1089
- "pcm-16": {
1090
- possible: ["wav"],
1091
- default: "wav"
1092
- }
1093
- }
1094
- },
1095
- gif: {
1096
- default: "gif",
1097
- forAudioCodec: {}
1098
- },
1099
- h264: {
1100
- default: "mp4",
1101
- forAudioCodec: {
1102
- "pcm-16": { possible: ["mkv", "mov"], default: "mkv" },
1103
- aac: { possible: ["mp4", "mkv", "mov"], default: "mp4" },
1104
- mp3: { possible: ["mp4", "mkv", "mov"], default: "mp4" }
1105
- }
1106
- },
1107
- h265: {
1108
- default: "mp4",
1109
- forAudioCodec: {
1110
- aac: { possible: ["mp4", "mkv", "hevc"], default: "mp4" },
1111
- "pcm-16": { possible: ["mkv"], default: "mkv" }
1112
- }
1113
- },
1114
- mp3: {
1115
- default: "mp3",
1116
- forAudioCodec: {
1117
- mp3: { possible: ["mp3"], default: "mp3" },
1118
- "pcm-16": { possible: ["wav"], default: "wav" }
1119
- }
1120
- },
1121
- prores: {
1122
- default: "mov",
1123
- forAudioCodec: {
1124
- aac: { possible: ["mov", "mkv", "mxf"], default: "mov" },
1125
- "pcm-16": { possible: ["mov", "mkv", "mxf"], default: "mov" }
1126
- }
1127
- },
1128
- vp8: {
1129
- default: "webm",
1130
- forAudioCodec: {
1131
- "pcm-16": { possible: ["mkv"], default: "mkv" },
1132
- opus: { possible: ["webm"], default: "webm" }
1133
- }
1134
- },
1135
- vp9: {
1136
- default: "webm",
1137
- forAudioCodec: {
1138
- "pcm-16": { possible: ["mkv"], default: "mkv" },
1139
- opus: { possible: ["webm"], default: "webm" }
1140
- }
1141
- },
1142
- wav: {
1143
- default: "wav",
1144
- forAudioCodec: {
1145
- "pcm-16": { possible: ["wav"], default: "wav" }
1146
- }
1147
- }
1148
- };
1149
- });
1150
- var require_get_extension_from_codec = __commonJS((exports) => {
1151
- Object.defineProperty(exports, "__esModule", { value: true });
1152
- exports.defaultCodecsForFileExtension = exports.makeFileExtensionMap = exports.getFileExtensionFromCodec = undefined;
1153
- var codec_1 = require_codec();
1154
- var file_extensions_1 = require_file_extensions();
1155
- var getFileExtensionFromCodec = (codec, audioCodec) => {
1156
- if (!codec_1.validCodecs.includes(codec)) {
1157
- throw new Error(`Codec must be one of the following: ${codec_1.validCodecs.join(", ")}, but got ${codec}`);
1158
- }
1159
- const map = file_extensions_1.defaultFileExtensionMap[codec];
1160
- if (audioCodec === null) {
1161
- return map.default;
1162
- }
1163
- const typedAudioCodec = audioCodec;
1164
- if (!(typedAudioCodec in map.forAudioCodec)) {
1165
- throw new Error(`Audio codec ${typedAudioCodec} is not supported for codec ${codec}`);
1166
- }
1167
- return map.forAudioCodec[audioCodec].default;
1168
- };
1169
- exports.getFileExtensionFromCodec = getFileExtensionFromCodec;
1170
- var makeFileExtensionMap = () => {
1171
- const map = {};
1172
- Object.keys(file_extensions_1.defaultFileExtensionMap).forEach((_codec) => {
1173
- const codec = _codec;
1174
- const fileExtMap = file_extensions_1.defaultFileExtensionMap[codec];
1175
- const audioCodecs = Object.keys(fileExtMap.forAudioCodec);
1176
- const possibleExtensionsForAudioCodec = audioCodecs.map((audioCodec) => fileExtMap.forAudioCodec[audioCodec].possible);
1177
- const allPossibleExtensions = [
1178
- fileExtMap.default,
1179
- ...possibleExtensionsForAudioCodec.flat(1)
1180
- ];
1181
- for (const extension of allPossibleExtensions) {
1182
- if (!map[extension]) {
1183
- map[extension] = [];
1184
- }
1185
- if (!map[extension].includes(codec)) {
1186
- map[extension].push(codec);
1187
- }
1188
- }
1189
- });
1190
- return map;
1191
- };
1192
- exports.makeFileExtensionMap = makeFileExtensionMap;
1193
- exports.defaultCodecsForFileExtension = {
1194
- "3gp": "aac",
1195
- aac: "aac",
1196
- gif: "gif",
1197
- hevc: "h265",
1198
- m4a: "aac",
1199
- m4b: "aac",
1200
- mkv: "h264-mkv",
1201
- mov: "prores",
1202
- mp3: "mp3",
1203
- mp4: "h264",
1204
- mpeg: "aac",
1205
- mpg: "aac",
1206
- mxf: "prores",
1207
- wav: "wav",
1208
- webm: "vp8",
1209
- ts: "h264-ts"
1210
- };
1211
- });
1212
- var require_path_normalize = __commonJS((exports) => {
1213
- Object.defineProperty(exports, "__esModule", { value: true });
1214
- exports.pathNormalize = undefined;
1215
- var SLASH = 47;
1216
- var DOT = 46;
1217
- var assertPath = (path) => {
1218
- const t = typeof path;
1219
- if (t !== "string") {
1220
- throw new TypeError(`Expected a string, got a ${t}`);
1221
- }
1222
- };
1223
- var posixNormalize = (path, allowAboveRoot) => {
1224
- let res = "";
1225
- let lastSegmentLength = 0;
1226
- let lastSlash = -1;
1227
- let dots = 0;
1228
- let code;
1229
- for (let i = 0;i <= path.length; ++i) {
1230
- if (i < path.length) {
1231
- code = path.charCodeAt(i);
1232
- } else if (code === SLASH) {
1233
- break;
1234
- } else {
1235
- code = SLASH;
1236
- }
1237
- if (code === SLASH) {
1238
- if (lastSlash === i - 1 || dots === 1) {
1239
- } else if (lastSlash !== i - 1 && dots === 2) {
1240
- if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
1241
- if (res.length > 2) {
1242
- const lastSlashIndex = res.lastIndexOf("/");
1243
- if (lastSlashIndex !== res.length - 1) {
1244
- if (lastSlashIndex === -1) {
1245
- res = "";
1246
- lastSegmentLength = 0;
1247
- } else {
1248
- res = res.slice(0, lastSlashIndex);
1249
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
1250
- }
1251
- lastSlash = i;
1252
- dots = 0;
1253
- continue;
1254
- }
1255
- } else if (res.length === 2 || res.length === 1) {
1256
- res = "";
1257
- lastSegmentLength = 0;
1258
- lastSlash = i;
1259
- dots = 0;
1260
- continue;
1261
- }
1262
- }
1263
- if (allowAboveRoot) {
1264
- if (res.length > 0) {
1265
- res += "/..";
1266
- } else {
1267
- res = "..";
1268
- }
1269
- lastSegmentLength = 2;
1270
- }
1271
- } else {
1272
- if (res.length > 0) {
1273
- res += "/" + path.slice(lastSlash + 1, i);
1274
- } else {
1275
- res = path.slice(lastSlash + 1, i);
1276
- }
1277
- lastSegmentLength = i - lastSlash - 1;
1278
- }
1279
- lastSlash = i;
1280
- dots = 0;
1281
- } else if (code === DOT && dots !== -1) {
1282
- ++dots;
1283
- } else {
1284
- dots = -1;
1285
- }
1286
- }
1287
- return res;
1288
- };
1289
- var decode = (s) => {
1290
- try {
1291
- return decodeURIComponent(s);
1292
- } catch (_a) {
1293
- return s;
1294
- }
1295
- };
1296
- var pathNormalize = (p) => {
1297
- assertPath(p);
1298
- let path = p;
1299
- if (path.length === 0) {
1300
- return ".";
1301
- }
1302
- const isAbsolute = path.charCodeAt(0) === SLASH;
1303
- const trailingSeparator = path.charCodeAt(path.length - 1) === SLASH;
1304
- path = decode(path);
1305
- path = posixNormalize(path, !isAbsolute);
1306
- if (path.length === 0 && !isAbsolute) {
1307
- path = ".";
1308
- }
1309
- if (path.length > 0 && trailingSeparator) {
1310
- path += "/";
1311
- }
1312
- if (isAbsolute) {
1313
- return "/" + path;
1314
- }
1315
- return path;
1316
- };
1317
- exports.pathNormalize = pathNormalize;
1318
- });
1319
- var require_get_extension_of_filename = __commonJS((exports) => {
1320
- Object.defineProperty(exports, "__esModule", { value: true });
1321
- exports.getExtensionOfFilename = undefined;
1322
- var path_normalize_1 = require_path_normalize();
1323
- var getExtensionOfFilename = (filename) => {
1324
- if (filename === null) {
1325
- return null;
1326
- }
1327
- const filenameArr = (0, path_normalize_1.pathNormalize)(filename).split(".");
1328
- const hasExtension = filenameArr.length >= 2;
1329
- const filenameArrLength = filenameArr.length;
1330
- const extension = hasExtension ? filenameArr[filenameArrLength - 1] : null;
1331
- return extension;
1332
- };
1333
- exports.getExtensionOfFilename = getExtensionOfFilename;
1334
- });
1335
- var require_separate_audio = __commonJS((exports) => {
1336
- Object.defineProperty(exports, "__esModule", { value: true });
1337
- exports.separateAudioOption = undefined;
1338
- var DEFAULT = null;
1339
- var cliFlag = "separate-audio-to";
1340
- exports.separateAudioOption = {
1341
- cliFlag,
1342
- description: () => `If set, the audio will not be included in the main output but rendered as a separate file at the location you pass. It is recommended to use an absolute path. If a relative path is passed, it is relative to the Remotion Root.`,
1343
- docLink: "https://remotion.dev/docs/renderer/render-media",
1344
- getValue: ({ commandLine }) => {
1345
- if (commandLine[cliFlag]) {
1346
- return {
1347
- source: "cli",
1348
- value: commandLine[cliFlag]
1349
- };
1350
- }
1351
- return {
1352
- source: "default",
1353
- value: DEFAULT
1354
- };
1355
- },
1356
- name: "Separate audio to",
1357
- setConfig: () => {
1358
- throw new Error("Not implemented");
1359
- },
1360
- ssrName: "separateAudioTo",
1361
- type: "string"
1362
- };
1363
- });
1364
- var require_audio_codec = __commonJS((exports) => {
1365
- Object.defineProperty(exports, "__esModule", { value: true });
1366
- exports.audioCodecOption = exports.getDefaultAudioCodec = exports.resolveAudioCodec = exports.getExtensionFromAudioCodec = exports.defaultAudioCodecs = exports.mapAudioCodecToFfmpegAudioCodecName = exports.supportedAudioCodecs = exports.validAudioCodecs = undefined;
1367
- var separate_audio_1 = require_separate_audio();
1368
- exports.validAudioCodecs = ["pcm-16", "aac", "mp3", "opus"];
1369
- exports.supportedAudioCodecs = {
1370
- h264: ["aac", "pcm-16", "mp3"],
1371
- "h264-mkv": ["pcm-16", "mp3"],
1372
- "h264-ts": ["pcm-16", "aac"],
1373
- aac: ["aac", "pcm-16"],
1374
- avi: [],
1375
- gif: [],
1376
- h265: ["aac", "pcm-16"],
1377
- mp3: ["mp3", "pcm-16"],
1378
- prores: ["aac", "pcm-16"],
1379
- vp8: ["opus", "pcm-16"],
1380
- vp9: ["opus", "pcm-16"],
1381
- wav: ["pcm-16"]
1382
- };
1383
- var _satisfies = exports.supportedAudioCodecs;
1384
- if (_satisfies) {
1385
- }
1386
- var mapAudioCodecToFfmpegAudioCodecName = (audioCodec) => {
1387
- if (audioCodec === "aac") {
1388
- return "libfdk_aac";
1389
- }
1390
- if (audioCodec === "mp3") {
1391
- return "libmp3lame";
1392
- }
1393
- if (audioCodec === "opus") {
1394
- return "libopus";
1395
- }
1396
- if (audioCodec === "pcm-16") {
1397
- return "pcm_s16le";
1398
- }
1399
- throw new Error("unknown audio codec: " + audioCodec);
1400
- };
1401
- exports.mapAudioCodecToFfmpegAudioCodecName = mapAudioCodecToFfmpegAudioCodecName;
1402
- var cliFlag = "audio-codec";
1403
- var ssrName = "audioCodec";
1404
- exports.defaultAudioCodecs = {
1405
- "h264-mkv": {
1406
- lossless: "pcm-16",
1407
- compressed: "pcm-16"
1408
- },
1409
- "h264-ts": {
1410
- lossless: "pcm-16",
1411
- compressed: "aac"
1412
- },
1413
- aac: {
1414
- lossless: "pcm-16",
1415
- compressed: "aac"
1416
- },
1417
- gif: {
1418
- lossless: null,
1419
- compressed: null
1420
- },
1421
- h264: {
1422
- lossless: "pcm-16",
1423
- compressed: "aac"
1424
- },
1425
- h265: {
1426
- lossless: "pcm-16",
1427
- compressed: "aac"
1428
- },
1429
- mp3: {
1430
- lossless: "pcm-16",
1431
- compressed: "mp3"
1432
- },
1433
- prores: {
1434
- lossless: "pcm-16",
1435
- compressed: "pcm-16"
1436
- },
1437
- vp8: {
1438
- lossless: "pcm-16",
1439
- compressed: "opus"
1440
- },
1441
- vp9: {
1442
- lossless: "pcm-16",
1443
- compressed: "opus"
1444
- },
1445
- wav: {
1446
- lossless: "pcm-16",
1447
- compressed: "pcm-16"
1448
- }
1449
- };
1450
- var extensionMap = {
1451
- aac: "aac",
1452
- mp3: "mp3",
1453
- opus: "opus",
1454
- "pcm-16": "wav"
1455
- };
1456
- var getExtensionFromAudioCodec = (audioCodec) => {
1457
- if (extensionMap[audioCodec]) {
1458
- return extensionMap[audioCodec];
1459
- }
1460
- throw new Error(`Unsupported audio codec: ${audioCodec}`);
1461
- };
1462
- exports.getExtensionFromAudioCodec = getExtensionFromAudioCodec;
1463
- var resolveAudioCodec = ({ codec, setting, preferLossless, separateAudioTo }) => {
1464
- let derivedFromSeparateAudioToExtension = null;
1465
- if (separateAudioTo) {
1466
- const extension = separateAudioTo.split(".").pop();
1467
- for (const [key, value] of Object.entries(extensionMap)) {
1468
- if (value === extension) {
1469
- derivedFromSeparateAudioToExtension = key;
1470
- if (!exports.supportedAudioCodecs[codec].includes(derivedFromSeparateAudioToExtension) && derivedFromSeparateAudioToExtension) {
1471
- throw new Error(`The codec is ${codec} but the audio codec derived from --${separate_audio_1.separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}. The only supported codecs are: ${exports.supportedAudioCodecs[codec].join(", ")}`);
1472
- }
1473
- }
1474
- }
1475
- }
1476
- if (preferLossless) {
1477
- const selected = (0, exports.getDefaultAudioCodec)({ codec, preferLossless });
1478
- if (derivedFromSeparateAudioToExtension && selected !== derivedFromSeparateAudioToExtension) {
1479
- throw new Error(`The audio codec derived from --${separate_audio_1.separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}, but does not match the audio codec derived from the "Prefer lossless" option (${selected}). Remove any conflicting options.`);
1480
- }
1481
- return selected;
1482
- }
1483
- if (setting === null) {
1484
- if (derivedFromSeparateAudioToExtension) {
1485
- return derivedFromSeparateAudioToExtension;
1486
- }
1487
- return (0, exports.getDefaultAudioCodec)({ codec, preferLossless });
1488
- }
1489
- if (derivedFromSeparateAudioToExtension !== setting && derivedFromSeparateAudioToExtension) {
1490
- throw new Error(`The audio codec derived from --${separate_audio_1.separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}, but does not match the audio codec derived from your ${exports.audioCodecOption.name} setting (${setting}). Remove any conflicting options.`);
1491
- }
1492
- return setting;
1493
- };
1494
- exports.resolveAudioCodec = resolveAudioCodec;
1495
- var getDefaultAudioCodec = ({ codec, preferLossless }) => {
1496
- return exports.defaultAudioCodecs[codec][preferLossless ? "lossless" : "compressed"];
1497
- };
1498
- exports.getDefaultAudioCodec = getDefaultAudioCodec;
1499
- var _audioCodec = null;
1500
- exports.audioCodecOption = {
1501
- cliFlag,
1502
- setConfig: (audioCodec) => {
1503
- if (audioCodec === null) {
1504
- _audioCodec = null;
1505
- return;
1506
- }
1507
- if (!exports.validAudioCodecs.includes(audioCodec)) {
1508
- throw new Error(`Audio codec must be one of the following: ${exports.validAudioCodecs.join(", ")}, but got ${audioCodec}`);
1509
- }
1510
- _audioCodec = audioCodec;
1511
- },
1512
- getValue: ({ commandLine }) => {
1513
- if (commandLine[cliFlag]) {
1514
- const codec = commandLine[cliFlag];
1515
- if (!exports.validAudioCodecs.includes(commandLine[cliFlag])) {
1516
- throw new Error(`Audio codec must be one of the following: ${exports.validAudioCodecs.join(", ")}, but got ${codec}`);
1517
- }
1518
- return {
1519
- source: "cli",
1520
- value: commandLine[cliFlag]
1521
- };
1522
- }
1523
- if (_audioCodec !== null) {
1524
- return {
1525
- source: "config",
1526
- value: _audioCodec
1527
- };
1528
- }
1529
- return {
1530
- source: "default",
1531
- value: null
1532
- };
1533
- },
1534
- description: () => `Set the format of the audio that is embedded in the video. Not all codec and audio codec combinations are supported and certain combinations require a certain file extension and container format. See the table in the docs to see possible combinations.`,
1535
- docLink: "https://www.remotion.dev/docs/encoding/#audio-codec",
1536
- name: "Audio Codec",
1537
- ssrName,
1538
- type: "aac"
1539
- };
1540
- });
1541
- var require_validate_output_filename = __commonJS((exports) => {
1542
- Object.defineProperty(exports, "__esModule", { value: true });
1543
- exports.validateOutputFilename = undefined;
1544
- var file_extensions_1 = require_file_extensions();
1545
- var audio_codec_1 = require_audio_codec();
1546
- var validateOutputFilename = ({ codec, audioCodecSetting, extension, preferLossless, separateAudioTo }) => {
1547
- if (!file_extensions_1.defaultFileExtensionMap[codec]) {
1548
- throw new TypeError(`The codec "${codec}" is not supported. Supported codecs are: ${Object.keys(file_extensions_1.defaultFileExtensionMap).join(", ")}`);
1549
- }
1550
- const map = file_extensions_1.defaultFileExtensionMap[codec];
1551
- const resolvedAudioCodec = (0, audio_codec_1.resolveAudioCodec)({
1552
- codec,
1553
- preferLossless,
1554
- setting: audioCodecSetting,
1555
- separateAudioTo
1556
- });
1557
- if (resolvedAudioCodec === null) {
1558
- if (extension !== map.default) {
1559
- throw new TypeError(`When using the ${codec} codec, the output filename must end in .${map.default}.`);
161
+ };
162
+ return {
163
+ onData,
164
+ getOutputBuffer: () => outputBuffer,
165
+ clear: () => {
166
+ unprocessedBuffers = [];
167
+ outputBuffer = new Uint8Array(0);
1560
168
  }
1561
- return;
1562
- }
1563
- if (!(resolvedAudioCodec in map.forAudioCodec)) {
1564
- throw new Error(`Audio codec ${resolvedAudioCodec} is not supported for codec ${codec}`);
1565
- }
1566
- const acceptableExtensions = map.forAudioCodec[resolvedAudioCodec].possible;
1567
- if (!acceptableExtensions.includes(extension) && !separateAudioTo) {
1568
- throw new TypeError(`When using the ${codec} codec with the ${resolvedAudioCodec} audio codec, the output filename must end in one of the following: ${acceptableExtensions.join(", ")}.`);
1569
- }
169
+ };
170
+ };
171
+ exports.makeStreamer = makeStreamer;
172
+ var makeStreamPayloadMessage = ({ status, body, nonce }) => {
173
+ const nonceArr = new TextEncoder().encode(nonce);
174
+ const magicWordArr = new TextEncoder().encode(exports.streamingKey);
175
+ const separatorArr = new TextEncoder().encode(":");
176
+ const bodyLengthArr = new TextEncoder().encode(body.length.toString());
177
+ const statusArr = new TextEncoder().encode(String(status));
178
+ const totalLength = nonceArr.length + magicWordArr.length + separatorArr.length * 3 + bodyLengthArr.length + statusArr.length + body.length;
179
+ const concat = new Uint8Array(totalLength);
180
+ let offset = 0;
181
+ const appendToConcat = (data) => {
182
+ concat.set(data, offset);
183
+ offset += data.length;
184
+ };
185
+ appendToConcat(magicWordArr);
186
+ appendToConcat(nonceArr);
187
+ appendToConcat(separatorArr);
188
+ appendToConcat(bodyLengthArr);
189
+ appendToConcat(separatorArr);
190
+ appendToConcat(statusArr);
191
+ appendToConcat(separatorArr);
192
+ appendToConcat(body);
193
+ return concat;
1570
194
  };
1571
- exports.validateOutputFilename = validateOutputFilename;
195
+ exports.makeStreamPayloadMessage = makeStreamPayloadMessage;
1572
196
  });
1573
- var require_pure = __commonJS((exports) => {
197
+ var require_dist = __commonJS((exports) => {
1574
198
  Object.defineProperty(exports, "__esModule", { value: true });
1575
- exports.NoReactAPIs = undefined;
1576
- var codec_supports_media_1 = require_codec_supports_media();
1577
- var get_duration_from_frame_range_1 = require_get_duration_from_frame_range();
1578
- var get_extension_from_codec_1 = require_get_extension_from_codec();
1579
- var get_extension_of_filename_1 = require_get_extension_of_filename();
1580
- var is_audio_codec_1 = require_is_audio_codec();
1581
- var validate_output_filename_1 = require_validate_output_filename();
1582
- exports.NoReactAPIs = {
1583
- getExtensionOfFilename: get_extension_of_filename_1.getExtensionOfFilename,
1584
- getFileExtensionFromCodec: get_extension_from_codec_1.getFileExtensionFromCodec,
1585
- validateOutputFilename: validate_output_filename_1.validateOutputFilename,
1586
- getFramesToRender: get_duration_from_frame_range_1.getFramesToRender,
1587
- codecSupportsMedia: codec_supports_media_1.codecSupportsMedia,
1588
- isAudioCodec: is_audio_codec_1.isAudioCodec
1589
- };
199
+ exports.makeStreamer = exports.makeStreamPayloadMessage = undefined;
200
+ var make_stream_payload_message_1 = require_make_stream_payload_message();
201
+ Object.defineProperty(exports, "makeStreamPayloadMessage", { enumerable: true, get: function() {
202
+ return make_stream_payload_message_1.makeStreamPayloadMessage;
203
+ } });
204
+ var make_streamer_1 = require_make_streamer();
205
+ Object.defineProperty(exports, "makeStreamer", { enumerable: true, get: function() {
206
+ return make_streamer_1.makeStreamer;
207
+ } });
1590
208
  });
1591
209
  function interpolateFunction(input, inputRange, outputRange, options) {
1592
210
  const { extrapolateLeft, extrapolateRight, easing } = options;
@@ -2299,9 +917,329 @@ var validateFramesPerFunction = ({
2299
917
  throw new TypeError(`The framesPerLambda needs to be at least ${effectiveMinimum}, but is ${framesPerFunction}`);
2300
918
  }
2301
919
  };
2302
- var import_error_handling = __toESM(require_error_handling(), 1);
920
+ var VERSION = "4.0.268";
921
+ var isColorSupported = () => {
922
+ const env = process.env || {};
923
+ const isForceDisabled = "NO_COLOR" in env;
924
+ if (isForceDisabled) {
925
+ return false;
926
+ }
927
+ const isForced = "FORCE_COLOR" in env;
928
+ if (isForced) {
929
+ return true;
930
+ }
931
+ const isWindows = process.platform === "win32";
932
+ const isCompatibleTerminal = tty?.isatty?.(1) && env.TERM && env.TERM !== "dumb";
933
+ const isCI = "CI" in env && (("GITHUB_ACTIONS" in env) || ("GITLAB_CI" in env) || ("CIRCLECI" in env));
934
+ return isWindows || isCompatibleTerminal || isCI;
935
+ };
936
+ var chalk = (() => {
937
+ const colors = {
938
+ enabled: () => isColorSupported(),
939
+ visible: true,
940
+ styles: {},
941
+ keys: {}
942
+ };
943
+ const ansi = (st) => {
944
+ const open = `\x1B[${st.codes[0]}m`;
945
+ const close = `\x1B[${st.codes[1]}m`;
946
+ const regex = new RegExp(`\\u001b\\[${st.codes[1]}m`, "g");
947
+ st.wrap = (input, newline) => {
948
+ if (input.includes(close))
949
+ input = input.replace(regex, close + open);
950
+ const output = open + input + close;
951
+ return newline ? output.replace(/\r*\n/g, `${close}$&${open}`) : output;
952
+ };
953
+ return st;
954
+ };
955
+ const wrap = (sty, input, newline) => {
956
+ return sty.wrap?.(input, newline);
957
+ };
958
+ const style = (input, stack) => {
959
+ if (input === "" || input === null || input === undefined)
960
+ return "";
961
+ if (colors.enabled() === false)
962
+ return input;
963
+ if (colors.visible === false)
964
+ return "";
965
+ let str = String(input);
966
+ const nl = str.includes(`
967
+ `);
968
+ let n = stack.length;
969
+ while (n-- > 0)
970
+ str = wrap(colors.styles[stack[n]], str, nl);
971
+ return str;
972
+ };
973
+ const define = (name, codes, type) => {
974
+ colors.styles[name] = ansi({ name, codes });
975
+ const keys = colors.keys[type] || (colors.keys[type] = []);
976
+ keys.push(name);
977
+ Reflect.defineProperty(colors, name, {
978
+ configurable: true,
979
+ enumerable: true,
980
+ set(value) {
981
+ colors.alias?.(name, value);
982
+ },
983
+ get() {
984
+ const color = (input) => style(input, color.stack);
985
+ Reflect.setPrototypeOf(color, colors);
986
+ color.stack = this.stack ? this.stack.concat(name) : [name];
987
+ return color;
988
+ }
989
+ });
990
+ };
991
+ define("reset", [0, 0], "modifier");
992
+ define("bold", [1, 22], "modifier");
993
+ define("dim", [2, 22], "modifier");
994
+ define("italic", [3, 23], "modifier");
995
+ define("underline", [4, 24], "modifier");
996
+ define("inverse", [7, 27], "modifier");
997
+ define("hidden", [8, 28], "modifier");
998
+ define("strikethrough", [9, 29], "modifier");
999
+ define("black", [30, 39], "color");
1000
+ define("red", [31, 39], "color");
1001
+ define("green", [32, 39], "color");
1002
+ define("yellow", [33, 39], "color");
1003
+ define("blue", [34, 39], "color");
1004
+ define("magenta", [35, 39], "color");
1005
+ define("cyan", [36, 39], "color");
1006
+ define("white", [37, 39], "color");
1007
+ define("gray", [90, 39], "color");
1008
+ define("grey", [90, 39], "color");
1009
+ define("bgBlack", [40, 49], "bg");
1010
+ define("bgRed", [41, 49], "bg");
1011
+ define("bgGreen", [42, 49], "bg");
1012
+ define("bgYellow", [43, 49], "bg");
1013
+ define("bgBlue", [44, 49], "bg");
1014
+ define("bgMagenta", [45, 49], "bg");
1015
+ define("bgWhite", [47, 49], "bg");
1016
+ define("blackBright", [90, 39], "bright");
1017
+ define("redBright", [91, 39], "bright");
1018
+ define("greenBright", [92, 39], "bright");
1019
+ define("yellowBright", [93, 39], "bright");
1020
+ define("blueBright", [94, 39], "bright");
1021
+ define("magentaBright", [95, 39], "bright");
1022
+ define("whiteBright", [97, 39], "bright");
1023
+ define("bgBlackBright", [100, 49], "bgBright");
1024
+ define("bgRedBright", [101, 49], "bgBright");
1025
+ define("bgGreenBright", [102, 49], "bgBright");
1026
+ define("bgYellowBright", [103, 49], "bgBright");
1027
+ define("bgBlueBright", [104, 49], "bgBright");
1028
+ define("bgMagentaBright", [105, 49], "bgBright");
1029
+ define("bgWhiteBright", [107, 49], "bgBright");
1030
+ colors.alias = (name, color) => {
1031
+ const fn = colors[color];
1032
+ if (typeof fn !== "function") {
1033
+ throw new TypeError("Expected alias to be the name of an existing color (string) or a function");
1034
+ }
1035
+ if (!fn.stack) {
1036
+ Reflect.defineProperty(fn, "name", { value: name });
1037
+ colors.styles[name] = fn;
1038
+ fn.stack = [name];
1039
+ }
1040
+ Reflect.defineProperty(colors, name, {
1041
+ configurable: true,
1042
+ enumerable: true,
1043
+ set(value) {
1044
+ colors.alias?.(name, value);
1045
+ },
1046
+ get() {
1047
+ const col = (input) => style(input, col.stack);
1048
+ Reflect.setPrototypeOf(col, colors);
1049
+ col.stack = this.stack ? this.stack.concat(fn.stack) : fn.stack;
1050
+ return col;
1051
+ }
1052
+ });
1053
+ };
1054
+ return colors;
1055
+ })();
1056
+ var logLevels = ["trace", "verbose", "info", "warn", "error"];
1057
+ var getNumberForLogLevel = (level) => {
1058
+ return logLevels.indexOf(level);
1059
+ };
1060
+ var isEqualOrBelowLogLevel = (currentLevel, level) => {
1061
+ return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);
1062
+ };
1063
+ var reproWriteInstance = null;
1064
+ var getReproWriter = () => {
1065
+ if (!reproWriteInstance) {
1066
+ throw new Error("reproWriteInstance is not initialized");
1067
+ }
1068
+ return reproWriteInstance;
1069
+ };
1070
+ var writeInRepro = (level, ...args) => {
1071
+ if (isReproEnabled()) {
1072
+ getReproWriter().writeLine(level, ...args);
1073
+ }
1074
+ };
1075
+ var shouldRepro = false;
1076
+ var isReproEnabled = () => shouldRepro;
1077
+ function truthy2(value) {
1078
+ return Boolean(value);
1079
+ }
1080
+ var INDENT_TOKEN = chalk.gray("│");
1081
+ var verboseTag = (str) => {
1082
+ return isColorSupported() ? chalk.bgBlack(` ${str} `) : `[${str}]`;
1083
+ };
1084
+ var Log = {
1085
+ trace: (options, ...args) => {
1086
+ writeInRepro("trace", ...args);
1087
+ if (isEqualOrBelowLogLevel(options.logLevel, "trace")) {
1088
+ if (args.length === 0) {
1089
+ return process.stdout.write(`
1090
+ `);
1091
+ }
1092
+ return console.log(...[
1093
+ options.indent ? INDENT_TOKEN : null,
1094
+ options.tag ? verboseTag(options.tag) : null
1095
+ ].filter(truthy2).concat(args.map((a) => chalk.gray(a))));
1096
+ }
1097
+ },
1098
+ verbose: (options, ...args) => {
1099
+ writeInRepro("verbose", ...args);
1100
+ if (isEqualOrBelowLogLevel(options.logLevel, "verbose")) {
1101
+ if (args.length === 0) {
1102
+ return process.stdout.write(`
1103
+ `);
1104
+ }
1105
+ return console.log(...[
1106
+ options.indent ? INDENT_TOKEN : null,
1107
+ options.tag ? verboseTag(options.tag) : null
1108
+ ].filter(truthy2).concat(args.map((a) => chalk.gray(a))));
1109
+ }
1110
+ },
1111
+ info: (options, ...args) => {
1112
+ writeInRepro("info", ...args);
1113
+ if (isEqualOrBelowLogLevel(options.logLevel, "info")) {
1114
+ if (args.length === 0) {
1115
+ return process.stdout.write(`
1116
+ `);
1117
+ }
1118
+ return console.log(...[options.indent ? INDENT_TOKEN : null].filter(truthy2).concat(args ?? []));
1119
+ }
1120
+ },
1121
+ warn: (options, ...args) => {
1122
+ writeInRepro("warn", ...args);
1123
+ if (isEqualOrBelowLogLevel(options.logLevel, "warn")) {
1124
+ if (args.length === 0) {
1125
+ return process.stdout.write(`
1126
+ `);
1127
+ }
1128
+ return console.warn(...[options.indent ? chalk.yellow(INDENT_TOKEN) : null].filter(truthy2).concat(args.map((a) => chalk.yellow(a))));
1129
+ }
1130
+ },
1131
+ error: (options, ...args) => {
1132
+ writeInRepro("error", ...args);
1133
+ if (isEqualOrBelowLogLevel(options.logLevel, "error")) {
1134
+ if (args.length === 0) {
1135
+ return process.stdout.write(`
1136
+ `);
1137
+ }
1138
+ return console.error(...[
1139
+ options.indent ? INDENT_TOKEN : null,
1140
+ options.tag ? verboseTag(options.tag) : null
1141
+ ].filter(truthy2).concat(args.map((a) => chalk.red(a))));
1142
+ }
1143
+ }
1144
+ };
1145
+ var alreadyPrintedCache = [];
1146
+ var printUsefulErrorMessage = (err, logLevel, indent) => {
1147
+ const errorStack = err.stack;
1148
+ if (errorStack && alreadyPrintedCache.includes(errorStack)) {
1149
+ return;
1150
+ }
1151
+ if (errorStack) {
1152
+ alreadyPrintedCache.push(errorStack);
1153
+ alreadyPrintedCache = alreadyPrintedCache.slice(-10);
1154
+ }
1155
+ if (err.message.includes("Could not play video with")) {
1156
+ Log.info({ indent, logLevel });
1157
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/media-playback-error");
1158
+ }
1159
+ if (err.message.includes("A delayRender()") && err.message.includes("was called but not cleared after")) {
1160
+ Log.info({ indent, logLevel });
1161
+ if (err.message.includes("/proxy")) {
1162
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/troubleshooting/delay-render-proxy");
1163
+ }
1164
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/timeout");
1165
+ }
1166
+ if (err.message.includes("Target closed")) {
1167
+ Log.info({ indent, logLevel });
1168
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/target-closed");
1169
+ }
1170
+ if (err.message.includes("Timed out evaluating")) {
1171
+ Log.info({ indent, logLevel });
1172
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/troubleshooting/timed-out-page-function");
1173
+ }
1174
+ if (err.message.includes("ENAMETOOLONG")) {
1175
+ Log.info({ indent, logLevel });
1176
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue at https://remotion.dev/docs/enametoolong");
1177
+ }
1178
+ if (err.message.includes("Member must have value less than or equal to 3008")) {
1179
+ Log.info({ indent, logLevel });
1180
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error indicates that you have a AWS account on the free tier or have been limited by your organization. Often times this can be solved by adding a credit card. See also: https://repost.aws/questions/QUKruWYNDYTSmP17jCnIz6IQ/questions/QUKruWYNDYTSmP17jCnIz6IQ/unable-to-set-lambda-memory-over-3008mb");
1181
+ }
1182
+ if (err.stack?.includes("TooManyRequestsException: Rate Exceeded.")) {
1183
+ Log.info({ indent, logLevel });
1184
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error indicates that your Lambda concurrency limit is too low. See: https://www.remotion.dev/docs/lambda/troubleshooting/rate-limit");
1185
+ }
1186
+ if (err.message.includes("Error creating WebGL context")) {
1187
+ Log.info({ indent, logLevel });
1188
+ Log.warn({
1189
+ indent,
1190
+ logLevel
1191
+ }, '\uD83D\uDCA1 You might need to set the OpenGL renderer to "angle-egl", "angle" (or "swangle" if rendering on lambda). Learn why at https://www.remotion.dev/docs/three');
1192
+ Log.warn({
1193
+ indent,
1194
+ logLevel
1195
+ }, "\uD83D\uDCA1 Check how it's done at https://www.remotion.dev/docs/chromium-flags#--gl");
1196
+ }
1197
+ if (err.message.includes("The bucket does not allow ACLs")) {
1198
+ Log.info({ indent, logLevel });
1199
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Fix for this issue: https://remotion.dev/docs/lambda/troubleshooting/bucket-disallows-acl");
1200
+ }
1201
+ if (err.message.includes("Minified React error #306")) {
1202
+ const componentName = err.message.match(/<\w+>/)?.[0];
1203
+ Log.info({ indent, logLevel }, [
1204
+ "\uD83D\uDCA1 This error indicates that the component",
1205
+ componentName ? `(${componentName})` : null,
1206
+ "you are trying to render is not imported correctly."
1207
+ ].filter(truthy2).join(" "));
1208
+ Log.info({ indent, logLevel });
1209
+ Log.info({ indent, logLevel }, " Check the root file and ensure that the component is not undefined.");
1210
+ Log.info({ indent, logLevel }, " Oftentimes, this happens if the component is missing the `export` keyword");
1211
+ Log.info({ indent, logLevel }, " or if the component was renamed and the import statement not properly adjusted.");
1212
+ }
1213
+ if (err.message.includes("GLIBC_")) {
1214
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Remotion requires at least Libc 2.35.");
1215
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 Get help for this issue: https://github.com/remotion-dev/remotion/issues/2439");
1216
+ }
1217
+ if (err.message.includes("EBADF")) {
1218
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error might be fixed by changing your Node version:");
1219
+ Log.info({ indent, logLevel }, " https://github.com/remotion-dev/remotion/issues/2452");
1220
+ }
1221
+ if (err.message.includes("routines::unsupported")) {
1222
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 This error might happen if using Cloud Run with credentials that have a newline at the end or are otherwise badly encoded.");
1223
+ Log.info({ indent, logLevel }, " https://github.com/remotion-dev/remotion/issues/3864");
1224
+ }
1225
+ if (err.message.includes("Failed to fetch")) {
1226
+ Log.info({ indent, logLevel }, "\uD83D\uDCA1 On Lambda, one reason this could happen is that Chrome is rejecting an asset to be loaded when it is running low on disk space.");
1227
+ Log.info({ indent, logLevel }, "Try increasing the disk size of your Lambda function.");
1228
+ }
1229
+ };
1230
+ var wrapWithErrorHandling = (fn) => {
1231
+ return async (...args) => {
1232
+ try {
1233
+ return await fn(...args);
1234
+ } catch (err) {
1235
+ const { indent } = args[0];
1236
+ const { logLevel } = args[0];
1237
+ printUsefulErrorMessage(err, logLevel, indent);
1238
+ throw err;
1239
+ }
1240
+ };
1241
+ };
2303
1242
  var import_streaming2 = __toESM(require_dist(), 1);
2304
- var VERSION = "4.0.267";
2305
1243
  var min = (arr) => {
2306
1244
  if (arr.length === 0) {
2307
1245
  throw new Error("Array of 0 length");
@@ -2534,7 +1472,508 @@ var estimatePriceFromMetadata = ({
2534
1472
  }).toPrecision(5));
2535
1473
  return { accruedSoFar, estimatedBillingDurationInMilliseconds };
2536
1474
  };
2537
- var import_pure2 = __toESM(require_pure(), 1);
1475
+ var isAudioCodec = (codec) => {
1476
+ return codec === "mp3" || codec === "aac" || codec === "wav";
1477
+ };
1478
+ var support = {
1479
+ "h264-mkv": {
1480
+ audio: true,
1481
+ video: true
1482
+ },
1483
+ aac: {
1484
+ audio: true,
1485
+ video: false
1486
+ },
1487
+ gif: {
1488
+ video: true,
1489
+ audio: false
1490
+ },
1491
+ h264: {
1492
+ video: true,
1493
+ audio: true
1494
+ },
1495
+ "h264-ts": {
1496
+ video: true,
1497
+ audio: true
1498
+ },
1499
+ h265: {
1500
+ video: true,
1501
+ audio: true
1502
+ },
1503
+ mp3: {
1504
+ audio: true,
1505
+ video: false
1506
+ },
1507
+ prores: {
1508
+ audio: true,
1509
+ video: true
1510
+ },
1511
+ vp8: {
1512
+ audio: true,
1513
+ video: true
1514
+ },
1515
+ vp9: {
1516
+ audio: true,
1517
+ video: true
1518
+ },
1519
+ wav: {
1520
+ audio: true,
1521
+ video: false
1522
+ }
1523
+ };
1524
+ var codecSupportsMedia = (codec) => {
1525
+ return support[codec];
1526
+ };
1527
+ var getFramesToRender = (frameRange, everyNthFrame) => {
1528
+ if (everyNthFrame === 0) {
1529
+ throw new Error("everyNthFrame cannot be 0");
1530
+ }
1531
+ return new Array(frameRange[1] - frameRange[0] + 1).fill(true).map((_, index) => {
1532
+ return index + frameRange[0];
1533
+ }).filter((index) => {
1534
+ return index % everyNthFrame === 0;
1535
+ });
1536
+ };
1537
+ var validCodecs = [
1538
+ "h264",
1539
+ "h265",
1540
+ "vp8",
1541
+ "vp9",
1542
+ "mp3",
1543
+ "aac",
1544
+ "wav",
1545
+ "prores",
1546
+ "h264-mkv",
1547
+ "h264-ts",
1548
+ "gif"
1549
+ ];
1550
+ var defaultFileExtensionMap = {
1551
+ "h264-mkv": {
1552
+ default: "mkv",
1553
+ forAudioCodec: {
1554
+ "pcm-16": { possible: ["mkv"], default: "mkv" },
1555
+ mp3: { possible: ["mkv"], default: "mkv" }
1556
+ }
1557
+ },
1558
+ "h264-ts": {
1559
+ default: "ts",
1560
+ forAudioCodec: {
1561
+ "pcm-16": { possible: ["ts"], default: "ts" },
1562
+ aac: { possible: ["ts"], default: "ts" }
1563
+ }
1564
+ },
1565
+ aac: {
1566
+ default: "aac",
1567
+ forAudioCodec: {
1568
+ aac: {
1569
+ possible: ["aac", "3gp", "m4a", "m4b", "mpg", "mpeg"],
1570
+ default: "aac"
1571
+ },
1572
+ "pcm-16": {
1573
+ possible: ["wav"],
1574
+ default: "wav"
1575
+ }
1576
+ }
1577
+ },
1578
+ gif: {
1579
+ default: "gif",
1580
+ forAudioCodec: {}
1581
+ },
1582
+ h264: {
1583
+ default: "mp4",
1584
+ forAudioCodec: {
1585
+ "pcm-16": { possible: ["mkv", "mov"], default: "mkv" },
1586
+ aac: { possible: ["mp4", "mkv", "mov"], default: "mp4" },
1587
+ mp3: { possible: ["mp4", "mkv", "mov"], default: "mp4" }
1588
+ }
1589
+ },
1590
+ h265: {
1591
+ default: "mp4",
1592
+ forAudioCodec: {
1593
+ aac: { possible: ["mp4", "mkv", "hevc"], default: "mp4" },
1594
+ "pcm-16": { possible: ["mkv"], default: "mkv" }
1595
+ }
1596
+ },
1597
+ mp3: {
1598
+ default: "mp3",
1599
+ forAudioCodec: {
1600
+ mp3: { possible: ["mp3"], default: "mp3" },
1601
+ "pcm-16": { possible: ["wav"], default: "wav" }
1602
+ }
1603
+ },
1604
+ prores: {
1605
+ default: "mov",
1606
+ forAudioCodec: {
1607
+ aac: { possible: ["mov", "mkv", "mxf"], default: "mov" },
1608
+ "pcm-16": { possible: ["mov", "mkv", "mxf"], default: "mov" }
1609
+ }
1610
+ },
1611
+ vp8: {
1612
+ default: "webm",
1613
+ forAudioCodec: {
1614
+ "pcm-16": { possible: ["mkv"], default: "mkv" },
1615
+ opus: { possible: ["webm"], default: "webm" }
1616
+ }
1617
+ },
1618
+ vp9: {
1619
+ default: "webm",
1620
+ forAudioCodec: {
1621
+ "pcm-16": { possible: ["mkv"], default: "mkv" },
1622
+ opus: { possible: ["webm"], default: "webm" }
1623
+ }
1624
+ },
1625
+ wav: {
1626
+ default: "wav",
1627
+ forAudioCodec: {
1628
+ "pcm-16": { possible: ["wav"], default: "wav" }
1629
+ }
1630
+ }
1631
+ };
1632
+ var getFileExtensionFromCodec = (codec, audioCodec) => {
1633
+ if (!validCodecs.includes(codec)) {
1634
+ throw new Error(`Codec must be one of the following: ${validCodecs.join(", ")}, but got ${codec}`);
1635
+ }
1636
+ const map = defaultFileExtensionMap[codec];
1637
+ if (audioCodec === null) {
1638
+ return map.default;
1639
+ }
1640
+ const typedAudioCodec = audioCodec;
1641
+ if (!(typedAudioCodec in map.forAudioCodec)) {
1642
+ throw new Error(`Audio codec ${typedAudioCodec} is not supported for codec ${codec}`);
1643
+ }
1644
+ return map.forAudioCodec[audioCodec].default;
1645
+ };
1646
+ var SLASH = 47;
1647
+ var DOT = 46;
1648
+ var assertPath = (path) => {
1649
+ const t = typeof path;
1650
+ if (t !== "string") {
1651
+ throw new TypeError(`Expected a string, got a ${t}`);
1652
+ }
1653
+ };
1654
+ var posixNormalize = (path, allowAboveRoot) => {
1655
+ let res = "";
1656
+ let lastSegmentLength = 0;
1657
+ let lastSlash = -1;
1658
+ let dots = 0;
1659
+ let code;
1660
+ for (let i = 0;i <= path.length; ++i) {
1661
+ if (i < path.length) {
1662
+ code = path.charCodeAt(i);
1663
+ } else if (code === SLASH) {
1664
+ break;
1665
+ } else {
1666
+ code = SLASH;
1667
+ }
1668
+ if (code === SLASH) {
1669
+ if (lastSlash === i - 1 || dots === 1) {
1670
+ } else if (lastSlash !== i - 1 && dots === 2) {
1671
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
1672
+ if (res.length > 2) {
1673
+ const lastSlashIndex = res.lastIndexOf("/");
1674
+ if (lastSlashIndex !== res.length - 1) {
1675
+ if (lastSlashIndex === -1) {
1676
+ res = "";
1677
+ lastSegmentLength = 0;
1678
+ } else {
1679
+ res = res.slice(0, lastSlashIndex);
1680
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
1681
+ }
1682
+ lastSlash = i;
1683
+ dots = 0;
1684
+ continue;
1685
+ }
1686
+ } else if (res.length === 2 || res.length === 1) {
1687
+ res = "";
1688
+ lastSegmentLength = 0;
1689
+ lastSlash = i;
1690
+ dots = 0;
1691
+ continue;
1692
+ }
1693
+ }
1694
+ if (allowAboveRoot) {
1695
+ if (res.length > 0) {
1696
+ res += "/..";
1697
+ } else {
1698
+ res = "..";
1699
+ }
1700
+ lastSegmentLength = 2;
1701
+ }
1702
+ } else {
1703
+ if (res.length > 0) {
1704
+ res += "/" + path.slice(lastSlash + 1, i);
1705
+ } else {
1706
+ res = path.slice(lastSlash + 1, i);
1707
+ }
1708
+ lastSegmentLength = i - lastSlash - 1;
1709
+ }
1710
+ lastSlash = i;
1711
+ dots = 0;
1712
+ } else if (code === DOT && dots !== -1) {
1713
+ ++dots;
1714
+ } else {
1715
+ dots = -1;
1716
+ }
1717
+ }
1718
+ return res;
1719
+ };
1720
+ var decode = (s) => {
1721
+ try {
1722
+ return decodeURIComponent(s);
1723
+ } catch {
1724
+ return s;
1725
+ }
1726
+ };
1727
+ var pathNormalize = (p) => {
1728
+ assertPath(p);
1729
+ let path = p;
1730
+ if (path.length === 0) {
1731
+ return ".";
1732
+ }
1733
+ const isAbsolute = path.charCodeAt(0) === SLASH;
1734
+ const trailingSeparator = path.charCodeAt(path.length - 1) === SLASH;
1735
+ path = decode(path);
1736
+ path = posixNormalize(path, !isAbsolute);
1737
+ if (path.length === 0 && !isAbsolute) {
1738
+ path = ".";
1739
+ }
1740
+ if (path.length > 0 && trailingSeparator) {
1741
+ path += "/";
1742
+ }
1743
+ if (isAbsolute) {
1744
+ return "/" + path;
1745
+ }
1746
+ return path;
1747
+ };
1748
+ var getExtensionOfFilename = (filename) => {
1749
+ if (filename === null) {
1750
+ return null;
1751
+ }
1752
+ const filenameArr = pathNormalize(filename).split(".");
1753
+ const hasExtension = filenameArr.length >= 2;
1754
+ const filenameArrLength = filenameArr.length;
1755
+ const extension = hasExtension ? filenameArr[filenameArrLength - 1] : null;
1756
+ return extension;
1757
+ };
1758
+ var DEFAULT = null;
1759
+ var cliFlag = "separate-audio-to";
1760
+ var separateAudioOption = {
1761
+ cliFlag,
1762
+ description: () => `If set, the audio will not be included in the main output but rendered as a separate file at the location you pass. It is recommended to use an absolute path. If a relative path is passed, it is relative to the Remotion Root.`,
1763
+ docLink: "https://remotion.dev/docs/renderer/render-media",
1764
+ getValue: ({ commandLine }) => {
1765
+ if (commandLine[cliFlag]) {
1766
+ return {
1767
+ source: "cli",
1768
+ value: commandLine[cliFlag]
1769
+ };
1770
+ }
1771
+ return {
1772
+ source: "default",
1773
+ value: DEFAULT
1774
+ };
1775
+ },
1776
+ name: "Separate audio to",
1777
+ setConfig: () => {
1778
+ throw new Error("Not implemented");
1779
+ },
1780
+ ssrName: "separateAudioTo",
1781
+ type: "string"
1782
+ };
1783
+ var validAudioCodecs = ["pcm-16", "aac", "mp3", "opus"];
1784
+ var supportedAudioCodecs = {
1785
+ h264: ["aac", "pcm-16", "mp3"],
1786
+ "h264-mkv": ["pcm-16", "mp3"],
1787
+ "h264-ts": ["pcm-16", "aac"],
1788
+ aac: ["aac", "pcm-16"],
1789
+ avi: [],
1790
+ gif: [],
1791
+ h265: ["aac", "pcm-16"],
1792
+ mp3: ["mp3", "pcm-16"],
1793
+ prores: ["aac", "pcm-16"],
1794
+ vp8: ["opus", "pcm-16"],
1795
+ vp9: ["opus", "pcm-16"],
1796
+ wav: ["pcm-16"]
1797
+ };
1798
+ var _satisfies = supportedAudioCodecs;
1799
+ if (_satisfies) {
1800
+ }
1801
+ var cliFlag2 = "audio-codec";
1802
+ var ssrName = "audioCodec";
1803
+ var defaultAudioCodecs = {
1804
+ "h264-mkv": {
1805
+ lossless: "pcm-16",
1806
+ compressed: "pcm-16"
1807
+ },
1808
+ "h264-ts": {
1809
+ lossless: "pcm-16",
1810
+ compressed: "aac"
1811
+ },
1812
+ aac: {
1813
+ lossless: "pcm-16",
1814
+ compressed: "aac"
1815
+ },
1816
+ gif: {
1817
+ lossless: null,
1818
+ compressed: null
1819
+ },
1820
+ h264: {
1821
+ lossless: "pcm-16",
1822
+ compressed: "aac"
1823
+ },
1824
+ h265: {
1825
+ lossless: "pcm-16",
1826
+ compressed: "aac"
1827
+ },
1828
+ mp3: {
1829
+ lossless: "pcm-16",
1830
+ compressed: "mp3"
1831
+ },
1832
+ prores: {
1833
+ lossless: "pcm-16",
1834
+ compressed: "pcm-16"
1835
+ },
1836
+ vp8: {
1837
+ lossless: "pcm-16",
1838
+ compressed: "opus"
1839
+ },
1840
+ vp9: {
1841
+ lossless: "pcm-16",
1842
+ compressed: "opus"
1843
+ },
1844
+ wav: {
1845
+ lossless: "pcm-16",
1846
+ compressed: "pcm-16"
1847
+ }
1848
+ };
1849
+ var extensionMap = {
1850
+ aac: "aac",
1851
+ mp3: "mp3",
1852
+ opus: "opus",
1853
+ "pcm-16": "wav"
1854
+ };
1855
+ var resolveAudioCodec = ({
1856
+ codec,
1857
+ setting,
1858
+ preferLossless,
1859
+ separateAudioTo
1860
+ }) => {
1861
+ let derivedFromSeparateAudioToExtension = null;
1862
+ if (separateAudioTo) {
1863
+ const extension = separateAudioTo.split(".").pop();
1864
+ for (const [key, value] of Object.entries(extensionMap)) {
1865
+ if (value === extension) {
1866
+ derivedFromSeparateAudioToExtension = key;
1867
+ if (!supportedAudioCodecs[codec].includes(derivedFromSeparateAudioToExtension) && derivedFromSeparateAudioToExtension) {
1868
+ throw new Error(`The codec is ${codec} but the audio codec derived from --${separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}. The only supported codecs are: ${supportedAudioCodecs[codec].join(", ")}`);
1869
+ }
1870
+ }
1871
+ }
1872
+ }
1873
+ if (preferLossless) {
1874
+ const selected = getDefaultAudioCodec({ codec, preferLossless });
1875
+ if (derivedFromSeparateAudioToExtension && selected !== derivedFromSeparateAudioToExtension) {
1876
+ throw new Error(`The audio codec derived from --${separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}, but does not match the audio codec derived from the "Prefer lossless" option (${selected}). Remove any conflicting options.`);
1877
+ }
1878
+ return selected;
1879
+ }
1880
+ if (setting === null) {
1881
+ if (derivedFromSeparateAudioToExtension) {
1882
+ return derivedFromSeparateAudioToExtension;
1883
+ }
1884
+ return getDefaultAudioCodec({ codec, preferLossless });
1885
+ }
1886
+ if (derivedFromSeparateAudioToExtension !== setting && derivedFromSeparateAudioToExtension) {
1887
+ throw new Error(`The audio codec derived from --${separateAudioOption.cliFlag} is ${derivedFromSeparateAudioToExtension}, but does not match the audio codec derived from your ${audioCodecOption.name} setting (${setting}). Remove any conflicting options.`);
1888
+ }
1889
+ return setting;
1890
+ };
1891
+ var getDefaultAudioCodec = ({
1892
+ codec,
1893
+ preferLossless
1894
+ }) => {
1895
+ return defaultAudioCodecs[codec][preferLossless ? "lossless" : "compressed"];
1896
+ };
1897
+ var _audioCodec = null;
1898
+ var audioCodecOption = {
1899
+ cliFlag: cliFlag2,
1900
+ setConfig: (audioCodec) => {
1901
+ if (audioCodec === null) {
1902
+ _audioCodec = null;
1903
+ return;
1904
+ }
1905
+ if (!validAudioCodecs.includes(audioCodec)) {
1906
+ throw new Error(`Audio codec must be one of the following: ${validAudioCodecs.join(", ")}, but got ${audioCodec}`);
1907
+ }
1908
+ _audioCodec = audioCodec;
1909
+ },
1910
+ getValue: ({ commandLine }) => {
1911
+ if (commandLine[cliFlag2]) {
1912
+ const codec = commandLine[cliFlag2];
1913
+ if (!validAudioCodecs.includes(commandLine[cliFlag2])) {
1914
+ throw new Error(`Audio codec must be one of the following: ${validAudioCodecs.join(", ")}, but got ${codec}`);
1915
+ }
1916
+ return {
1917
+ source: "cli",
1918
+ value: commandLine[cliFlag2]
1919
+ };
1920
+ }
1921
+ if (_audioCodec !== null) {
1922
+ return {
1923
+ source: "config",
1924
+ value: _audioCodec
1925
+ };
1926
+ }
1927
+ return {
1928
+ source: "default",
1929
+ value: null
1930
+ };
1931
+ },
1932
+ description: () => `Set the format of the audio that is embedded in the video. Not all codec and audio codec combinations are supported and certain combinations require a certain file extension and container format. See the table in the docs to see possible combinations.`,
1933
+ docLink: "https://www.remotion.dev/docs/encoding/#audio-codec",
1934
+ name: "Audio Codec",
1935
+ ssrName,
1936
+ type: "aac"
1937
+ };
1938
+ var validateOutputFilename = ({
1939
+ codec,
1940
+ audioCodecSetting,
1941
+ extension,
1942
+ preferLossless,
1943
+ separateAudioTo
1944
+ }) => {
1945
+ if (!defaultFileExtensionMap[codec]) {
1946
+ throw new TypeError(`The codec "${codec}" is not supported. Supported codecs are: ${Object.keys(defaultFileExtensionMap).join(", ")}`);
1947
+ }
1948
+ const map = defaultFileExtensionMap[codec];
1949
+ const resolvedAudioCodec = resolveAudioCodec({
1950
+ codec,
1951
+ preferLossless,
1952
+ setting: audioCodecSetting,
1953
+ separateAudioTo
1954
+ });
1955
+ if (resolvedAudioCodec === null) {
1956
+ if (extension !== map.default) {
1957
+ throw new TypeError(`When using the ${codec} codec, the output filename must end in .${map.default}.`);
1958
+ }
1959
+ return;
1960
+ }
1961
+ if (!(resolvedAudioCodec in map.forAudioCodec)) {
1962
+ throw new Error(`Audio codec ${resolvedAudioCodec} is not supported for codec ${codec}`);
1963
+ }
1964
+ const acceptableExtensions = map.forAudioCodec[resolvedAudioCodec].possible;
1965
+ if (!acceptableExtensions.includes(extension) && !separateAudioTo) {
1966
+ throw new TypeError(`When using the ${codec} codec with the ${resolvedAudioCodec} audio codec, the output filename must end in one of the following: ${acceptableExtensions.join(", ")}.`);
1967
+ }
1968
+ };
1969
+ var NoReactAPIs = {
1970
+ getExtensionOfFilename,
1971
+ getFileExtensionFromCodec,
1972
+ validateOutputFilename,
1973
+ getFramesToRender,
1974
+ codecSupportsMedia,
1975
+ isAudioCodec
1976
+ };
2538
1977
  var getCustomOutName = ({
2539
1978
  renderMetadata,
2540
1979
  customCredentials
@@ -2566,7 +2005,6 @@ var getCustomOutName = ({
2566
2005
  key: renderMetadata.outName.key
2567
2006
  };
2568
2007
  };
2569
- var import_pure = __toESM(require_pure(), 1);
2570
2008
  var validateBucketName = ({
2571
2009
  bucketName,
2572
2010
  bucketNamePrefix,
@@ -2612,10 +2050,10 @@ var validateOutname = ({
2612
2050
  return;
2613
2051
  }
2614
2052
  if (codec) {
2615
- import_pure.NoReactAPIs.validateOutputFilename({
2053
+ NoReactAPIs.validateOutputFilename({
2616
2054
  codec,
2617
2055
  audioCodecSetting,
2618
- extension: import_pure.NoReactAPIs.getExtensionOfFilename(outName2),
2056
+ extension: NoReactAPIs.getExtensionOfFilename(outName2),
2619
2057
  preferLossless: false,
2620
2058
  separateAudioTo
2621
2059
  });
@@ -2652,7 +2090,7 @@ var getExpectedOutName = ({
2652
2090
  if (renderMetadata.type === "video") {
2653
2091
  return {
2654
2092
  renderBucketName: bucketName,
2655
- key: outName(renderMetadata.renderId, import_pure2.NoReactAPIs.getFileExtensionFromCodec(renderMetadata.codec, renderMetadata.audioCodec)),
2093
+ key: outName(renderMetadata.renderId, NoReactAPIs.getFileExtensionFromCodec(renderMetadata.codec, renderMetadata.audioCodec)),
2656
2094
  customCredentials: null
2657
2095
  };
2658
2096
  }
@@ -2735,7 +2173,6 @@ var inspectErrors = ({
2735
2173
  };
2736
2174
  });
2737
2175
  };
2738
- var import_pure4 = __toESM(require_pure(), 1);
2739
2176
  var weights = {
2740
2177
  evaluating: 0.1,
2741
2178
  encoding: 0.1,
@@ -2875,20 +2312,19 @@ var makeTimeoutError = ({
2875
2312
  name: "TimeoutError"
2876
2313
  };
2877
2314
  };
2878
- var import_pure3 = __toESM(require_pure(), 1);
2879
2315
  var lambdaRenderHasAudioVideo = (renderMetadata) => {
2880
2316
  if (renderMetadata.type === "still") {
2881
2317
  throw new Error("Cannot merge stills");
2882
2318
  }
2883
- const support = import_pure3.NoReactAPIs.codecSupportsMedia(renderMetadata.codec);
2884
- const hasVideo = renderMetadata ? !import_pure3.NoReactAPIs.isAudioCodec(renderMetadata.codec) : false;
2885
- const hasAudio = renderMetadata ? !renderMetadata.muted && support.audio : false;
2319
+ const support2 = NoReactAPIs.codecSupportsMedia(renderMetadata.codec);
2320
+ const hasVideo = renderMetadata ? !NoReactAPIs.isAudioCodec(renderMetadata.codec) : false;
2321
+ const hasAudio = renderMetadata ? !renderMetadata.muted && support2.audio : false;
2886
2322
  return {
2887
2323
  hasAudio,
2888
2324
  hasVideo
2889
2325
  };
2890
2326
  };
2891
- function truthy2(value) {
2327
+ function truthy3(value) {
2892
2328
  return Boolean(value);
2893
2329
  }
2894
2330
  var getProgress = async ({
@@ -2924,7 +2360,7 @@ var getProgress = async ({
2924
2360
  customCredentials,
2925
2361
  bucketNamePrefix: providerSpecifics.getBucketPrefix()
2926
2362
  });
2927
- const totalFrameCount = import_pure4.NoReactAPIs.getFramesToRender(overallProgress.renderMetadata.frameRange, overallProgress.renderMetadata.everyNthFrame).length;
2363
+ const totalFrameCount = NoReactAPIs.getFramesToRender(overallProgress.renderMetadata.frameRange, overallProgress.renderMetadata.everyNthFrame).length;
2928
2364
  return {
2929
2365
  framesRendered: totalFrameCount,
2930
2366
  bucket: bucketName,
@@ -3045,12 +2481,12 @@ var getProgress = async ({
3045
2481
  region,
3046
2482
  providerSpecifics
3047
2483
  });
3048
- const chunkMultiplier = [hasAudio, hasVideo].filter(truthy2).length;
2484
+ const chunkMultiplier = [hasAudio, hasVideo].filter(truthy3).length;
3049
2485
  if (renderMetadata.type === "still") {
3050
2486
  throw new Error("You don't need to call getRenderProgress() on a still render. Once you have obtained the `renderId`, the render is already done! \uD83D\uDE09");
3051
2487
  }
3052
2488
  const allChunks = (overallProgress.chunks ?? []).length / chunkMultiplier === (renderMetadata.totalChunks ?? Infinity);
3053
- const frameCount = import_pure4.NoReactAPIs.getFramesToRender(renderMetadata.frameRange, renderMetadata.everyNthFrame).length;
2489
+ const frameCount = NoReactAPIs.getFramesToRender(renderMetadata.frameRange, renderMetadata.everyNthFrame).length;
3054
2490
  const missingChunks = new Array(renderMetadata.totalChunks).fill(true).map((_, i) => i).filter((index) => {
3055
2491
  return typeof (overallProgress.chunks ?? []).find((c) => c === index) === "undefined";
3056
2492
  });
@@ -3067,7 +2503,7 @@ var getProgress = async ({
3067
2503
  providerSpecifics
3068
2504
  }) : null,
3069
2505
  ...errorExplanations
3070
- ].filter(truthy2);
2506
+ ].filter(truthy3);
3071
2507
  return {
3072
2508
  framesRendered: overallProgress.framesRendered ?? 0,
3073
2509
  chunks: chunkCount,
@@ -3166,7 +2602,6 @@ var {
3166
2602
  validateDimension: validateDimension2,
3167
2603
  validateDurationInFrames: validateDurationInFrames2
3168
2604
  } = NoReactInternals;
3169
- var export_wrapWithErrorHandling = import_error_handling.wrapWithErrorHandling;
3170
2605
  var export_makeStreamer = import_streaming2.makeStreamer;
3171
2606
  var export_makeStreamPayloadMessage = import_streaming2.makeStreamPayloadMessage;
3172
2607
 
@@ -3233,7 +2668,7 @@ var messageForVariable = (variable) => {
3233
2668
  getIsCli() ? null : `- Environment variables from a '.env' file are not automatically read if you are calling the Node.JS APIs, in that case you need to load the file yourself or set the environment variables manually.`,
3234
2669
  `- Please refer to the Remotion Lambda docs (${DOCS_URL}/docs/lambda/setup) to see how to generate the credentials for your AWS account and then set the environment variables.`,
3235
2670
  `- For more reasons see the troubleshooting page: ${DOCS_URL}/docs/lambda/troubleshooting/permissions`
3236
- ].filter(truthy2).join(`
2671
+ ].filter(truthy3).join(`
3237
2672
  `);
3238
2673
  };
3239
2674
  var checkCredentials = () => {
@@ -5056,7 +4491,7 @@ var generateRandomHashWithLifeCycleRule = ({
5056
4491
  deleteAfter,
5057
4492
  randomHashFn
5058
4493
  }) => {
5059
- return [deleteAfter, randomHashFn()].filter(truthy2).join("-");
4494
+ return [deleteAfter, randomHashFn()].filter(truthy3).join("-");
5060
4495
  };
5061
4496
 
5062
4497
  // src/lifecycle-rules.ts
@@ -5973,7 +5408,7 @@ var renderMediaOnLambdaOptionalToRequired = (options) => {
5973
5408
  apiKey: options.apiKey ?? null
5974
5409
  };
5975
5410
  };
5976
- var wrapped = export_wrapWithErrorHandling(internalRenderMediaOnLambdaRaw);
5411
+ var wrapped = wrapWithErrorHandling(internalRenderMediaOnLambdaRaw);
5977
5412
  var renderMediaOnLambda = (options) => {
5978
5413
  if (options.quality) {
5979
5414
  throw new Error("quality has been renamed to jpegQuality. Please rename the option.");
@@ -6444,7 +5879,7 @@ var internalRenderStillOnLambda = async (input) => {
6444
5879
  throw err;
6445
5880
  }
6446
5881
  };
6447
- var errorHandled = export_wrapWithErrorHandling(internalRenderStillOnLambda);
5882
+ var errorHandled = wrapWithErrorHandling(internalRenderStillOnLambda);
6448
5883
  var renderStillOnLambda = (input) => {
6449
5884
  return errorHandled({
6450
5885
  chromiumOptions: input.chromiumOptions ?? {},