Skip to content

🎥 Make videos programmatically with React

Merge branch 'v4' into new-config-format

Jonny Burger9e2e4d6dd502
diff --cc packages/cli/src/config/index.ts
index a175948c3d,905f595fcc..a36139a80e
--- a/packages/cli/src/config/index.ts
+++ b/packages/cli/src/config/index.ts
@@@ -1,4 -1,4 +1,3 @@@
- // eslint-disable-next-line no-restricted-imports
-import {Config as RemotionConfig, Internals} from 'remotion';
import {getBrowser} from './browser';
import {getBrowserExecutable} from './browser-executable';
import {
@@@ -35,14 -31,7 +30,12 @@@ import {getCurrentPuppeteerTimeout} fro
import {getWebpackCaching} from './webpack-caching';
import type {WebpackConfiguration} from '@remotion/bundler';
- // eslint-disable-next-line no-restricted-imports
-import type {ConfigType} from 'remotion';
+import type {
+ BrowserExecutable,
+ CodecOrUndefined,
+ Crf,
- FfmpegExecutable,
+ FrameRange,
+} from '@remotion/renderer';
import {getAudioCodec, setAudioCodec} from './audio-codec';
import {
getAudioBitrate,
@@@ -106,285 -93,7 +98,275 @@@ import
} from './webpack-poll';
import {getWidth, overrideWidth} from './width';
-const Preview = {
+declare global {
+ interface RemotionBundlingOptions {
+ /**
+ * Specify the entry point so you don't have to specify it in the
+ * CLI command
+ */
+ readonly setEntryPoint: (src: string) => 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;
+ /**
+ * Define the location of the public/ directory.
+ * By default it is a folder named "public" inside the current working directory.
+ * You can set an absolute path or a relative path that will be resolved from the closest package.json location.
+ */
+ readonly setPublicDir: (publicDir: string | null) => void;
+ }
+ // Legacy config format: New options to not need to be added here.
+ interface RemotionConfigObject {
+ /**
+ * 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;
+ /**
+ * Enable Keyboard shortcuts in the Remotion Preview.
+ * @param enabled Boolean whether to enable the keyboard shortcuts
+ * @default true
+ */
+ readonly setKeyboardShortcutsEnabled: (enableShortcuts: boolean) => void;
+ /**
+ * Set number of shared audio tags. https://www.remotion.dev/docs/player/autoplay#use-the-numberofsharedaudiotags-property
+ * @param numberOfAudioTags
+ * @default 0
+ */
+ readonly setNumberOfSharedAudioTags: (numberOfAudioTags: number) => void;
+ /**
+ * Enable Webpack polling instead of file system listeners for hot reloading in the preview.
+ * This is useful if you are using a remote directory or a virtual machine.
+ * @param interval
+ * @default null
+ */
+ readonly setWebpackPollingInMilliseconds: (interval: number | null) => void;
+ /**
+ * Whether Remotion should open a browser when starting the Preview.
+ * @param should
+ * @default true
+ */
+ readonly setShouldOpenBrowser: (should: boolean) => void;
+ /**
+ * 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;
+ /**
+ * 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 setDelayRenderTimeoutInMilliseconds: (
+ newPuppeteerTimeout: number
+ ) => void;
+ /**
+ * @deprecated Renamed to `setDelayRenderTimeoutInMilliseconds`.
+ * 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;
+ /**
+ * 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;
+ /**
+ * Disable audio output.
+ * Default: false
+ */
+ readonly setMuted: (muted: boolean) => void;
+ /**
+ * Don't render an audio track if it would be silent.
+ * Default: true
+ */
+ readonly setEnforceAudioTrack: (enforceAudioTrack: boolean) => void;
+
+ /**
+ * 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;
+ /**
+ * Overrides the height of a composition
+ */
+ readonly overrideHeight: (newHeight: number) => void;
+ /**
+ * Overrides the width of a composition
+ */
+ readonly overrideWidth: (newWidth: number) => 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;
+ /**
+ * Override the arguments that Remotion passes to FFMPEG.
+ * Consult https://remotion.dev/docs/renderer/render-media#ffmpegoverride before using this feature.
+ */
+ readonly overrideFfmpegCommand: (
+ command: (info: {
+ type: 'pre-stitcher' | 'stitcher';
+ args: string[];
+ }) => string[]
+ ) => void;
+
+ /**
+ * Set a target audio bitrate to be passed to FFMPEG.
+ */
+ readonly setAudioBitrate: (bitrate: string | null) => void;
+
+ /**
+ * Set a target video bitrate to be passed to FFMPEG.
+ * Mutually exclusive with setCrf().
+ */
+ readonly setVideoBitrate: (bitrate: string | null) => void;
+ }
+}
+
+type FlatConfig = RemotionConfigObject &
+ RemotionBundlingOptions & {
+ /**
+ * Set the audio codec to use for the output video.
+ * See the Encoding guide in the docs for defaults and available options.
+ */
+ setAudioCodec: (codec: 'pcm-16' | 'aac' | 'mp3' | 'opus') => void;
+ };
+
+export const Config: FlatConfig = {
setMaxTimelineTracks,
setKeyboardShortcutsEnabled,
setNumberOfSharedAudioTags,
diff --cc packages/cli/src/index.tsx
index 0683763ef8,540c46055c..fb257f1be2
--- a/packages/cli/src/index.tsx
+++ b/packages/cli/src/index.tsx
@@@ -2,7 -2,9 +2,8 @@@ import {RenderInternals} from '@remotio
import minimist from 'minimist';
import {benchmarkCommand} from './benchmark';
import {chalk} from './chalk';
+ import {cleanupBeforeQuit, handleCtrlC} from './cleanup-before-quit';
import {listCompositionsCommand} from './compositions';
-import {overrideRemotion} from './config/index';
import {determineFinalImageFormat} from './determine-image-format';
import {getFileSizeDownloadBar} from './download-progress';
import {findEntryPoint} from './entry-point';
diff --cc packages/core/src/index.ts
index 4d36004730,e9050b3dd5..f056098c91
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@@ -58,41 -58,54 +58,53 @@@ export type BundleState
checkMultipleRemotionVersions();
- export * from './AbsoluteFill';
- export * from './audio';
- export {cancelRender} from './cancel-render';
- export * from './Composition';
- export {SmallTCompMetadata, TAsset, TCompMetadata} from './CompositionManager';
- export {getInputProps} from './config/input-props';
- export {continueRender, delayRender} from './delay-render';
- export * from './easing';
- export * from './Folder';
- export * from './freeze';
- export {getStaticFiles, StaticFile} from './get-static-files';
- export * from './IFrame';
- export * from './Img';
- export * from './internals';
- export * from './interpolate';
- export {interpolateColors} from './interpolate-colors';
- export {Loop} from './loop';
- export {ClipRegion} from './NativeLayers';
- export {prefetch} from './prefetch';
- export {random, RandomSeed} from './random';
- export {registerRoot} from './register-root';
- export {Sequence} from './Sequence';
- export {Series} from './series';
- export * from './spring';
- export {staticFile} from './static-file';
- export * from './Still';
- export type {PlayableMediaTag} from './timeline-position-state';
- export {useCurrentFrame} from './use-current-frame';
- export * from './use-video-config';
- export * from './version';
- export * from './video';
- export * from './video-config';
+ export * from './AbsoluteFill.js';
+ export * from './audio/index.js';
+ export {cancelRender} from './cancel-render.js';
+ export * from './Composition.js';
+ export {
+ SmallTCompMetadata,
+ TAsset,
+ TCompMetadata,
+ } from './CompositionManager.js';
-export {Config, ConfigType} from './config.js';
+ export {getInputProps} from './config/input-props.js';
+ export {continueRender, delayRender} from './delay-render.js';
+ export * from './easing.js';
+ export * from './Folder.js';
+ export * from './freeze.js';
+ export {getStaticFiles, StaticFile} from './get-static-files.js';
+ export * from './IFrame.js';
+ export * from './Img.js';
+ export * from './internals.js';
+ export {interpolateColors} from './interpolate-colors.js';
+ export * from './interpolate.js';
+ export {Loop} from './loop/index.js';
+ export {ClipRegion} from './NativeLayers.js';
+ export {prefetch} from './prefetch.js';
+ export {random, RandomSeed} from './random.js';
+ export {registerRoot} from './register-root.js';
+ export {Sequence} from './Sequence.js';
+ export {Series} from './series/index.js';
+ export * from './spring/index.js';
+ export {staticFile} from './static-file.js';
+ export * from './Still.js';
+ export type {PlayableMediaTag} from './timeline-position-state.js';
+ export {useCurrentFrame} from './use-current-frame.js';
+ export * from './use-video-config.js';
+ export * from './version.js';
+ export * from './video-config.js';
+ export * from './video/index.js';
export const Experimental = {
+ /**
+ * @description This is a special component that will cause Remotion to only partially capture the frame of the video.
+ * @see [Documentation](https://www.remotion.dev/docs/clipper)
+ */
Clipper,
+ /**
+ * @description This is a special component, that, when rendered, will skip rendering the frame altogether.
+ * @see [Documentation](https://www.remotion.dev/docs/null)
+ */
Null,
useIsPlayer,
};
diff --cc packages/docs/docs/4-0-migration.md
index 0f56429713,992742e431..ad111f4865
--- a/packages/docs/docs/4-0-migration.md
+++ b/packages/docs/docs/4-0-migration.md
@@@ -29,9 -29,21 +29,28 @@@ Upgrade `remotion` and all packages sta
Run `npm i `, `yarn` or `pnpm i` respectively afterwards.
+## Config file changes
+
+```diff
+- import {Config} from 'remotion';
++ import {Config} from '@remotion/cli/config';
+```
++
+ ## Dropped support for Lambda `architecture`
+
+ When deploying a Lambda, you were previously able to choose between the `arm64` and `x86_64` architecture.
+ From v4.0 on, only `arm64` is supported. It should be faster, cheaper and not have any different behavior than `x86_64`.
+
+ **How to upgrade**: Remove the `architecture` option from `estimatePrice()` and `deployFunction()`.
+
+ ## Rich timeline removed
+
+ The option to use the "Rich timeline" has been removed due to performance problems.
+ The timeline is now always in simple mode, but supports more timeline layers at once.
+
+ ## ProRes videos now export uncompressed audio by default
+
+ Previously, the `aac` audio codec was the default for ProRes exports. The default is now `pcm_s16le` which stands for uncompressed 16-bit low-endian PCM audio.
+ This change was made since users export ProRes mainly for getting high-quality footage to be further used in video editing programs.
+
+ ## No more FFmpeg install, `ffmpegExecutable` option removed
diff --cc packages/example/remotion.config.ts
index 06b1de6e24,8c4a2cd3e9..f02daee66e
--- a/packages/example/remotion.config.ts
+++ b/packages/example/remotion.config.ts
@@@ -2,5 -2,4 +2,4 @@@ import {Config} from '@remotion/cli/con
import {webpackOverride} from './src/webpack-override';
Config.setOverwriteOutput(true);
-Config.Bundling.overrideWebpackConfig(webpackOverride);
+Config.overrideWebpackConfig(webpackOverride);
- Config.setPort(8080);