🎥 Make videos programmatically with React
move the rest of the config over
Jonny Burger387c0c9b9599
diff --git a/packages/config/src/config/index.ts b/packages/config/src/config/index.tsindex 65bfe6aefa..ee9a22c66a 100644--- a/packages/config/src/config/index.ts+++ b/packages/config/src/config/index.ts@@ -1,227 +1,230 @@-import type {Browser} from './browser';-import type {BrowserExecutable} from './browser-executable';-import {setBrowserExecutable} from './browser-executable';+import type { Browser } from "./browser";+import type { BrowserExecutable } from "./browser-executable";+import { setBrowserExecutable } from "./browser-executable";import {- setChromiumDisableWebSecurity,- setChromiumHeadlessMode,- setChromiumIgnoreCertificateErrors,- setChromiumOpenGlRenderer,-} from './chromium-flags';-import type {Codec} from './codec';-import {setCodec, setOutputFormat} from './codec';-import type {Concurrency} from './concurrency';-import {setConcurrency} from './concurrency';-import {setCrf} from './crf';-import {setDotEnvLocation} from './env-file';-import {setEveryNthFrame} from './every-nth-frame';-import type {FfmpegExecutable} from './ffmpeg-executable';-import {setFfmpegExecutable, setFfprobeExecutable} from './ffmpeg-executable';-import type {FrameRange} from './frame-range';-import {setFrameRange} from './frame-range';-import type {ImageFormat, StillImageFormat} from './image-format';-import {setImageFormat} from './image-format';-import {setImageSequence} from './image-sequence';-import type {LogLevel} from './log';-import {setLogLevel} from './log';-import {setMaxTimelineTracks} from './max-timeline-tracks';-import {setNumberOfGifLoops} from './number-of-gif-loops';-import {setOutputLocation} from './output-location';-import type {WebpackConfiguration, WebpackOverrideFn} from './override-webpack';-import {overrideWebpackConfig} from './override-webpack';-import {setOverwriteOutput} from './overwrite';-import type {PixelFormat} from './pixel-format';-import {setPixelFormat} from './pixel-format';-import {setPort} from './preview-server';-import {setProResProfile} from './prores-profile';-import {setQuality} from './quality';-import {setScale} from './scale';-import {setPuppeteerTimeout} from './timeout';-import {setWebpackCaching} from './webpack-caching';+ setChromiumDisableWebSecurity,+ setChromiumHeadlessMode,+ setChromiumIgnoreCertificateErrors,+ setChromiumOpenGlRenderer,+} from "./chromium-flags";+import type { Codec } from "./codec";+import { setCodec, setOutputFormat } from "./codec";+import type { Concurrency } from "./concurrency";+import { setConcurrency } from "./concurrency";+import { setCrf } from "./crf";+import { setDotEnvLocation } from "./env-file";+import { setEveryNthFrame } from "./every-nth-frame";+import type { FfmpegExecutable } from "./ffmpeg-executable";+import { setFfmpegExecutable, setFfprobeExecutable } from "./ffmpeg-executable";+import type { FrameRange } from "./frame-range";+import { setFrameRange } from "./frame-range";+import type { ImageFormat, StillImageFormat } from "./image-format";+import { setImageFormat } from "./image-format";+import { setImageSequence } from "./image-sequence";+import type { LogLevel } from "./log";+import { setLogLevel } from "./log";+import { setMaxTimelineTracks } from "./max-timeline-tracks";+import { setNumberOfGifLoops } from "./number-of-gif-loops";+import { setOutputLocation } from "./output-location";+import type {+ WebpackConfiguration,+ WebpackOverrideFn,+} from "./override-webpack";+import { overrideWebpackConfig } from "./override-webpack";+import { setOverwriteOutput } from "./overwrite";+import type { PixelFormat } from "./pixel-format";+import { setPixelFormat } from "./pixel-format";+import { setPort } from "./preview-server";+import { setProResProfile } from "./prores-profile";+import { setQuality } from "./quality";+import { setScale } from "./scale";+import { setPuppeteerTimeout } from "./timeout";+import { setWebpackCaching } from "./webpack-caching";export const Config = {- Preview: {- /**- * Change the maximum amount of tracks that are shown in the timeline.- * @param maxTracks The maximum amount of timeline tracks that you would like to show.- * @default 15- */- setMaxTimelineTracks,- },- Bundling: {- /**- * Pass in a function which takes the current Webpack config- * and return a modified Webpack configuration.- * Docs: http://remotion.dev/docs/webpack- */- overrideWebpackConfig,- /**- * Whether Webpack bundles should be cached to make- * subsequent renders faster. Default: true- */- setCachingEnabled: setWebpackCaching,- /**- * Define on which port Remotion should start it's HTTP servers during preview and rendering.- * By default, Remotion will try to find a free port.- * If you specify a port, but it's not available, Remotion will throw an error.- */- setPort,- },- Log: {- /**- * Set the log level.- * Acceptable values: 'error' | 'warning' | 'info' | 'verbose'- * Default value: 'info'- *- * Set this to 'verbose' to get browser logs and other IO.- */- setLevel: setLogLevel,- },- Puppeteer: {- /**- * Specify executable path for the browser to use.- * 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,- /**- * Setting deciding whether to disable CORS and other Chrome security features.- * Default: false- */- setChromiumDisableWebSecurity,- /**- * Setting whether to ignore any invalid SSL certificates, such as self-signed ones.- * Default: false- */- setChromiumIgnoreCertificateErrors,- /**- * If false, will open an actual browser during rendering to observe progress.- * Default: true- */- setChromiumHeadlessMode,- /**- * Set the OpenGL rendering backend for Chrome. Possible values: 'egl', 'angle', 'swiftshader' and 'swangle'.- * Default: 'swangle' in Lambda, null elsewhere.- */- setChromiumOpenGlRenderer,- },- Rendering: {- /**- * Set a custom location for a .env file.- * Default: `.env`- */- setDotEnvLocation,- /**- * Sets how many Puppeteer instances will work on rendering your video in parallel.- * Default: `null`, meaning half of the threads available on your CPU.- */- setConcurrency,- /**- * Set the JPEG quality for the frames.- * Must be between 0 and 100.- * Must be between 0 and 100.- * Default: 80- */- setQuality,- /** Decide in which image format to render. Can be either 'jpeg' or 'png'.- * PNG is slower, but supports transparency.- */- setImageFormat,- /**- * Render only a subset of a video.- * Pass in a tuple [20, 30] to only render frames 20-30 into a video.- * Pass in a single number `20` to only render a single frame as an image.- * The frame count starts at 0.- */- setFrameRange,+ Preview: {+ /**+ * Change the maximum amount of tracks that are shown in the timeline.+ * @param maxTracks The maximum amount of timeline tracks that you would like to show.+ * @default 15+ */+ setMaxTimelineTracks,+ },+ Bundling: {+ /**+ * Pass in a function which takes the current Webpack config+ * and return a modified Webpack configuration.+ * Docs: http://remotion.dev/docs/webpack+ */+ overrideWebpackConfig,+ /**+ * Whether Webpack bundles should be cached to make+ * subsequent renders faster. Default: true+ */+ setCachingEnabled: setWebpackCaching,+ /**+ * Define on which port Remotion should start it's HTTP servers during preview and rendering.+ * By default, Remotion will try to find a free port.+ * If you specify a port, but it's not available, Remotion will throw an error.+ */+ setPort,+ },+ Log: {+ /**+ * Set the log level.+ * Acceptable values: 'error' | 'warning' | 'info' | 'verbose'+ * Default value: 'info'+ *+ * Set this to 'verbose' to get browser logs and other IO.+ */+ setLevel: setLogLevel,+ },+ Puppeteer: {+ /**+ * Specify executable path for the browser to use.+ * 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,+ /**+ * Setting deciding whether to disable CORS and other Chrome security features.+ * Default: false+ */+ setChromiumDisableWebSecurity,+ /**+ * Setting whether to ignore any invalid SSL certificates, such as self-signed ones.+ * Default: false+ */+ setChromiumIgnoreCertificateErrors,+ /**+ * If false, will open an actual browser during rendering to observe progress.+ * Default: true+ */+ setChromiumHeadlessMode,+ /**+ * Set the OpenGL rendering backend for Chrome. Possible values: 'egl', 'angle', 'swiftshader' and 'swangle'.+ * Default: 'swangle' in Lambda, null elsewhere.+ */+ setChromiumOpenGlRenderer,+ },+ Rendering: {+ /**+ * Set a custom location for a .env file.+ * Default: `.env`+ */+ setDotEnvLocation,+ /**+ * Sets how many Puppeteer instances will work on rendering your video in parallel.+ * Default: `null`, meaning half of the threads available on your CPU.+ */+ setConcurrency,+ /**+ * Set the JPEG quality for the frames.+ * Must be between 0 and 100.+ * Must be between 0 and 100.+ * Default: 80+ */+ setQuality,+ /** Decide in which image format to render. Can be either 'jpeg' or 'png'.+ * PNG is slower, but supports transparency.+ */+ setImageFormat,+ /**+ * Render only a subset of a video.+ * Pass in a tuple [20, 30] to only render frames 20-30 into a video.+ * Pass in a single number `20` to only render a single frame as an image.+ * The frame count starts at 0.+ */+ setFrameRange,- /**- * Specify local ffmpeg executable.- * Default: null, which will use ffmpeg available in PATH.- */- setFfmpegExecutable,- /**- * Specify local ffprobe executable.- * Default: null, which will use ffprobe available in PATH.- */- setFfprobeExecutable,- /**- * Scales the output dimensions by a factor.- * Default: 1.- */- setScale,- /**- * Specify which frames should be picked for rendering a GIF- * Default: 1, which means every frame- * https://remotion.dev/docs/render-as-gif- */- setEveryNthFrame,- /**- * Specify the number of Loop a GIF should have.- * Default: null (means GIF will loop infinite)- */- setNumberOfGifLoops,- },- Output: {- /**- * Set the output file location string. Default: `out/{composition}.{codec}`- */- setOutputLocation,- /**- * If the video file already exists, should Remotion overwrite- * the output? Default: true- */- setOverwriteOutput,- /**- * Sets the pixel format in FFMPEG.- * See https://trac.ffmpeg.org/wiki/Chroma%20Subsampling for an explanation.- * You can override this using the `--pixel-format` Cli flag.- */- setPixelFormat,- /**- * @deprecated Use setCodec() and setImageSequence() instead.- * Specify what kind of output you, either `mp4` or `png-sequence`.- */- setOutputFormat,- /**- * Specify the codec for stitching the frames into a video.- * Can be `h264` (default), `h265`, `vp8` or `vp9`- */- setCodec,- /**- * Set the Constant Rate Factor to pass to FFMPEG.- * Lower values mean better quality, but be aware that the ranges of- * possible values greatly differs between codecs.- */- setCrf,- /**- * Set to true if don't want a video but an image sequence as the output.- */- setImageSequence,- /**- * Set the ProRes profile.- * This method is only valid if the codec has been set to 'prores'.- * Possible values: 4444-xq, 4444, hq, standard, light, proxy. Default: 'hq'- * See https://avpres.net/FFmpeg/im_ProRes.html for meaning of possible values.- */- setProResProfile,- },+ /**+ * Specify local ffmpeg executable.+ * Default: null, which will use ffmpeg available in PATH.+ */+ setFfmpegExecutable,+ /**+ * Specify local ffprobe executable.+ * Default: null, which will use ffprobe available in PATH.+ */+ setFfprobeExecutable,+ /**+ * Scales the output dimensions by a factor.+ * Default: 1.+ */+ setScale,+ /**+ * Specify which frames should be picked for rendering a GIF+ * Default: 1, which means every frame+ * https://remotion.dev/docs/render-as-gif+ */+ setEveryNthFrame,+ /**+ * Specify the number of Loop a GIF should have.+ * Default: null (means GIF will loop infinite)+ */+ setNumberOfGifLoops,+ },+ Output: {+ /**+ * Set the output file location string. Default: `out/{composition}.{codec}`+ */+ setOutputLocation,+ /**+ * If the video file already exists, should Remotion overwrite+ * the output? Default: true+ */+ setOverwriteOutput,+ /**+ * Sets the pixel format in FFMPEG.+ * See https://trac.ffmpeg.org/wiki/Chroma%20Subsampling for an explanation.+ * You can override this using the `--pixel-format` Cli flag.+ */+ setPixelFormat,+ /**+ * @deprecated Use setCodec() and setImageSequence() instead.+ * Specify what kind of output you, either `mp4` or `png-sequence`.+ */+ setOutputFormat,+ /**+ * Specify the codec for stitching the frames into a video.+ * Can be `h264` (default), `h265`, `vp8` or `vp9`+ */+ setCodec,+ /**+ * Set the Constant Rate Factor to pass to FFMPEG.+ * Lower values mean better quality, but be aware that the ranges of+ * possible values greatly differs between codecs.+ */+ setCrf,+ /**+ * Set to true if don't want a video but an image sequence as the output.+ */+ setImageSequence,+ /**+ * Set the ProRes profile.+ * This method is only valid if the codec has been set to 'prores'.+ * Possible values: 4444-xq, 4444, hq, standard, light, proxy. Default: 'hq'+ * See https://avpres.net/FFmpeg/im_ProRes.html for meaning of possible values.+ */+ setProResProfile,+ },} as const;export type {- PixelFormat,- Concurrency,- WebpackConfiguration,- WebpackOverrideFn,- BrowserExecutable,- FfmpegExecutable,- ImageFormat,- Codec,- Browser,- FrameRange,- LogLevel,- StillImageFormat,+ PixelFormat,+ Concurrency,+ WebpackConfiguration,+ WebpackOverrideFn,+ BrowserExecutable,+ FfmpegExecutable,+ ImageFormat,+ Codec,+ Browser,+ FrameRange,+ LogLevel,+ StillImageFormat,};diff --git a/packages/config/src/timeout.ts b/packages/config/src/timeout.tsnew file mode 100644index 0000000000..38db1cd60b--- /dev/null+++ b/packages/config/src/timeout.ts@@ -0,0 +1 @@+export const DEFAULT_PUPPETEER_TIMEOUT = 30000;diff --git a/packages/core/src/delay-render.ts b/packages/core/src/delay-render.tsindex 5a2d54e95b..d1f289a0fe 100644--- a/packages/core/src/delay-render.ts+++ b/packages/core/src/delay-render.ts@@ -1,5 +1,4 @@import {getRemotionEnvironment} from './get-environment';-import {DEFAULT_PUPPETEER_TIMEOUT} from './timeout';import {truthy} from './truthy';if (typeof window !== 'undefined') {@@ -31,7 +30,7 @@ export const delayRender = (label?: string): number => {if (getRemotionEnvironment() === 'rendering') {const timeoutToUse =typeof window === 'undefined'- ? DEFAULT_PUPPETEER_TIMEOUT+ ? 30000: window.remotion_puppeteerTimeout - 2000;timeouts[handle] = setTimeout(() => {const message = [diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.tsindex f5de5952cc..ace6e0561e 100644--- a/packages/core/src/internals.ts+++ b/packages/core/src/internals.ts@@ -1,7 +1,3 @@-import {validateFrame} from '../../config/src/validation/validate-frame';-import type {OpenGlRenderer} from '../../config/src/validation/validate-opengl-renderer';-import {validateOpenGlRenderer} from '../../config/src/validation/validate-opengl-renderer';-import {validateQuality} from '../../config/src/validation/validate-quality';import {SharedAudioContext,SharedAudioContextProvider,@@ -43,7 +39,6 @@ import type {TimelineContextValue,} from './timeline-position-state';import * as TimelinePosition from './timeline-position-state';-import {DEFAULT_PUPPETEER_TIMEOUT, setupPuppeteerTimeout} from './timeout';import {truthy} from './truthy';import {useAbsoluteCurrentFrame} from './use-current-frame';import {useLazyComponent} from './use-lazy-component';@@ -102,14 +97,9 @@ export const Internals = {getRemotionEnvironment,SharedAudioContext,SharedAudioContextProvider,- validateQuality,- validateFrame,invalidCompositionErrorMessage,isCompositionIdValid,AssetCompression,- DEFAULT_PUPPETEER_TIMEOUT,- setupPuppeteerTimeout,- validateOpenGlRenderer,getPreviewDomElement,compositionsRef,DELAY_RENDER_CALLSTACK_TOKEN,@@ -147,5 +137,4 @@ export type {MediaVolumeContextValue,SetMediaVolumeContextValue,RemotionEnvironment,- OpenGlRenderer,};diff --git a/packages/core/src/timeout.ts b/packages/core/src/timeout.tsdeleted file mode 100644index 822a8368e4..0000000000--- a/packages/core/src/timeout.ts+++ /dev/null@@ -1,10 +0,0 @@-export const DEFAULT_PUPPETEER_TIMEOUT = 30000;--const getPuppeteerTimeout = (): number => {- const param = window.remotion_puppeteerTimeout;- return param ? Number(param) : DEFAULT_PUPPETEER_TIMEOUT;-};--export const setupPuppeteerTimeout = () => {- window.remotion_puppeteerTimeout = getPuppeteerTimeout();-};