Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Add `Config.setShowPremounting()` for timeline indicators

Jonny Burgerd0603c2f2f74
diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts
index 7abb409563..fcbcf524bf 100644
--- a/packages/cli/src/config/index.ts
+++ b/packages/cli/src/config/index.ts
@@ -141,6 +141,7 @@ const {
defaultCodingAgentOption,
defaultEditorOption,
defaultPremountInSecondsOption,
+ showPremountingOption,
askAIOption,
publicLicenseKeyOption,
interactivityOption,
@@ -682,6 +683,11 @@ type FlatConfig = RemotionConfigObject &
* Default: 0 in v4, 2 in v5.
*/
setDefaultPremountInSeconds: (seconds: number) => void;
+ /**
+ * Show premounting indicators in the Studio timeline.
+ * @default true
+ */
+ setShowPremounting: (show: boolean) => void;
/**
* Set the coding agent used by Remotion Studio.
*/
@@ -910,6 +916,7 @@ export const Config: FlatConfig = {
setDefaultCodingAgent: defaultCodingAgentOption.setConfig,
setDefaultEditor: defaultEditorOption.setConfig,
setDefaultPremountInSeconds: defaultPremountInSecondsOption.setConfig,
+ setShowPremounting: showPremountingOption.setConfig,
setForceNewStudioEnabled: forceNewStudioOption.setConfig,
setIPv4: ipv4Option.setConfig,
setBundleOutDir: outDirOption.setConfig,
diff --git a/packages/cli/src/parsed-cli.ts b/packages/cli/src/parsed-cli.ts
index 4d30854ce3..a5767b8b6a 100644
--- a/packages/cli/src/parsed-cli.ts
+++ b/packages/cli/src/parsed-cli.ts
@@ -35,6 +35,7 @@ const {
defaultCodingAgentOption,
defaultEditorOption,
defaultPremountInSecondsOption,
+ showPremountingOption,
publicLicenseKeyOption,
forceNewStudioOption,
experimentalKeepAudioContextAliveOption,
@@ -115,6 +116,9 @@ export type CommandLineOptions = {
[defaultPremountInSecondsOption.cliFlag]: TypeOfOption<
typeof defaultPremountInSecondsOption
>;
+ [showPremountingOption.cliFlag]: TypeOfOption<
+ typeof showPremountingOption
+ > | null;
[disableWebSecurityOption.cliFlag]: TypeOfOption<
typeof disableWebSecurityOption
> | null;
@@ -231,6 +235,7 @@ export type CommandLineOptions = {
};
export const BooleanFlags = [
+ showPremountingOption.cliFlag,
allowHtmlInCanvasOption.cliFlag,
overwriteOption.cliFlag,
imageSequenceOption.cliFlag,
@@ -266,6 +271,7 @@ export const BooleanFlags = [
export const parsedCli = minimist<CommandLineOptions>(process.argv.slice(2), {
boolean: BooleanFlags,
default: {
+ [showPremountingOption.cliFlag]: null,
[allowHtmlInCanvasOption.cliFlag]: null,
[overwriteOption.cliFlag]: null,
[bundleCacheOption.cliFlag]: null,
diff --git a/packages/cli/src/print-help.ts b/packages/cli/src/print-help.ts
index 2be8870ac2..e31bf259ef 100644
--- a/packages/cli/src/print-help.ts
+++ b/packages/cli/src/print-help.ts
@@ -131,6 +131,7 @@ const studioOptions = options(
'ipv4',
'number-of-shared-audio-tags',
'default-premount-in-seconds',
+ 'show-premounting',
'experimental-keep-audio-context-alive',
'preview-sample-rate',
'cross-site-isolation',
diff --git a/packages/cli/src/studio.ts b/packages/cli/src/studio.ts
index 8c6bb85f10..bf94843921 100644
--- a/packages/cli/src/studio.ts
+++ b/packages/cli/src/studio.ts
@@ -58,6 +58,7 @@ const {
defaultCodingAgentOption,
defaultEditorOption,
defaultPremountInSecondsOption,
+ showPremountingOption,
publicLicenseKeyOption,
beepOnFinishOption,
logLevelOption,
@@ -170,6 +171,9 @@ export const studioCommand = async (
defaultPremountInSeconds: defaultPremountInSecondsOption.getValue({
commandLine: parsedCli,
}).value,
+ showPremounting: showPremountingOption.getValue({
+ commandLine: parsedCli,
+ }).value,
keyboardShortcuts: ConfigInternals.getKeyboardShortcuts(),
askAIEnabled: askAIOption.getValue({
commandLine: parsedCli,
@@ -198,6 +202,7 @@ export const studioCommand = async (
commandLine: parsedCli,
}).value,
configFileStudioSettings: {
+ showPremounting: showPremountingOption.getConfigValue(),
defaultPremountInSeconds:
defaultPremountInSecondsOption.getConfigValue(),
askAIEnabled: askAIOption.getConfigValue(),
diff --git a/packages/docs/docs/cli/studio.mdx b/packages/docs/docs/cli/studio.mdx
index e22942657e..d7d673f516 100644
--- a/packages/docs/docs/cli/studio.mdx
+++ b/packages/docs/docs/cli/studio.mdx
@@ -139,6 +139,14 @@ npx remotion studio --ipv4
npx remotion studio --default-premount-in-seconds=2
```
+### `--show-premounting`<AvailableFrom v="4.0.535" />
+
+<Options id="show-premounting" />
+
+```sh title="Terminal"
+npx remotion studio --show-premounting=false
+```
+
### `--number-of-shared-audio-tags`<AvailableFrom v="3.3.2" />
<Options id="number-of-shared-audio-tags" />
diff --git a/packages/docs/docs/config.mdx b/packages/docs/docs/config.mdx
index 25b81ce87f..98e9481607 100644
--- a/packages/docs/docs/config.mdx
+++ b/packages/docs/docs/config.mdx
@@ -292,6 +292,19 @@ Changes apply immediately in the Studio without reloading the page.
The [`--experimental-tracks`](/docs/options/experimental-tracks) flag takes precedence over this option.
+## `setShowPremounting()`<AvailableFrom v="4.0.535" />
+
+<Options id="show-premounting" />
+
+```ts twoslash title="remotion.config.ts"
+import {Config} from '@remotion/cli/config';
+// ---cut---
+Config.setShowPremounting(false);
+```
+
+You can also change this value in the Studio settings. Changes apply immediately.
+The [`--show-premounting`](/docs/options/show-premounting) flag takes precedence over this option.
+
## `setDefaultPremountInSeconds()`<AvailableFrom v="4.0.535" />
<Options id="default-premount-in-seconds" />
diff --git a/packages/docs/docs/options/index.mdx b/packages/docs/docs/options/index.mdx
index c209abf43a..d979960b50 100644
--- a/packages/docs/docs/options/index.mdx
+++ b/packages/docs/docs/options/index.mdx
@@ -103,6 +103,7 @@ Only the CLI reads the config file. In programmatic APIs, you need to pass all o
- [Sample Rate](/docs/options/sample-rate) (`--sample-rate`)
- [Scale](/docs/options/scale) (`--scale`)
- [Separate audio to](/docs/options/separate-audio-to) (`--separate-audio-to`)
+- [Show premounting in the Studio timeline](/docs/options/show-premounting) (`--show-premounting`)
- [Skip Skills](/docs/options/skip-skills) (`--skip-skills`)
- [Still Image Format](/docs/options/still-image-format) (`--image-format`)
- [Throw if site exists](/docs/options/throw-if-site-exists) (`--throw-if-site-exists`)
diff --git a/packages/docs/docs/options/show-premounting.mdx b/packages/docs/docs/options/show-premounting.mdx
new file mode 100644
index 0000000000..4a9d21c175
--- /dev/null
+++ b/packages/docs/docs/options/show-premounting.mdx
@@ -0,0 +1,34 @@
+---
+image: /generated/articles-docs-options-show-premounting.png
+# Generated by packages/docs/generate-option-docs.ts. Do not edit directly.
+# Regenerate: cd packages/docs && bun run generate-option-docs
+title: "Show premounting in the Studio timeline"
+crumb: Options
+custom_edit_url: https://github.com/remotion-dev/remotion/edit/main/packages/renderer/src/options/show-premounting.tsx
+---
+
+# Show premounting in the Studio timeline<AvailableFrom v="4.0.535" />
+
+Show premounting indicators in the Studio timeline. Defaults to `true`; this may change in a future 4.x release. Set explicitly to preserve your preference.
+
+## CLI flag
+
+```text
+--show-premounting
+```
+
+The following CLI commands accept this option:
+
+- [`remotion studio`](/docs/cli/studio)
+
+## Config file
+
+```ts twoslash title="remotion.config.ts"
+import {Config} from '@remotion/cli/config';
+// ---cut---
+Config.setShowPremounting(false);
+```
+
+## See also
+
+- [All options](/docs/options)
diff --git a/packages/docs/docs/player/premounting.mdx b/packages/docs/docs/player/premounting.mdx
index 41710afaa5..9f6d81ce56 100644
--- a/packages/docs/docs/player/premounting.mdx
+++ b/packages/docs/docs/player/premounting.mdx
@@ -62,6 +62,8 @@ In the Studio timeline, diagonal stripes indicate the premounted range:
<img src="/img/premount.png" alt="A premounted range shown with diagonal stripes in the Studio timeline" />
+Hide these indicators with [`Config.setShowPremounting(false)`](/docs/config#setshowpremounting) or the Studio settings. Premounting still runs, and child items may appear in the timeline while their parent is premounted.
+
## Premounting a whole scene
Set `premountFor` on a container such as [`<AbsoluteFill>`](/docs/absolute-fill) to prepare its children together:
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index 0970f34c53..527117c007 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -1440,6 +1440,15 @@ export const articles = [
noAi: false,
slug: 'options/sequence',
},
+ {
+ id: 'options/show-premounting',
+ title: 'Show premounting in the Studio timeline',
+ relativePath: 'docs/options/show-premounting.mdx',
+ compId: 'articles-docs-options-show-premounting',
+ crumb: 'Options',
+ noAi: false,
+ slug: 'options/show-premounting',
+ },
{
id: 'options/skip-skills',
title: 'Skip Skills',
diff --git a/packages/docs/static/generated/articles-docs-options-show-premounting.png b/packages/docs/static/generated/articles-docs-options-show-premounting.png
new file mode 100644
index 0000000000..0ca0aa6ba4
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-options-show-premounting.png differ
diff --git a/packages/renderer/src/options/index.tsx b/packages/renderer/src/options/index.tsx
index e3d4363747..cac9b3d131 100644
--- a/packages/renderer/src/options/index.tsx
+++ b/packages/renderer/src/options/index.tsx
@@ -85,6 +85,7 @@ import {runsOption} from './runs';
import {sampleRateOption} from './sample-rate';
import {scaleOption} from './scale';
import {separateAudioOption} from './separate-audio';
+import {showPremountingOption} from './show-premounting';
import {skipSkillsOption} from './skip-skills';
import {stillFrameOption} from './still-frame';
import {stillImageFormatOption} from './still-image-format';
@@ -101,6 +102,7 @@ import {webpackPollOption} from './webpack-poll';
import {x264Option} from './x264-preset';
export const allOptions = {
+ showPremountingOption,
allowHtmlInCanvasOption,
audioCodecOption,
benchmarkConcurrenciesOption,
diff --git a/packages/renderer/src/options/show-premounting.tsx b/packages/renderer/src/options/show-premounting.tsx
new file mode 100644
index 0000000000..374528c7a1
--- /dev/null
+++ b/packages/renderer/src/options/show-premounting.tsx
@@ -0,0 +1,40 @@
+import type {AnyRemotionOption} from './option';
+
+let configuredShowPremounting: boolean | null = null;
+
+const cliFlag = 'show-premounting' as const;
+
+export const showPremountingOption = {
+ name: 'Show premounting in the Studio timeline',
+ addedIn: '4.0.535',
+ cliFlag,
+ id: cliFlag,
+ description: () => (
+ <>
+ Show premounting indicators in the Studio timeline. Defaults to{' '}
+ <code>true</code>; this may change in a future 4.x release. Set explicitly
+ to preserve your preference.
+ </>
+ ),
+ ssrName: null,
+ docLink: 'https://www.remotion.dev/docs/options/show-premounting',
+ type: true as boolean,
+ getValue: ({commandLine}) => {
+ if (commandLine[cliFlag] !== undefined && commandLine[cliFlag] !== null) {
+ return {value: commandLine[cliFlag] as boolean, source: 'cli'};
+ }
+
+ return {value: configuredShowPremounting ?? true, source: 'config'};
+ },
+ setConfig(value) {
+ if (typeof value !== 'boolean') {
+ throw new Error('Config.setShowPremounting() expects a boolean');
+ }
+
+ configuredShowPremounting = value;
+ },
+ getConfigValue: () => configuredShowPremounting,
+ reset: () => {
+ configuredShowPremounting = null;
+ },
+} satisfies AnyRemotionOption<boolean>;
diff --git a/packages/studio-shared/src/config-method-lifecycles.ts b/packages/studio-shared/src/config-method-lifecycles.ts
index c10d0ae6b6..7edf94fcbb 100644
--- a/packages/studio-shared/src/config-method-lifecycles.ts
+++ b/packages/studio-shared/src/config-method-lifecycles.ts
@@ -94,6 +94,7 @@ export const configMethodLifecycles = {
setSampleRate: 'runtime',
setScale: 'runtime',
setShouldOpenBrowser: 'restart',
+ setShowPremounting: 'runtime',
setStillImageFormat: 'runtime',
setStudioPort: 'restart',
setTimeoutInMilliseconds: 'runtime',
diff --git a/packages/studio-shared/src/studio-runtime-config.ts b/packages/studio-shared/src/studio-runtime-config.ts
index 601fe4c35f..02961d6a74 100644
--- a/packages/studio-shared/src/studio-runtime-config.ts
+++ b/packages/studio-shared/src/studio-runtime-config.ts
@@ -6,6 +6,7 @@ import type {
import type {StudioKeyboardShortcuts} from './keyboard-shortcuts';
export type ConfigFileStudioSettings = {
+ readonly showPremounting?: boolean | null;
readonly defaultPremountInSeconds?: number | null;
readonly askAIEnabled: boolean | null;
readonly audioLatencyHint: AudioContextLatencyCategory | null;
@@ -27,6 +28,7 @@ export type StudioElementLibrary = {
};
export type StudioRuntimeConfig = {
+ readonly showPremounting?: boolean;
readonly defaultPremountInSeconds?: number;
readonly maxTimelineTracks: number | null;
readonly askAIEnabled: boolean;
diff --git a/packages/studio/src/components/StudioSettings.tsx b/packages/studio/src/components/StudioSettings.tsx
index 737b86fdd7..c7cb0bc0ea 100644
--- a/packages/studio/src/components/StudioSettings.tsx
+++ b/packages/studio/src/components/StudioSettings.tsx
@@ -45,6 +45,7 @@ const resetIcon: React.CSSProperties = {
};
const initialSettings: ConfigFileStudioSettings = {
+ showPremounting: null,
defaultPremountInSeconds: null,
askAIEnabled: null,
audioLatencyHint: null,
@@ -187,6 +188,7 @@ export const StudioSettings: React.FC = () => {
: {setter, type: 'set', value};
const updatesForEditedSetters = [
+ update('setShowPremounting', settings.showPremounting),
update('setAskAIEnabled', settings.askAIEnabled),
update('setEnableCrossSiteIsolation', settings.enableCrossSiteIsolation),
update('setBeepOnFinish', settings.beepOnFinish),
@@ -297,6 +299,22 @@ export const StudioSettings: React.FC = () => {
/>
<p style={sectionTitle}>Interface</p>
+ <label style={optionRow}>
+ <div style={label}>Show premounting in timeline</div>
+ <div style={rightRow}>
+ <Checkbox
+ checked={settings.showPremounting ?? true}
+ name="Show premounting in timeline"
+ onChange={(event) =>
+ changeSetting(
+ 'showPremounting',
+ 'setShowPremounting',
+ event.target.checked,
+ )
+ }
+ />
+ </div>
+ </label>
<label style={optionRow}>
<div style={label}>Ask AI enabled</div>
<div style={rightRow}>
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index 450760410d..4037c3278b 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -42,6 +42,7 @@ import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sor
import {isStudioInteractivityEnabled} from '../../helpers/interactivity-enabled';
import {isVideoWithLastFrameHold} from '../../helpers/is-video-with-last-frame-hold';
import {getSequenceAnnotationAttributes} from '../../helpers/sequence-annotation';
+import {getStudioShowPremounting} from '../../helpers/studio-runtime-config';
import {
getTimelineLayerHeight,
TIMELINE_ITEM_BORDER_BOTTOM,
@@ -957,6 +958,7 @@ const TimelineSequenceInner: React.FC<{
)?.durationInFrames?.status === 'static',
);
const {previewServerState} = useContext(StudioServerConnectionCtx);
+ const showPremounting = getStudioShowPremounting();
const previewConnected = previewServerState.type === 'connected';
const previewInteractive = previewConnected && isStudioInteractivityEnabled();
const {setPropStatuses} = useContext(Internals.VisualModeSettersContext);
@@ -1373,7 +1375,8 @@ const TimelineSequenceInner: React.FC<{
video,
windowWidth,
// Premounting does not occupy space in a packed track.
- premountDisplay: s.timelineTrack ? null : s.premountDisplay,
+ premountDisplay:
+ s.timelineTrack || !showPremounting ? null : s.premountDisplay,
postmountDisplay: s.postmountDisplay,
});
}, [
@@ -1381,6 +1384,7 @@ const TimelineSequenceInner: React.FC<{
displayDurationInFrames,
effectiveMaxMediaDuration,
s,
+ showPremounting,
video,
windowWidth,
]);
diff --git a/packages/studio/src/helpers/studio-runtime-config.ts b/packages/studio/src/helpers/studio-runtime-config.ts
index 3b40c80c7b..f408015195 100644
--- a/packages/studio/src/helpers/studio-runtime-config.ts
+++ b/packages/studio/src/helpers/studio-runtime-config.ts
@@ -61,3 +61,7 @@ export const getStudioDefaultPremountInSeconds = () => {
NoReactInternals.DEFAULT_PREMOUNT_IN_SECONDS
);
};
+
+export const getStudioShowPremounting = () => {
+ return getStudioRuntimeConfig().showPremounting ?? true;
+};