Skip to content

🎥 Make videos programmatically with React

cli stuff

Jonny Burgerc18c9eb2600e
diff --git a/packages/cli/src/get-cli-options.ts b/packages/cli/src/get-cli-options.ts
index a153b692f6..4b65f233a1 100644
--- a/packages/cli/src/get-cli-options.ts
+++ b/packages/cli/src/get-cli-options.ts
@@ -199,6 +199,7 @@ export const getCliOptions = async (type: 'still' | 'series') => {
const ffmpegExecutable = Internals.getCustomFfmpegExecutable();
return {
+ puppeteerTimeout: Internals.getCurrentPuppeteerTimeout(),
parallelism: Internals.getConcurrency(),
frameRange,
shouldOutputImageSequence,
diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.ts
index b520032391..649e515650 100644
--- a/packages/cli/src/parse-command-line.ts
+++ b/packages/cli/src/parse-command-line.ts
@@ -23,6 +23,7 @@ export type CommandLineOptions = {
['env-file']: string;
codec: Codec;
concurrency: number;
+ timeout: number;
config: string;
crf: number;
force: boolean;
@@ -83,6 +84,10 @@ export const parseCommandLine = (type: 'still' | 'sequence' | 'versions') => {
Config.Rendering.setConcurrency(parsedCli.concurrency);
}
+ if (parsedCli.timeout) {
+ Config.Puppeteer.setTimeoutInMilliseconds(parsedCli.timeout);
+ }
+
if (parsedCli.frames) {
if (type === 'still') {
Log.error(
diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsx
index d32e415c8e..00a8c9d435 100644
--- a/packages/cli/src/render.tsx
+++ b/packages/cli/src/render.tsx
@@ -93,6 +93,7 @@ export const render = async () => {
inputProps,
browserInstance: openedBrowser,
envVariables,
+ timeoutInMilliseconds: Internals.getCurrentPuppeteerTimeout(),
});
const compositionId = getCompositionId(comps);
@@ -154,6 +155,7 @@ export const render = async () => {
frameRange: frameRange ?? null,
dumpBrowserLogs: Internals.Logging.isEqualOrBelowLogLevel('verbose'),
puppeteerInstance: openedBrowser,
+ timeoutInMilliseconds: Internals.getCurrentPuppeteerTimeout(),
});
const closeBrowserPromise = openedBrowser.close();
diff --git a/packages/cli/src/still.ts b/packages/cli/src/still.ts
index 79472439e5..cc6a6269d1 100644
--- a/packages/cli/src/still.ts
+++ b/packages/cli/src/still.ts
@@ -92,6 +92,7 @@ export const still = async () => {
inputProps,
browserInstance: openedBrowser,
envVariables,
+ timeoutInMilliseconds: Internals.getCurrentPuppeteerTimeout(),
});
const compositionId = getCompositionId(comps);
@@ -124,6 +125,7 @@ export const still = async () => {
},
puppeteerInstance: openedBrowser,
overwrite: Internals.getShouldOverwrite(),
+ timeoutInMilliseconds: Internals.getCurrentPuppeteerTimeout(),
});
const closeBrowserPromise = openedBrowser.close();
diff --git a/packages/core/src/config/index.ts b/packages/core/src/config/index.ts
index 9b08580001..02be36f042 100644
--- a/packages/core/src/config/index.ts
+++ b/packages/core/src/config/index.ts
@@ -21,6 +21,7 @@ import {setProResProfile} from './prores-profile';
import {setQuality} from './quality';
import {setWebpackCaching} from './webpack-caching';
import {FfmpegExecutable, setFfmpegExecutable} from './ffmpeg-executable';
+import {setPuppeteerTimeout} from './timeout';
export const Config = {
Preview: {
@@ -66,6 +67,11 @@ export const Config = {
* Default: null, which will make Remotion find or download a version of said browser.
*/
setBrowserExecutable,
+ /**
+ * Set how many milliseconds a frame may take to render before it times out.
+ * Default: `30000`
+ */
+ setTimeoutInMilliseconds: setPuppeteerTimeout,
},
Rendering: {
/**
diff --git a/packages/core/src/config/timeout.ts b/packages/core/src/config/timeout.ts
new file mode 100644
index 0000000000..245c973fe2
--- /dev/null
+++ b/packages/core/src/config/timeout.ts
@@ -0,0 +1,15 @@
+import {DEFAULT_PUPPETEER_TIMEOUT} from '../timeout';
+
+let currentTimeout: number = DEFAULT_PUPPETEER_TIMEOUT;
+
+export const setPuppeteerTimeout = (newPuppeteerTimeout: number) => {
+ if (typeof newPuppeteerTimeout !== 'number') {
+ throw new Error('--concurrency flag must be a number.');
+ }
+
+ currentTimeout = newPuppeteerTimeout;
+};
+
+export const getCurrentPuppeteerTimeout = (): number => {
+ return currentTimeout;
+};
diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.ts
index 979d7b6596..3976220d35 100644
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@ -128,6 +128,10 @@ import {
PUPPETEER_TIMEOUT_KEY,
setupPuppeteerTimeout,
} from './timeout';
+import {
+ getCurrentPuppeteerTimeout,
+ setPuppeteerTimeout,
+} from './config/timeout';
const Timeline = {...TimelinePosition, ...TimelineInOutPosition};
// Mark them as Internals so use don't assume this is public
@@ -210,6 +214,8 @@ export const Internals = {
DEFAULT_PUPPETEER_TIMEOUT,
PUPPETEER_TIMEOUT_KEY,
setupPuppeteerTimeout,
+ setPuppeteerTimeout,
+ getCurrentPuppeteerTimeout,
};
export type {