Skip to content

🎥 Make videos programmatically with React

Config.Preview.setMaxTimelineTracks()

Jonny Burger87d4a45d65ad
diff --git a/packages/bundler/src/start-server.ts b/packages/bundler/src/start-server.ts
index f0ade49811..d347c3c558 100644
--- a/packages/bundler/src/start-server.ts
+++ b/packages/bundler/src/start-server.ts
@@ -20,6 +20,7 @@ export const startServer = async (
inputProps?: object;
envVariables?: Record<string, string>;
port?: number;
+ maxTimelineTracks?: number;
}
): Promise<number> => {
const app = express();
@@ -36,6 +37,7 @@ export const startServer = async (
options?.webpackOverride ?? Internals.getWebpackOverrideFn(),
inputProps: options?.inputProps ?? {},
envVariables: options?.envVariables ?? {},
+ maxTimelineTracks: options?.maxTimelineTracks ?? 15,
});
const compiler = webpack(config);
diff --git a/packages/bundler/src/webpack-config.ts b/packages/bundler/src/webpack-config.ts
index a698e8325c..99f7646ec3 100644
--- a/packages/bundler/src/webpack-config.ts
+++ b/packages/bundler/src/webpack-config.ts
@@ -21,6 +21,7 @@ export const webpackConfig = ({
enableCaching = Internals.DEFAULT_WEBPACK_CACHE_ENABLED,
inputProps,
envVariables,
+ maxTimelineTracks,
}: {
entry: string;
userDefinedComponent: string;
@@ -31,6 +32,7 @@ export const webpackConfig = ({
enableCaching?: boolean;
inputProps?: object;
envVariables?: Record<string, string>;
+ maxTimelineTracks: number;
}): WebpackConfiguration => {
return webpackOverride({
optimization: {
@@ -71,6 +73,7 @@ export const webpackConfig = ({
new ReactRefreshPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
+ 'process.env.MAX_TIMELINE_TRACKS': maxTimelineTracks,
'process.env.INPUT_PROPS': JSON.stringify(inputProps ?? {}),
[`process.env.${Internals.ENV_VARIABLES_ENV_NAME}`]: JSON.stringify(
envVariables ?? {}
diff --git a/packages/cli/src/editor/components/Timeline/MaxTimelineTracks.tsx b/packages/cli/src/editor/components/Timeline/MaxTimelineTracks.tsx
index 47d8907d35..638a30231f 100644
--- a/packages/cli/src/editor/components/Timeline/MaxTimelineTracks.tsx
+++ b/packages/cli/src/editor/components/Timeline/MaxTimelineTracks.tsx
@@ -2,7 +2,10 @@ import React from 'react';
import styled from 'styled-components';
import {TIMELINE_PADDING} from '../../helpers/timeline-layout';
-export const MAX_TIMELINE_TRACKS = 15;
+export const MAX_TIMELINE_TRACKS =
+ typeof process.env.MAX_TIMELINE_TRACKS === 'undefined'
+ ? 15
+ : Number(process.env.MAX_TIMELINE_TRACKS);
const Container = styled.div`
padding-top: 6px;
@@ -18,6 +21,9 @@ export const MaxTimelineTracksReached: React.FC = () => {
return (
<Container>
Limited display to {MAX_TIMELINE_TRACKS} tracks to sustain performance.
+ {''}
+ You can change this by setting Config.Preview.setMaxTimelineTracks() in
+ your remotion.config.ts file.
</Container>
);
};
diff --git a/packages/cli/src/preview.ts b/packages/cli/src/preview.ts
index e820f9f071..2ed2cc45f5 100644
--- a/packages/cli/src/preview.ts
+++ b/packages/cli/src/preview.ts
@@ -3,6 +3,7 @@
import {BundlerInternals} from '@remotion/bundler';
import betterOpn from 'better-opn';
import path from 'path';
+import {Internals} from 'remotion';
import xns from 'xns';
import {getConfigFileName} from './get-config-file-name';
import {getEnvironmentVariables} from './get-env';
@@ -29,6 +30,7 @@ export const previewCommand = xns(async () => {
inputProps,
envVariables,
port: desiredPort,
+ maxTimelineTracks: Internals.getMaxTimelineTracks(),
}
);
betterOpn(`http://localhost:${port}`);
diff --git a/packages/core/src/config/index.ts b/packages/core/src/config/index.ts
index a079d6ff1d..dcfb4bc0ba 100644
--- a/packages/core/src/config/index.ts
+++ b/packages/core/src/config/index.ts
@@ -8,6 +8,7 @@ import {FrameRange, setFrameRange} from './frame-range';
import {ImageFormat, setImageFormat} from './image-format';
import {setImageSequence} from './image-sequence';
import {LogLevel, setLogLevel} from './log';
+import {setMaxTimelineTracks} from './max-timeline-tracks';
import {
overrideWebpackConfig,
WebpackConfiguration,
@@ -21,6 +22,14 @@ import {setQuality} from './quality';
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
diff --git a/packages/core/src/config/max-timeline-tracks.ts b/packages/core/src/config/max-timeline-tracks.ts
new file mode 100644
index 0000000000..8e34273c02
--- /dev/null
+++ b/packages/core/src/config/max-timeline-tracks.ts
@@ -0,0 +1,33 @@
+let maxTimelineTracks = 15;
+
+export const setMaxTimelineTracks = (maxTracks: number) => {
+ if (typeof maxTracks !== 'number') {
+ throw new Error(
+ `Need to pass a number to Config.Preview.setMaxTimelineTracks(), got ${typeof maxTracks}`
+ );
+ }
+
+ if (Number.isNaN(maxTracks)) {
+ throw new Error(
+ `Need to pass a real number to Config.Preview.setMaxTimelineTracks(), got NaN`
+ );
+ }
+
+ if (!Number.isFinite(maxTracks)) {
+ throw new Error(
+ `Need to pass a real number to Config.Preview.setMaxTimelineTracks(), got ${maxTracks}`
+ );
+ }
+
+ if (maxTracks < 0) {
+ throw new Error(
+ `Need to pass a non-negative number to Config.Preview.setMaxTimelineTracks(), got ${maxTracks}`
+ );
+ }
+
+ maxTimelineTracks = maxTracks;
+};
+
+export const getMaxTimelineTracks = () => {
+ return maxTimelineTracks;
+};
diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.ts
index be4def0451..ec2e491e5b 100644
--- a/packages/core/src/internals.ts
+++ b/packages/core/src/internals.ts
@@ -35,6 +35,7 @@ import {
import {getShouldOutputImageSequence} from './config/image-sequence';
import {INPUT_PROPS_KEY} from './config/input-props';
import * as Logging from './config/log';
+import {getMaxTimelineTracks} from './config/max-timeline-tracks';
import {
getWebpackOverrideFn,
WebpackOverrideFn,
@@ -163,6 +164,7 @@ export const Internals = {
getProResProfile,
setProResProfile,
validateSelectedCodecAndProResCombination,
+ getMaxTimelineTracks,
};
export type {
diff --git a/packages/docs/docs/config.mdx b/packages/docs/docs/config.mdx
index 45de7dc06b..047549988a 100644
--- a/packages/docs/docs/config.mdx
+++ b/packages/docs/docs/config.mdx
@@ -75,6 +75,18 @@ Config.Log.setLevel('verbose');
The [command line flag](/docs/cli#--log) `--log` will take precedence over this option.
+## Preview
+
+_Available from Version 2.1.10._
+
+### setMaxTimelineTracks()
+
+Set how many tracks are being displayed in the timeline at most. This does not affect your video, just the amount of tracks shown when previewing. Default `15`.
+
+```ts
+Config.Preview.setMaxTimelineTracks(20);
+```
+
## Puppeteer
### setBrowserExecutable()
@@ -84,7 +96,7 @@ _Available from Version 1.5._
Set a custom Chrome or Chromium executable path. By default Remotion will try to find an existing version of Chrome on your system and if not found, it will download one. This flag is useful if you don't have Chrome installed in a standard location and you want to prevent downloading an additional browser or need [support for the H264 codec](/docs/video#codec-support).
```ts
-Config.Puppeteer.setBrowserExecutable('/usr/bin/google-chrome-stable')
+Config.Puppeteer.setBrowserExecutable('/usr/bin/google-chrome-stable');
```
The [command line flag](/docs/cli#--browser-executable) `--browser-executable` will take precedence over this option.
diff --git a/packages/docs/docs/timeline.md b/packages/docs/docs/timeline.md
index 6020c35550..410d8e3b9c 100644
--- a/packages/docs/docs/timeline.md
+++ b/packages/docs/docs/timeline.md
@@ -32,3 +32,7 @@ More renders also mean slower rendering. If you are suffering from slow playback
The rich timline will become the default in the future, but right now it is disabled by default.
We encourage you to try out the rich timeline mode and [letting us know about any issues you will face.](https://github.com/JonnyBurger/remotion/issues/new).
+
+## See also
+
+- [Customize the number of timeline tracks shown](/docs/config#setmaxtimelinetracks) using the `setMaxTimelineTracks()` configuration.