🎥 Make videos programmatically with React
put back into core
Jonny Burgerdbedbbcc96ed
diff --git a/packages/config/package.json b/packages/config/package.jsonindex cea0c3dcc9..49c968d48b 100644--- a/packages/config/package.json+++ b/packages/config/package.json@@ -21,6 +21,7 @@"license": "SEE LICENSE IN LICENSE.md","peerDependencies": {},"dependencies": {+ "remotion": "3.1.5","@remotion/renderer": "^3.0.14"},"devDependencies": {diff --git a/packages/config/src/config/index.ts b/packages/config/src/config/index.tsindex f8c381252b..58b881abc2 100644--- a/packages/config/src/config/index.ts+++ b/packages/config/src/config/index.ts@@ -1,3 +1,4 @@+import type {ConfigType} from 'remotion';import {setBrowserExecutable} from './browser-executable';import {setChromiumDisableWebSecurity,@@ -30,7 +31,7 @@ import {setScale} from './scale';import {setPuppeteerTimeout} from './timeout';import {setWebpackCaching} from './webpack-caching';-export const Config = {+export const Config: ConfigType = {Preview: {/*** Change the maximum amount of tracks that are shown in the timeline.diff --git a/packages/core/src/config.ts b/packages/core/src/config.tsnew file mode 100644index 0000000000..c3be75adcb--- /dev/null+++ b/packages/core/src/config.ts@@ -0,0 +1,228 @@+/**+ * The configuration has moved to @remotion/cli.+ * For the moment the type definitions are going to stay here+ */++type Concurrency = number | null;+import type {Configuration} from 'webpack';+type WebpackConfiguration = Configuration;+type WebpackOverrideFn = (+ currentConfiguration: WebpackConfiguration+) => WebpackConfiguration;+type BrowserExecutable = string | null;+type FrameRange = number | [number, number];+type FfmpegExecutable = string | null;+type Loop = number | null;+type CodecOrUndefined =+ | 'h264'+ | 'h265'+ | 'vp8'+ | 'vp9'+ | 'mp3'+ | 'aac'+ | 'wav'+ | 'prores'+ | 'h264-mkv'+ | 'gif'+ | undefined;+type Crf = number | undefined;++export type ConfigType = {+ readonly 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+ */+ readonly setMaxTimelineTracks: (maxTracks: number) => void;+ };+ readonly Bundling: {+ /**+ * Pass in a function which takes the current Webpack config+ * and return a modified Webpack configuration.+ * Docs: http://remotion.dev/docs/webpack+ */+ readonly overrideWebpackConfig: (fn: WebpackOverrideFn) => void;+ /**+ * Whether Webpack bundles should be cached to make+ * subsequent renders faster. Default: true+ */+ readonly setCachingEnabled: (flag: boolean) => void;+ /**+ * 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.+ */+ readonly setPort: (port: number | undefined) => void;+ };+ readonly 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.+ */+ readonly setLevel: (+ newLogLevel: 'verbose' | 'info' | 'warn' | 'error'+ ) => void;+ };+ readonly Puppeteer: {+ /**+ * Specify executable path for the browser to use.+ * Default: null, which will make Remotion find or download a version of said browser.+ */+ readonly setBrowserExecutable: (+ newBrowserExecutablePath: BrowserExecutable+ ) => void;+ /**+ * Set how many milliseconds a frame may take to render before it times out.+ * Default: `30000`+ */+ readonly setTimeoutInMilliseconds: (newPuppeteerTimeout: number) => void;+ /**+ * Setting deciding whether to disable CORS and other Chrome security features.+ * Default: false+ */+ readonly setChromiumDisableWebSecurity: (should: boolean) => void;+ /**+ * Setting whether to ignore any invalid SSL certificates, such as self-signed ones.+ * Default: false+ */+ readonly setChromiumIgnoreCertificateErrors: (should: boolean) => void;+ /**+ * If false, will open an actual browser during rendering to observe progress.+ * Default: true+ */+ readonly setChromiumHeadlessMode: (should: boolean) => void;+ /**+ * Set the OpenGL rendering backend for Chrome. Possible values: 'egl', 'angle', 'swiftshader' and 'swangle'.+ * Default: 'swangle' in Lambda, null elsewhere.+ */+ readonly setChromiumOpenGlRenderer: (+ renderer: 'swangle' | 'angle' | 'egl' | 'swiftshader'+ ) => void;+ };+ readonly Rendering: {+ /**+ * Set a custom location for a .env file.+ * Default: `.env`+ */+ readonly setDotEnvLocation: (file: string) => void;+ /**+ * Sets how many Puppeteer instances will work on rendering your video in parallel.+ * Default: `null`, meaning half of the threads available on your CPU.+ */+ readonly setConcurrency: (newConcurrency: Concurrency) => void;+ /**+ * Set the JPEG quality for the frames.+ * Must be between 0 and 100.+ * Must be between 0 and 100.+ * Default: 80+ */+ readonly setQuality: (q: number | undefined) => void;+ /** Decide in which image format to render. Can be either 'jpeg' or 'png'.+ * PNG is slower, but supports transparency.+ */+ readonly setImageFormat: (format: 'png' | 'jpeg' | 'none') => void;+ /**+ * 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.+ */+ readonly setFrameRange: (newFrameRange: FrameRange | null) => void;+ /**+ * Specify local ffmpeg executable.+ * Default: null, which will use ffmpeg available in PATH.+ */+ readonly setFfmpegExecutable: (ffmpegPath: FfmpegExecutable) => void;+ /**+ * Specify local ffprobe executable.+ * Default: null, which will use ffprobe available in PATH.+ */+ readonly setFfprobeExecutable: (ffprobePath: FfmpegExecutable) => void;+ /**+ * Scales the output dimensions by a factor.+ * Default: 1.+ */+ readonly setScale: (newScale: number) => void;+ /**+ * Specify which frames should be picked for rendering a GIF+ * Default: 1, which means every frame+ * https://remotion.dev/docs/render-as-gif+ */+ readonly setEveryNthFrame: (frame: number) => void;+ /**+ * Specify the number of Loop a GIF should have.+ * Default: null (means GIF will loop infinite)+ */+ readonly setNumberOfGifLoops: (newLoop: Loop) => void;+ };+ readonly Output: {+ /**+ * Set the output file location string. Default: `out/{composition}.{codec}`+ */+ readonly setOutputLocation: (newOutputLocation: string) => void;+ /**+ * If the video file already exists, should Remotion overwrite+ * the output? Default: true+ */+ readonly setOverwriteOutput: (newOverwrite: boolean) => void;+ /**+ * 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.+ */+ readonly setPixelFormat: (+ format:+ | 'yuv420p'+ | 'yuva420p'+ | 'yuv422p'+ | 'yuv444p'+ | 'yuv420p10le'+ | 'yuv422p10le'+ | 'yuv444p10le'+ | 'yuva444p10le'+ ) => void;+ /**+ * @deprecated Use setCodec() and setImageSequence() instead.+ * Specify what kind of output you, either `mp4` or `png-sequence`.+ */+ readonly setOutputFormat: (newLegacyFormat: 'mp4' | 'png-sequence') => void;+ /**+ * Specify the codec for stitching the frames into a video.+ * Can be `h264` (default), `h265`, `vp8` or `vp9`+ */+ readonly setCodec: (newCodec: CodecOrUndefined) => void;+ /**+ * 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.+ */+ readonly setCrf: (newCrf: Crf) => void;+ /**+ * Set to true if don't want a video but an image sequence as the output.+ */+ readonly setImageSequence: (newImageSequence: boolean) => void;+ /**+ * 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.+ */+ readonly setProResProfile: (+ profile:+ | '4444-xq'+ | '4444'+ | 'hq'+ | 'standard'+ | 'light'+ | 'proxy'+ | undefined+ ) => void;+ };+};+export type {Concurrency, WebpackConfiguration, WebpackOverrideFn};++export const Conf = {} as unknown as ConfigType;diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 0123f5a758..83aeffa326 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -44,6 +44,7 @@ export * from './AbsoluteFill';export * from './audio';export * from './Composition';export {SmallTCompMetadata, TAsset, TCompMetadata} from './CompositionManager';+export {ConfigType} from './config';export {getInputProps} from './config/input-props';export * from './delay-render';export * from './easing';diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.tsindex ff934a3460..b93047a049 100644--- a/packages/renderer/src/render-media.ts+++ b/packages/renderer/src/render-media.ts@@ -77,8 +77,7 @@ export type RenderMediaOptions = {port?: number | null;cancelSignal?: CancelSignal;browserExecutable?: BrowserExecutable;- // TODO: Make optional- verbose: boolean;+ verbose?: boolean;} & ServeUrlOrWebpackBundle;type Await<T> = T extends PromiseLike<infer U> ? U : T;@@ -209,7 +208,7 @@ export const renderMedia = ({encodedFrames = frame;callUpdate();},- verbose: options.verbose,+ verbose: options.verbose ?? false,ffmpegExecutable,imageFormat: actualImageFormat,signal: cancelPrestitcher.cancelSignal,diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 98fe54d610..dcc2573e6e 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -173,11 +173,13 @@ importers:eslint: 8.13.0prettier: ^2.0.5prettier-plugin-organize-imports: ^2.3.4+ remotion: 3.1.5typescript: ^4.7.0vitest: ^0.18.0webpack: 5.72.0dependencies:'@remotion/renderer': link:../renderer+ remotion: link:../coredevDependencies:'@jonny/eslint-config': 3.0.266_6hvhxfirl4y3p6nuemvvvbadcu'@types/node': 16.10.2@@ -354,7 +356,7 @@ importers:'@types/react': 18.0.1eslint: 8.13.0typescript: 4.7.2- url-loader: [email protected]+ url-loader: 4.1.1_csgzzuwaerdr4d7s3u52mzcn7mpackages/eslint-config:specifiers:@@ -13787,7 +13789,6 @@ packages:loader-utils: 2.0.0schema-utils: 3.1.1webpack: 5.72.0- dev: false/filesize/6.1.0:resolution: {integrity: sha512-LpCHtPQ3sFx67z+uh2HnSyWSLLu5Jxo21795uRDuar/EOuYWXib5EmPaGIBuSnRqH2IODiKA2k5re/K9OnN/Yg==}@@ -22625,23 +22626,6 @@ packages:mime-types: 2.1.33schema-utils: 3.1.1webpack: 5.72.0- dev: false-- /url-loader/[email protected]:- resolution: {integrity: sha512-3BTV812+AVHHOJQO8O5MkWgZ5aosP7GnROJwvzLS9hWDj00lZ6Z0wNak423Lp9PBZN05N+Jk/N5Si8jRAlGyWA==}- engines: {node: '>= 10.13.0'}- peerDependencies:- file-loader: '*'- webpack: ^4.0.0 || ^5.0.0- peerDependenciesMeta:- file-loader:- optional: true- dependencies:- loader-utils: 2.0.0- mime-types: 2.1.33- schema-utils: 3.1.1- webpack: 5.72.0- dev: true/url-parse-lax/3.0.0:resolution: {integrity: sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=}