Skip to content

πŸŽ₯ Make videos programmatically with React

`@remotion/studio`: Premount components for 2 seconds by default

JonnyBurger226091c4894e
diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts
index e1dce35ce9..68e5812e43 100644
--- a/packages/cli/src/config/index.ts
+++ b/packages/cli/src/config/index.ts
@@ -686,12 +686,12 @@ type FlatConfig = RemotionConfigObject &
setDefaultEditor: (editor: DefaultEditor) => void;
/**
* Set the default premount duration in seconds in Remotion Studio.
- * Default: 0 in v4, 2 in v5.
+ * Default: 2.
*/
setDefaultPremountInSeconds: (seconds: number) => void;
/**
* Show premounting indicators in the Studio timeline.
- * @default true
+ * @default false
*/
setShowPremounting: (show: boolean) => void;
/**
diff --git a/packages/core/src/default-premount-in-seconds.ts b/packages/core/src/default-premount-in-seconds.ts
index 8eccc255b3..55426331cc 100644
--- a/packages/core/src/default-premount-in-seconds.ts
+++ b/packages/core/src/default-premount-in-seconds.ts
@@ -1,6 +1,5 @@
-import {ENABLE_V5_BREAKING_CHANGES} from './v5-flag.js';
-
-export const DEFAULT_PREMOUNT_IN_SECONDS = ENABLE_V5_BREAKING_CHANGES ? 2 : 0;
+export const DEFAULT_PREMOUNT_IN_SECONDS = 0;
+export const DEFAULT_STUDIO_PREMOUNT_IN_SECONDS = 2;
export const validateDefaultPremountInSeconds = (value: unknown) => {
if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) {
diff --git a/packages/core/src/no-react.ts b/packages/core/src/no-react.ts
index c5f08c1b3c..cb75a2e7c6 100644
--- a/packages/core/src/no-react.ts
+++ b/packages/core/src/no-react.ts
@@ -28,6 +28,7 @@ export type {VideoConfig} from './video-config';
import {
DEFAULT_PREMOUNT_IN_SECONDS,
+ DEFAULT_STUDIO_PREMOUNT_IN_SECONDS,
validateDefaultPremountInSeconds,
} from './default-premount-in-seconds';
import {
@@ -64,6 +65,7 @@ import {getOffthreadVideoSource} from './video/offthread-video-source';
export const NoReactInternals = {
DEFAULT_PREMOUNT_IN_SECONDS,
+ DEFAULT_STUDIO_PREMOUNT_IN_SECONDS,
DEFAULT_SEQUENCE_ACTIVITY_LIMIT,
validateDefaultPremountInSeconds,
evaluateSourceNumericValue,
diff --git a/packages/docs/docs/5-0-migration.mdx b/packages/docs/docs/5-0-migration.mdx
index da9ca40394..20b386f2c4 100644
--- a/packages/docs/docs/5-0-migration.mdx
+++ b/packages/docs/docs/5-0-migration.mdx
@@ -174,13 +174,6 @@ loadFont('normal', {
**Required action**: Ensure custom fonts are loaded before calling these APIs, or pass `validateFontIsLoaded: false` explicitly to keep the previous behavior. See [layout utils best practices](/docs/layout-utils/best-practices).
-## Default premount duration is now 2 seconds
-
-The default [premount duration](/docs/player/premounting) for timed components changes from `0` to `2` seconds in the Studio and Player.
-This prepares assets before components appear. Explicit `premountFor` props continue to take precedence. Premounting does not affect rendering.
-
-**Required action**: To keep the v4 default, set [`Config.setDefaultPremountInSeconds(0)`](/docs/config#setdefaultpremountinseconds) for the Studio and [`defaultPremountInSeconds={0}`](/docs/player/player#defaultpremountinseconds) on the Player. You can also use [`--default-premount-in-seconds=0`](/docs/options/default-premount-in-seconds) or change the Studio settings. For an individual component, pass [`premountFor={0}`](/docs/sequence#premountfor).
-
## `<Player>` does not create shared audio tags by default
The default [`numberOfSharedAudioTags`](/docs/player/player#numberofsharedaudiotags) value of the [`<Player>`](/docs/player/player) has changed from `5` to `0`.
diff --git a/packages/docs/docs/config.mdx b/packages/docs/docs/config.mdx
index b1454693a4..4992cea279 100644
--- a/packages/docs/docs/config.mdx
+++ b/packages/docs/docs/config.mdx
@@ -334,7 +334,7 @@ The [`--experimental-sequence-activity-limit`](/docs/options/experimental-sequen
```ts twoslash title="remotion.config.ts"
import {Config} from '@remotion/cli/config';
// ---cut---
-Config.setShowPremounting(false);
+Config.setShowPremounting(true);
```
The [`--show-premounting`](/docs/options/show-premounting) flag takes precedence over this option.
diff --git a/packages/docs/docs/options/default-premount-in-seconds.mdx b/packages/docs/docs/options/default-premount-in-seconds.mdx
index 37a22e2b0e..116b0fdc31 100644
--- a/packages/docs/docs/options/default-premount-in-seconds.mdx
+++ b/packages/docs/docs/options/default-premount-in-seconds.mdx
@@ -9,7 +9,7 @@ custom_edit_url: https://github.com/remotion-dev/remotion/edit/main/packages/ren
# Default premount duration in seconds<AvailableFrom v="4.0.535" />
-Set the default premount duration in seconds for timed components in the Studio. Defaults to 0 in v4 and 2 in v5. Must be a finite, non-negative number. The duration is converted to frames using the composition FPS and rounded to the nearest frame. An explicit `premountFor` prop takes precedence. Does not affect rendering. In the Player, use the `defaultPremountInSeconds` prop instead.
+Set the default premount duration in seconds for timed components in the Studio. Defaults to 2. Must be a finite, non-negative number. The duration is converted to frames using the composition FPS and rounded to the nearest frame. An explicit `premountFor` prop takes precedence. Does not affect rendering. In the Player, use the `defaultPremountInSeconds` prop instead.
## CLI flag
diff --git a/packages/docs/docs/options/show-premounting.mdx b/packages/docs/docs/options/show-premounting.mdx
index 4a9d21c175..96d7babba7 100644
--- a/packages/docs/docs/options/show-premounting.mdx
+++ b/packages/docs/docs/options/show-premounting.mdx
@@ -9,7 +9,7 @@ custom_edit_url: https://github.com/remotion-dev/remotion/edit/main/packages/ren
# 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.
+Show premounting indicators for components on separate Studio timeline rows. Defaults to `false`. Selecting a component's "Premount For" property shows its premounted range regardless of this setting.
## CLI flag
@@ -26,7 +26,7 @@ The following CLI commands accept this option:
```ts twoslash title="remotion.config.ts"
import {Config} from '@remotion/cli/config';
// ---cut---
-Config.setShowPremounting(false);
+Config.setShowPremounting(true);
```
## See also
diff --git a/packages/docs/docs/player/api.mdx b/packages/docs/docs/player/api.mdx
index 09a563377b..9fbb5ae67c 100644
--- a/packages/docs/docs/player/api.mdx
+++ b/packages/docs/docs/player/api.mdx
@@ -414,7 +414,7 @@ Either `player-size` (default) or `composition-size`:
### `defaultPremountInSeconds?`<AvailableFrom v="4.0.535" />
-The default [premount duration](/docs/player/premounting) in seconds for timed components inside the Player. Defaults to `0` in v4 and `2` in v5.
+The default [premount duration](/docs/player/premounting) in seconds for timed components inside the Player. Defaults to `0`.
Must be a finite, non-negative number. The duration is converted to frames using `fps` and rounded to the nearest frame.
An explicit [`premountFor`](/docs/sequence#premountfor) prop takes precedence, including `premountFor={0}` to disable premounting for a component.
diff --git a/packages/docs/docs/player/premounting.mdx b/packages/docs/docs/player/premounting.mdx
index 0d00521fe6..cf26b7a376 100644
--- a/packages/docs/docs/player/premounting.mdx
+++ b/packages/docs/docs/player/premounting.mdx
@@ -23,10 +23,50 @@ With premounting, the component mounts earlier, stays hidden, and waits at its f
<Premounting />
-## Premounting components
+## Default premounting in Studio<AvailableFrom v="4.0.535" />
-Pass [`premountFor`](/docs/img#premountfor) directly to the component you want to prepare. The value is the number of frames before its start at which it should mount.
+The [Remotion Studio](/docs/studio) premounts components automatically from v4.0.535 for 2 seconds.
+Configure this with [`Config.setDefaultPremountInSeconds()`](/docs/config#setdefaultpremountinseconds) or the Studio settings.
+
+Open Settings in the top-right corner of Studio. Under Playback, change "Default premount in seconds". Premounting indicators are hidden by default.
+
+<img src="/img/studio-premount-settings.jpg" alt="Studio settings with Show premounting in timeline unchecked and Default premount in seconds set to Default (2)" />
+
+## Default premounting in the Player
+
+The [Player](/docs/player) does not premount components by default.
+
+Pass the [`defaultPremountInSeconds`](/docs/player/player#defaultpremountinseconds) prop to do so:
+
+```tsx twoslash title="MyPlayer.tsx"
+import {Player} from '@remotion/player';
+
+const MyComposition: React.FC = () => null;
+// ---cut---
+export const MyPlayer: React.FC = () => {
+ return (
+ <Player
+ component={MyComposition}
+ durationInFrames={150}
+ fps={30}
+ compositionWidth={1920}
+ compositionHeight={1080}
+ defaultPremountInSeconds={2}
+ />
+ );
+};
+```
+
+Seconds are converted to frames using the composition FPS and rounded to the nearest frame. At 30 FPS, `2` seconds means `60` frames of premounting.
+
+An explicit `premountFor` overrides the default. Pass `premountFor={0}` to disable premounting for a component.
+
+## Components which support premounting
+
+The following components support premounting:
+
+- [`<Sequence>`](/docs/sequence)
- [`<Video>`](/docs/media/video) and [`<Audio>`](/docs/media/audio) from `@remotion/media`
- [`<Img>`](/docs/img), [`<AnimatedImage>`](/docs/animatedimage), [`<Gif>`](/docs/gif/gif)
- [`<Lottie>`](/docs/lottie/lottie), [`<RemotionRiveCanvas>`](/docs/rive/remotionrivecanvas)
@@ -35,9 +75,11 @@ Pass [`premountFor`](/docs/img#premountfor) directly to the component you want t
- [Shape components](/docs/shapes), [`<MacOSCursor>`](/docs/mac-cursors/mac-os-cursor), [rough-notation components](/docs/rough-notation/api)
- [`<ThreeCanvas>`](/docs/three-canvas), [`<ThreeWebGPUCanvas>`](/docs/three-webgpu-canvas)
-Containers with a `layout` prop must use `layout="absolute-fill"` for premounting, including default premounting.
+Use [`premountFor`](/docs/img#premountfor) to individually control the premounting duration in frames for each component.
-For example, this image mounts at frame 30 and becomes visible at frame 60:
+Containers with a `layout` prop must use `layout="absolute-fill"` for premounting to work.
+
+Example: Image mounts at frame 30 and becomes visible at frame 60:
```tsx twoslash title="PremountedImage.tsx"
import {Img, staticFile} from 'remotion';
@@ -54,15 +96,19 @@ export const PremountedImage: React.FC = () => {
};
```
-The same `from={60}` and `premountFor={30}` values work on a video, a Lottie animation, or any of the other components above. Each gets 30 frames to prepare before its start.
+## Seeing if a component is premounted
+
+Enable premounting indicators with [`Config.setShowPremounting(true)`](/docs/config#setshowpremounting) or check "Show premounting in timeline" under Settings β†’ Studio β†’ Interface.
-While premounted, components are hidden and do not respond to pointer events. Use `styleWhilePremounted` to customize these styles.
+Diagonal stripes indicate the premounted range:
-In the Studio timeline, diagonal stripes indicate the premounted range:
+<img src="/img/studio-premount-indicators.jpg" alt="Studio timeline with diagonal stripes before each sequence and 0 (Premounted) at the current frame" />
-<img src="/img/premount.png" alt="A premounted range shown with diagonal stripes in the Studio timeline" />
+To inspect one component while indicators are disabled, select it in the timeline and click "Premount For" under Layout in the Inspector. Its premounted range stays visible while the property is selected.
-Hide these indicators with [`Config.setShowPremounting(false)`](/docs/config#setshowpremounting) or the Studio settings.
+<img src="/img/studio-premount-selected.jpg" alt="Premount For selected in the Inspector and timeline, revealing stripes for the selected sequence while the other sequence has no premount indicator" />
+
+Premounting indicators are shown for components on separate timeline rows. Clips grouped in a packed track do not display premounted ranges.
## Premounting a whole scene
@@ -87,37 +133,6 @@ A child can only premount while its parent is mounted. Premount the outer contai
For custom components, see [Make a component interactive](/docs/studio/make-component-interactive).
-## Default premount duration<AvailableFrom v="4.0.535" />
-
-Use [`defaultPremountInSeconds`](/docs/options/default-premount-in-seconds) to premount components without setting `premountFor` on each one. The default is `0` seconds in v4 and `2` seconds in [v5](/docs/5-0-migration), for both Studio and Player.
-
-In the Studio, configure it with [`Config.setDefaultPremountInSeconds()`](/docs/config#setdefaultpremountinseconds), the [`--default-premount-in-seconds`](/docs/options/default-premount-in-seconds) CLI flag, or the Studio settings. The empty template already sets `2` seconds in its config file.
-
-In the Player, pass the [`defaultPremountInSeconds`](/docs/player/player#defaultpremountinseconds) prop:
-
-```tsx twoslash title="MyPlayer.tsx"
-import {Player} from '@remotion/player';
-
-const MyComposition: React.FC = () => null;
-// ---cut---
-export const MyPlayer: React.FC = () => {
- return (
- <Player
- component={MyComposition}
- durationInFrames={150}
- fps={30}
- compositionWidth={1920}
- compositionHeight={1080}
- defaultPremountInSeconds={2}
- />
- );
-};
-```
-
-Seconds are converted to frames using the composition FPS and rounded to the nearest frame. At 30 FPS, `2` seconds means `60` frames of premounting.
-
-An explicit `premountFor` overrides the default. Pass `premountFor={0}` to disable premounting for a component.
-
## Usage together with the buffer state
Loading an invisible component should not pause playback. Components that support the [buffer state](/docs/player/buffer-state), such as [`<Video>`](/docs/media/video), [`<Audio>`](/docs/media/audio), and [`<Img>`](/docs/img#pausewhenloading), do not trigger it while premounted. This also applies to [`<Html5Audio>`](/docs/html5-audio#pausewhenbuffering), [`<Html5Video>`](/docs/html5-video#pausewhenbuffering), and [`<OffthreadVideo>`](/docs/offthreadvideo#pausewhenbuffering) inside a premounted scene.
diff --git a/packages/docs/docs/sequence.mdx b/packages/docs/docs/sequence.mdx
index 6688efc39d..c0dd30183d 100644
--- a/packages/docs/docs/sequence.mdx
+++ b/packages/docs/docs/sequence.mdx
@@ -309,7 +309,7 @@ If `layout` is set to `none`, there is no container and setting this style is no
### `premountFor?`<AvailableFrom v="4.0.140" />
[Premount](/docs/player/premounting) the sequence for a set number of frames.
-The default is controlled by [`defaultPremountInSeconds`](/docs/player/premounting#default-premount-duration), converted to frames. It is `0` seconds in v4 and `2` seconds in [v5.0](/docs/5-0-migration).
+The default is `2` seconds in the [Studio](/docs/player/premounting#default-premounting-in-studio) and `0` seconds in the [Player](/docs/player/premounting#default-premounting-in-the-player), converted to frames. An explicit `premountFor` takes precedence.
### `postmountFor?`<AvailableFrom v="4.0.340" />
diff --git a/packages/docs/docs/series.mdx b/packages/docs/docs/series.mdx
index c62bbca6af..b50621d70f 100644
--- a/packages/docs/docs/series.mdx
+++ b/packages/docs/docs/series.mdx
@@ -110,7 +110,7 @@ Whether this sequence should be shown in the timeline in the Studio. See [`showI
### `premountFor?`<AvailableFrom v="4.0.140"/>
[Premount](/docs/player/premounting) the sequence for a set number of frames.
-The default is controlled by [`defaultPremountInSeconds`](/docs/player/premounting#default-premount-duration), converted to frames. It is `0` seconds in v4 and `2` seconds in [v5.0](/docs/5-0-migration).
+The default is `2` seconds in the [Studio](/docs/player/premounting#default-premounting-in-studio) and `0` seconds in the [Player](/docs/player/premounting#default-premounting-in-the-player), converted to frames. An explicit `premountFor` takes precedence.
### `ref?`<AvailableFrom v="3.3.4" />
diff --git a/packages/docs/static/img/studio-premount-indicators.jpg b/packages/docs/static/img/studio-premount-indicators.jpg
new file mode 100644
index 0000000000..dd232bfcf0
Binary files /dev/null and b/packages/docs/static/img/studio-premount-indicators.jpg differ
diff --git a/packages/docs/static/img/studio-premount-selected.jpg b/packages/docs/static/img/studio-premount-selected.jpg
new file mode 100644
index 0000000000..1d0223d49f
Binary files /dev/null and b/packages/docs/static/img/studio-premount-selected.jpg differ
diff --git a/packages/docs/static/img/studio-premount-settings.jpg b/packages/docs/static/img/studio-premount-settings.jpg
new file mode 100644
index 0000000000..e2216a546e
Binary files /dev/null and b/packages/docs/static/img/studio-premount-settings.jpg differ
diff --git a/packages/renderer/src/options/default-premount-in-seconds.tsx b/packages/renderer/src/options/default-premount-in-seconds.tsx
index 22602fe828..3b41950c3b 100644
--- a/packages/renderer/src/options/default-premount-in-seconds.tsx
+++ b/packages/renderer/src/options/default-premount-in-seconds.tsx
@@ -12,10 +12,10 @@ export const defaultPremountInSecondsOption = {
description: () => (
<>
Set the default premount duration in seconds for timed components in the
- Studio. Defaults to 0 in v4 and 2 in v5. Must be a finite, non-negative
- number. The duration is converted to frames using the composition FPS and
- rounded to the nearest frame. An explicit <code>premountFor</code> prop
- takes precedence. Does not affect rendering. In the Player, use the{' '}
+ Studio. Defaults to 2. Must be a finite, non-negative number. The duration
+ is converted to frames using the composition FPS and rounded to the
+ nearest frame. An explicit <code>premountFor</code> prop takes precedence.
+ Does not affect rendering. In the Player, use the{' '}
<code>defaultPremountInSeconds</code> prop instead.
</>
),
@@ -32,7 +32,7 @@ export const defaultPremountInSecondsOption = {
return {
value:
configuredDefaultPremountInSeconds ??
- NoReactInternals.DEFAULT_PREMOUNT_IN_SECONDS,
+ NoReactInternals.DEFAULT_STUDIO_PREMOUNT_IN_SECONDS,
source: 'config',
};
},
diff --git a/packages/renderer/src/options/show-premounting.tsx b/packages/renderer/src/options/show-premounting.tsx
index 374528c7a1..5885483420 100644
--- a/packages/renderer/src/options/show-premounting.tsx
+++ b/packages/renderer/src/options/show-premounting.tsx
@@ -11,9 +11,10 @@ export const showPremountingOption = {
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.
+ Show premounting indicators for components on separate Studio timeline
+ rows. Defaults to <code>false</code>. Selecting a component&apos;s
+ &quot;Premount For&quot; property shows its premounted range regardless of
+ this setting.
</>
),
ssrName: null,
@@ -24,7 +25,7 @@ export const showPremountingOption = {
return {value: commandLine[cliFlag] as boolean, source: 'cli'};
}
- return {value: configuredShowPremounting ?? true, source: 'config'};
+ return {value: configuredShowPremounting ?? false, source: 'config'};
},
setConfig(value) {
if (typeof value !== 'boolean') {
diff --git a/packages/studio/src/components/StudioSettings.tsx b/packages/studio/src/components/StudioSettings.tsx
index 5bbe88b46a..98786ffde5 100644
--- a/packages/studio/src/components/StudioSettings.tsx
+++ b/packages/studio/src/components/StudioSettings.tsx
@@ -328,7 +328,7 @@ export const StudioSettings: React.FC = () => {
<div style={label}>Show premounting in timeline</div>
<div style={rightRow}>
<Checkbox
- checked={settings.showPremounting ?? true}
+ checked={settings.showPremounting ?? false}
name="Show premounting in timeline"
onChange={(event) =>
changeSetting(
@@ -427,7 +427,7 @@ export const StudioSettings: React.FC = () => {
<p style={sectionTitle}>Playback</p>
<ConfigNumber
- defaultValue={NoReactInternals.DEFAULT_PREMOUNT_IN_SECONDS}
+ defaultValue={NoReactInternals.DEFAULT_STUDIO_PREMOUNT_IN_SECONDS}
name="Default premount in seconds"
step={0.1}
onChange={(value) =>
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index 5308d411d5..6e27c677b6 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -989,7 +989,16 @@ const useTimelineSequenceState = (props: TimelineSequenceProps) => {
)?.durationInFrames?.status === 'static',
);
const {previewServerState} = useContext(StudioServerConnectionCtx);
- const showPremounting = getStudioShowPremounting();
+ const premountNodePathInfo = useMemo(
+ (): SequenceNodePathInfo | null =>
+ nodePathInfo === null
+ ? null
+ : {...nodePathInfo, auxiliaryKeys: ['controls', 'premountFor']},
+ [nodePathInfo],
+ );
+ const {selected: premountSelected} =
+ useTimelineRowSelection(premountNodePathInfo);
+ const showPremounting = getStudioShowPremounting() || premountSelected;
const previewConnected = previewServerState.type === 'connected';
const previewInteractive = previewConnected && isStudioInteractivityEnabled();
const {setPropStatuses} = useContext(Internals.VisualModeSettersContext);
diff --git a/packages/studio/src/helpers/studio-runtime-config.ts b/packages/studio/src/helpers/studio-runtime-config.ts
index 6721ec83df..4b80f0fa43 100644
--- a/packages/studio/src/helpers/studio-runtime-config.ts
+++ b/packages/studio/src/helpers/studio-runtime-config.ts
@@ -63,12 +63,12 @@ export const getStudioBufferStateDelayInMilliseconds = () => {
export const getStudioDefaultPremountInSeconds = () => {
return (
getStudioRuntimeConfig().defaultPremountInSeconds ??
- NoReactInternals.DEFAULT_PREMOUNT_IN_SECONDS
+ NoReactInternals.DEFAULT_STUDIO_PREMOUNT_IN_SECONDS
);
};
export const getStudioShowPremounting = () => {
- return getStudioRuntimeConfig().showPremounting ?? true;
+ return getStudioRuntimeConfig().showPremounting ?? false;
};
export const getStudioSequenceActivitySettings = () => {