🎥 Make videos programmatically with React
`@remotion/media`: Add direct premounting to Video and Audio (#9336)
Jonny Burger68007b2a47ed
diff --git a/packages/core/src/Sequence.tsx b/packages/core/src/Sequence.tsxindex 8d2aea2065..f8ac0631e3 100644--- a/packages/core/src/Sequence.tsx+++ b/packages/core/src/Sequence.tsx@@ -17,7 +17,6 @@ import {sequenceSchemaWithoutFrom,} from './interactivity-schema.js';import {useNonce} from './nonce.js';-import {PremountContext} from './PremountContext.js';import type {SequenceContextType} from './SequenceContext.js';import {SequenceContext} from './SequenceContext.js';import {SequenceManager} from './SequenceManager.js';@@ -26,8 +25,8 @@ import {useTimelineContext,useTimelinePosition,} from './timeline-position-state.js';-import {useCurrentFrame} from './use-current-frame';import type {BasicMediaInTimelineReturnType} from './use-media-in-timeline.js';+import {usePremounting} from './use-premounting.js';import {useRemotionEnvironment} from './use-remotion-environment.js';import {useVideoConfig} from './use-video-config.js';import {ENABLE_V5_BREAKING_CHANGES} from './v5-flag.js';@@ -575,10 +574,6 @@ const PremountedPostmountedSequenceRefForwardingFunction: React.ForwardRefRenderHTMLDivElement,SequenceProps> = (props, ref) => {- const parentPremountContext = useContext(PremountContext);- const frame =- useCurrentFrame() - parentPremountContext.premountFramesRemaining;-if (props.layout === 'none') {throw new Error('`<Sequence>` with `premountFor` and `postmountFor` props does not support layout="none"',@@ -596,46 +591,30 @@ const PremountedPostmountedSequenceRefForwardingFunction: React.ForwardRefRender...otherProps} = props;- const endThreshold = Math.ceil(from + durationInFrames - 1);- const premountingActive = frame < from && frame >= from - premountFor;- const postmountingActive =- frame > endThreshold && frame <= endThreshold + postmountFor;-- // Determine which freeze frame to use- const freezeFrame = premountingActive- ? from- : postmountingActive- ? from + durationInFrames - 1- : 0;- const isFreezingActive = premountingActive || postmountingActive;-- const style = useMemo(() => {- return {- ...passedStyle,- opacity:- premountingActive || postmountingActive ? 0 : passedStyle?.opacity,- pointerEvents:- premountingActive || postmountingActive- ? 'none'- : (passedStyle?.pointerEvents ?? undefined),- ...(premountingActive ? styleWhilePremounted : {}),- ...(postmountingActive ? styleWhilePostmounted : {}),- };- }, [- passedStyle,- premountingActive,+ const {+ freezeFrame,+ isPremountingOrPostmounting,postmountingActive,- styleWhilePremounted,- styleWhilePostmounted,- ]);+ premountingActive,+ premountingStyle,+ } = usePremounting({+ from,+ durationInFrames,+ premountFor,+ postmountFor,+ style: passedStyle ?? null,+ styleWhilePremounted: styleWhilePremounted ?? null,+ styleWhilePostmounted: styleWhilePostmounted ?? null,+ hideWhilePremounted: 'opacity',+ });return (- <Freeze frame={freezeFrame} active={isFreezingActive}>+ <Freeze frame={freezeFrame} active={isPremountingOrPostmounting}><SequenceInnerref={ref}from={from}durationInFrames={durationInFrames}- style={style}+ style={premountingStyle ?? undefined}_remotionInternalPremountDisplay={premountFor}_remotionInternalPostmountDisplay={postmountFor}_remotionInternalIsPremounting={premountingActive}diff --git a/packages/core/src/interactivity-schema.ts b/packages/core/src/interactivity-schema.tsindex 4746e4183e..f772b94aeb 100644--- a/packages/core/src/interactivity-schema.ts+++ b/packages/core/src/interactivity-schema.ts@@ -350,6 +350,7 @@ export const premountSchema = {min: 0,step: 1,hiddenFromList: false,+ keyframable: false,},postmountFor: {type: 'number',@@ -357,7 +358,11 @@ export const premountSchema = {min: 0,step: 1,hiddenFromList: true,+ keyframable: false,},+} as const satisfies InteractivitySchema;++export const premountStyleSchema = {styleWhilePremounted: {type: 'hidden',},@@ -366,11 +371,14 @@ export const premountSchema = {},} as const satisfies InteractivitySchema;-export const sequencePremountSchema = premountSchema;+export const sequencePremountSchema = {+ ...premountSchema,+ ...premountStyleSchema,+} as const satisfies InteractivitySchema;export const sequenceStyleSchema = {...transformSchema,- ...premountSchema,+ ...sequencePremountSchema,} as const satisfies InteractivitySchema;export const hiddenField: InteractivitySchemaField = {diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.tsindex 3bdf585bb3..a85642cce7 100644--- a/packages/core/src/internals.ts+++ b/packages/core/src/internals.ts@@ -97,6 +97,7 @@ import {fromField,hiddenField,premountSchema,+ premountStyleSchema,sequencePremountSchema,sequenceSchema,sequenceStyleSchema,@@ -204,6 +205,7 @@ import {useMediaInTimeline,} from './use-media-in-timeline.js';import {PixelDensityContext} from './use-pixel-density.js';+import {usePremounting} from './use-premounting.js';import type {CanUpdateSequencePropStatusFalse,CanUpdateSequencePropStatusEasing,@@ -307,6 +309,7 @@ export const Internals = {textSchema,transformSchema,premountSchema,+ premountStyleSchema,flattenActiveSchema,getFlatSchemaWithAllKeys,RemotionRootContexts,@@ -320,6 +323,7 @@ export const Internals = {truthy,SequenceContext,PremountContext,+ usePremounting,useRemotionContexts,RemotionContextProvider,CSSUtils,diff --git a/packages/core/src/test/with-interactivity-schema-helpers.test.ts b/packages/core/src/test/with-interactivity-schema-helpers.test.tsindex d46b57a26d..44f52d1cd6 100644--- a/packages/core/src/test/with-interactivity-schema-helpers.test.ts+++ b/packages/core/src/test/with-interactivity-schema-helpers.test.ts@@ -12,6 +12,7 @@ import {baseSchema,extendSchemaWithSequenceName,premountSchema,+ sequencePremountSchema,sequenceSchema,sequenceSchemaWithoutFrom,sequenceStyleSchema,@@ -26,10 +27,21 @@ import {selectActiveKeys,} from '../with-interactivity-schema.js';-test('sequenceStyleSchema is the union of transform and premount fields', () => {+test('sequenceStyleSchema contains transform and premount fields', () => {expect(Object.keys(sequenceStyleSchema).sort()).toEqual(- [...Object.keys(transformSchema), ...Object.keys(premountSchema)].sort(),+ [+ ...Object.keys(transformSchema),+ ...Object.keys(sequencePremountSchema),+ ].sort(),+ );+});++test('premount fields are not keyframable', () => {+ expect(Object.keys(premountSchema).sort()).toEqual(+ ['postmountFor', 'premountFor'].sort(),);+ expect(premountSchema.premountFor.keyframable).toBe(false);+ expect(premountSchema.postmountFor.keyframable).toBe(false);});test('baseSchema exposes common timeline fields', () => {diff --git a/packages/core/src/use-premounting.ts b/packages/core/src/use-premounting.tsnew file mode 100644index 0000000000..fe6952156e--- /dev/null+++ b/packages/core/src/use-premounting.ts@@ -0,0 +1,84 @@+import {useContext, useMemo} from 'react';+import type React from 'react';+import {PremountContext} from './PremountContext.js';+import {useCurrentFrame} from './use-current-frame.js';+import {useRemotionEnvironment} from './use-remotion-environment.js';+import {useVideoConfig} from './use-video-config.js';+import {ENABLE_V5_BREAKING_CHANGES} from './v5-flag.js';++export const usePremounting = ({+ from,+ durationInFrames,+ premountFor,+ postmountFor,+ style,+ styleWhilePremounted,+ styleWhilePostmounted,+ hideWhilePremounted,+}: {+ readonly from: number;+ readonly durationInFrames: number;+ readonly premountFor: number | null;+ readonly postmountFor: number | null;+ readonly style: React.CSSProperties | null;+ readonly styleWhilePremounted: React.CSSProperties | null;+ readonly styleWhilePostmounted: React.CSSProperties | null;+ readonly hideWhilePremounted: 'opacity' | 'display-none';+}) => {+ const parentPremountContext = useContext(PremountContext);+ const frame =+ useCurrentFrame() - parentPremountContext.premountFramesRemaining;+ const environment = useRemotionEnvironment();+ const {fps} = useVideoConfig();+ const effectivePremountFor = ENABLE_V5_BREAKING_CHANGES+ ? (premountFor ?? fps)+ : (premountFor ?? 0);+ const effectivePostmountFor = postmountFor ?? 0;+ const endThreshold = Math.ceil(from + durationInFrames - 1);+ const premountingActive =+ !environment.isRendering &&+ frame < from &&+ frame >= from - effectivePremountFor;+ const postmountingActive =+ !environment.isRendering &&+ frame > endThreshold &&+ frame <= endThreshold + effectivePostmountFor;+ const isPremountingOrPostmounting = premountingActive || postmountingActive;+ const freezeFrame = premountingActive+ ? from+ : postmountingActive+ ? from + durationInFrames - 1+ : 0;++ const premountingStyle = useMemo((): React.CSSProperties | null => {+ if (!isPremountingOrPostmounting) {+ return style;+ }++ return {+ ...style,+ ...(hideWhilePremounted === 'opacity' ? {opacity: 0} : {display: 'none'}),+ pointerEvents: 'none',+ ...(premountingActive ? styleWhilePremounted : {}),+ ...(postmountingActive ? styleWhilePostmounted : {}),+ };+ }, [+ isPremountingOrPostmounting,+ hideWhilePremounted,+ postmountingActive,+ premountingActive,+ style,+ styleWhilePostmounted,+ styleWhilePremounted,+ ]);++ return {+ effectivePremountFor,+ effectivePostmountFor,+ premountingActive,+ postmountingActive,+ isPremountingOrPostmounting,+ freezeFrame,+ premountingStyle,+ };+};diff --git a/packages/docs/docs/media/audio.mdx b/packages/docs/docs/media/audio.mdxindex 54ba89fb03..efcbf1085a 100644--- a/packages/docs/docs/media/audio.mdx+++ b/packages/docs/docs/media/audio.mdx@@ -69,6 +69,14 @@ export const MyComposition = () => {};```+### `premountFor?`<AvailableFrom v="4.0.495" />++Mounts the audio for the specified number of frames before its `from` frame, allowing it to buffer before playback starts. See [Premounting](/docs/player/premounting).++### `postmountFor?`<AvailableFrom v="4.0.495" />++Keeps the audio mounted for the specified number of frames after its duration has ended.+### `trimBefore?`Will remove a portion of the audio at the beginning (left side).diff --git a/packages/docs/docs/media/video.mdx b/packages/docs/docs/media/video.mdxindex a896c1b40d..50926b4b08 100644--- a/packages/docs/docs/media/video.mdx+++ b/packages/docs/docs/media/video.mdx@@ -92,6 +92,24 @@ export const MyComposition = () => {};```+### `premountFor?`<AvailableFrom v="4.0.495" />++Mounts the video for the specified number of frames before its `from` frame. The video carries `display: none` and is frozen at its first frame while premounted, so it does not affect layout.++Use this prop to let the video buffer before it becomes visible. See [Premounting](/docs/player/premounting).++### `postmountFor?`<AvailableFrom v="4.0.495" />++Keeps the video mounted for the specified number of frames after its duration has ended. The video is invisible and frozen at its final frame while postmounted.++### `styleWhilePremounted?`<AvailableFrom v="4.0.495" />++CSS styles applied to the video while it is premounted. These styles override the default `display: none` and `pointer-events: none` styles.++### `styleWhilePostmounted?`<AvailableFrom v="4.0.495" />++CSS styles applied to the video while it is postmounted. These styles override the default `display: none` and `pointer-events: none` styles.+### `trimBefore?`Will remove a portion of the video at the beginning (left side).diff --git a/packages/docs/docs/player/premounting.mdx b/packages/docs/docs/player/premounting.mdxindex 5a308c6b20..2841f5e4a2 100644--- a/packages/docs/docs/player/premounting.mdx+++ b/packages/docs/docs/player/premounting.mdx@@ -65,6 +65,19 @@ A premounted [`<Sequence>`](/docs/sequence) does carry the styles `opacity: 0` aIt is not possible to premount a [`<Sequence>`](/docs/sequence) with `layout="none"` because such a sequence does not have a container to apply the styles to.+## Premounting media<AvailableFrom v="4.0.495" />++[`<Video>`](/docs/media/video) and [`<Audio>`](/docs/media/audio) from `@remotion/media` accept `premountFor` directly. They remain layoutless, carry `display: none` while premounted and register the premounted range in the Studio timeline.++```tsx twoslash title="PremountedVideo.tsx"+import {Video} from '@remotion/media';+import {staticFile} from 'remotion';++export const MyVideo = () => {+ return <Video src={staticFile('video.mp4')} from={60} premountFor={30} />;+};+```+## With `<Series>` and `<TransitionSeries>``premountFor` is also available on [`<Series.Sequence>`](/docs/series) and [`<TransitionSeries.Sequence>`](/docs/transitions/transitionseries).diff --git a/packages/media/src/audio/audio-for-preview.tsx b/packages/media/src/audio/audio-for-preview.tsxindex 998829596f..7566b6d4da 100644--- a/packages/media/src/audio/audio-for-preview.tsx+++ b/packages/media/src/audio/audio-for-preview.tsx@@ -28,6 +28,7 @@ const {} = Internals;type NewAudioForPreviewProps = {+ readonly style: React.CSSProperties | null;readonly src: string;readonly playbackRate: number;readonly logLevel: LogLevel;@@ -71,6 +72,7 @@ const AudioForPreviewAssertedShowing: React.FC<NewAudioForPreviewProps> = ({credentials,requestInit,setMediaDurationInSeconds,+ style,}) => {const videoConfig = useUnsafeVideoConfig();const frame = useCurrentFrame();@@ -375,6 +377,7 @@ const AudioForPreviewAssertedShowing: React.FC<NewAudioForPreviewProps> = ({name={name}loop={loop}showInTimeline={showInTimeline}+ style={style ?? undefined}stack={stack ?? undefined}toneFrequency={toneFrequency}audioStreamIndex={audioStreamIndex}@@ -389,6 +392,7 @@ const AudioForPreviewAssertedShowing: React.FC<NewAudioForPreviewProps> = ({};type InnerAudioProps = {+ readonly style: React.CSSProperties | null;readonly loop?: boolean;readonly src: string;readonly logLevel?: LogLevel;@@ -439,6 +443,7 @@ export const AudioForPreview: React.FC<InnerAudioProps> = ({credentials,requestInit,setMediaDurationInSeconds,+ style,}) => {const preloadedSrc = usePreload(src);@@ -501,6 +506,7 @@ export const AudioForPreview: React.FC<InnerAudioProps> = ({requestInit={requestInit}fallbackHtml5AudioProps={fallbackHtml5AudioProps}setMediaDurationInSeconds={setMediaDurationInSeconds}+ style={style}/>);};diff --git a/packages/media/src/audio/audio.tsx b/packages/media/src/audio/audio.tsxindex f412348783..d104c7aa16 100644--- a/packages/media/src/audio/audio.tsx+++ b/packages/media/src/audio/audio.tsx@@ -1,5 +1,6 @@import React, {useMemo, useState} from 'react';import {+ Freeze,Internals,Interactive,Sequence,@@ -23,6 +24,7 @@ const audioSchema = {keyframable: false,},...Internals.baseSchema,+ ...Internals.premountSchema,volume: {type: 'number',min: 0,@@ -60,6 +62,9 @@ const AudioInner: React.FC<durationInFrames,freeze,hidden,+ style,+ premountFor,+ postmountFor,...otherProps} = props;const environment = useRemotionEnvironment();@@ -120,6 +125,24 @@ const AudioInner: React.FC<}),[basicInfo],);+ const {+ effectivePostmountFor,+ effectivePremountFor,+ freezeFrame,+ isPremountingOrPostmounting,+ postmountingActive,+ premountingActive,+ premountingStyle,+ } = Internals.usePremounting({+ from: from ?? 0,+ durationInFrames: basicInfo.duration,+ premountFor: premountFor ?? null,+ postmountFor: postmountFor ?? null,+ style: style ?? null,+ styleWhilePremounted: null,+ styleWhilePostmounted: null,+ hideWhilePremounted: 'display-none',+ });if (typeof props.src !== 'string') {throw new TypeError(@@ -139,35 +162,45 @@ const AudioInner: React.FC<}return (- <Sequence- layout="none"- from={from ?? 0}- durationInFrames={basicInfo.duration}- freeze={freeze}- _remotionInternalStack={stack}- _remotionInternalIsMedia={isMedia}- name={name ?? '<Audio>'}- _remotionInternalDocumentationLink={- name === undefined- ? 'https://www.remotion.dev/docs/media/audio'- : undefined- }- controls={controls}- _remotionInternalLoopDisplay={loopDisplay}- showInTimeline={showInTimeline ?? true}- hidden={hidden}- >- {environment.isRendering ? (- <AudioForRendering {...otherProps} />- ) : (- <AudioForPreview- name={name}- {...otherProps}- stack={stack ?? null}- setMediaDurationInSeconds={setMediaDurationInSeconds}- />- )}- </Sequence>+ <Freeze frame={freezeFrame} active={isPremountingOrPostmounting}>+ <Sequence+ layout="none"+ from={from ?? 0}+ durationInFrames={basicInfo.duration}+ freeze={freeze}+ _remotionInternalStack={stack}+ _remotionInternalIsMedia={isMedia}+ _remotionInternalPremountDisplay={effectivePremountFor || null}+ _remotionInternalPostmountDisplay={effectivePostmountFor || null}+ _remotionInternalIsPremounting={premountingActive}+ _remotionInternalIsPostmounting={postmountingActive}+ name={name ?? '<Audio>'}+ _remotionInternalDocumentationLink={+ name === undefined+ ? 'https://www.remotion.dev/docs/media/audio'+ : undefined+ }+ controls={controls}+ _remotionInternalLoopDisplay={loopDisplay}+ showInTimeline={showInTimeline ?? true}+ hidden={hidden}+ >+ {environment.isRendering ? (+ <AudioForRendering+ {...otherProps}+ style={premountingStyle ?? undefined}+ />+ ) : (+ <AudioForPreview+ name={name}+ {...otherProps}+ style={premountingStyle}+ stack={stack ?? null}+ setMediaDurationInSeconds={setMediaDurationInSeconds}+ />+ )}+ </Sequence>+ </Freeze>);};diff --git a/packages/media/src/audio/props.ts b/packages/media/src/audio/props.tsindex dc36af3f3e..f4a0654b5d 100644--- a/packages/media/src/audio/props.ts+++ b/packages/media/src/audio/props.ts@@ -1,5 +1,6 @@import type {InteractiveBaseProps,+ InteractivePremountProps,LogLevel,LoopVolumeCurveBehavior,VolumeProp,@@ -45,4 +46,5 @@ export type AudioProps = {*/credentials?: RequestCredentials;requestInit?: MediaRequestInit;-} & InteractiveBaseProps;+} & InteractiveBaseProps &+ Pick<InteractivePremountProps, 'premountFor' | 'postmountFor'>;diff --git a/packages/media/src/test/premounting.test.tsx b/packages/media/src/test/premounting.test.tsxnew file mode 100644index 0000000000..84af4ec215--- /dev/null+++ b/packages/media/src/test/premounting.test.tsx@@ -0,0 +1,157 @@+import {Player} from '@remotion/player';+import React from 'react';+import {createRoot} from 'react-dom/client';+import {expect, test, vi} from 'vitest';+import {Audio} from '../audio/audio';+import {Video} from '../video/video';++vi.mock('../audio/audio-for-preview', () => ({+ AudioForPreview: ({style}: {readonly style: React.CSSProperties | null}) => (+ <div data-testid="premounted-audio" style={style ?? undefined} />+ ),+}));++const waitFor = async (predicate: () => boolean) => {+ const started = Date.now();+ while (Date.now() - started < 10000) {+ if (predicate()) {+ return;+ }++ await new Promise((resolve) => setTimeout(resolve, 10));+ }++ throw new Error('Timed out waiting for condition');+};++test('premounts a Video and hides its canvas', async () => {+ const container = document.createElement('div');+ document.body.appendChild(container);++ const Composition: React.FC = () => {+ return (+ <Video+ data-testid="premounted-video"+ durationInFrames={20}+ from={10}+ premountFor={10}+ src="/bigbuckbunny.mp4"+ style={{opacity: 0.5}}+ />+ );+ };++ const root = createRoot(container);+ root.render(+ <Player+ acknowledgeRemotionLicense+ component={Composition}+ compositionHeight={720}+ compositionWidth={1280}+ durationInFrames={100}+ fps={30}+ initiallyMuted+ inputProps={{}}+ />,+ );++ try {+ await waitFor(+ () =>+ container.querySelector('[data-testid="premounted-video"]') !== null,+ );+ const canvas = container.querySelector('[data-testid="premounted-video"]');+ expect(canvas).toBeInstanceOf(HTMLCanvasElement);+ expect(canvas?.getAttribute('style')).toContain('display: none');+ expect(canvas?.getAttribute('style')).toContain('pointer-events: none');+ await waitFor(+ () =>+ canvas instanceof HTMLCanvasElement &&+ canvas.width > 0 &&+ canvas.height > 0,+ );+ } finally {+ root.unmount();+ container.remove();+ }+});++test('styleWhilePremounted overrides the default Video premount style', async () => {+ const container = document.createElement('div');+ document.body.appendChild(container);++ const Composition: React.FC = () => {+ return (+ <Video+ data-testid="premounted-video"+ from={10}+ premountFor={10}+ src="/bigbuckbunny.mp4"+ styleWhilePremounted={{display: 'block', opacity: 0.25}}+ />+ );+ };++ const root = createRoot(container);+ root.render(+ <Player+ acknowledgeRemotionLicense+ component={Composition}+ compositionHeight={720}+ compositionWidth={1280}+ durationInFrames={100}+ fps={30}+ initiallyMuted+ inputProps={{}}+ />,+ );++ try {+ await waitFor(+ () =>+ container.querySelector('[data-testid="premounted-video"]') !== null,+ );+ const canvas = container.querySelector('[data-testid="premounted-video"]');+ expect(canvas?.getAttribute('style')).toContain('opacity: 0.25');+ expect(canvas?.getAttribute('style')).toContain('display: block');+ } finally {+ root.unmount();+ container.remove();+ }+});++test('premounts Audio and hides its fallback element', async () => {+ const container = document.createElement('div');+ document.body.appendChild(container);++ const Composition: React.FC = () => (+ <Audio durationInFrames={20} from={10} premountFor={10} src="/audio.mp3" />+ );++ const root = createRoot(container);+ root.render(+ <Player+ acknowledgeRemotionLicense+ component={Composition}+ compositionHeight={720}+ compositionWidth={1280}+ durationInFrames={100}+ fps={30}+ initiallyMuted+ inputProps={{}}+ />,+ );++ try {+ await waitFor(+ () =>+ container.querySelector('[data-testid="premounted-audio"]') !== null,+ );+ const audio = container.querySelector('[data-testid="premounted-audio"]');+ expect(audio?.getAttribute('style')).toContain('display: none');+ expect(audio?.getAttribute('style')).toContain('pointer-events: none');+ } finally {+ root.unmount();+ container.remove();+ }+});diff --git a/packages/media/src/video/props.ts b/packages/media/src/video/props.tsindex 245c21b927..8e716eda13 100644--- a/packages/media/src/video/props.ts+++ b/packages/media/src/video/props.ts@@ -3,6 +3,7 @@ import type {EffectDefinitionAndStack,EffectsProp,InteractiveBaseProps,+ InteractivePremountProps,LogLevel,LoopVolumeCurveBehavior,OnVideoFrame,@@ -100,4 +101,5 @@ export type VideoProps = MandatoryVideoProps &Partial<OuterVideoProps> &Partial<OptionalVideoProps> &NativeVideoProps &- InteractiveBaseProps;+ InteractiveBaseProps &+ InteractivePremountProps;diff --git a/packages/media/src/video/video.tsx b/packages/media/src/video/video.tsxindex 17147fe26d..d16638d16c 100644--- a/packages/media/src/video/video.tsx+++ b/packages/media/src/video/video.tsx@@ -1,5 +1,6 @@import React, {useMemo, useState} from 'react';import {+ Freeze,Internals,Interactive,Sequence,@@ -25,6 +26,8 @@ const videoSchema = {keyframable: false,},...Internals.baseSchema,+ ...Internals.premountSchema,+ ...Internals.premountStyleSchema,volume: {type: 'number',min: 0,@@ -227,6 +230,10 @@ const VideoInner: React.FC<from,freeze,hidden,+ premountFor,+ postmountFor,+ styleWhilePremounted,+ styleWhilePostmounted,...props}) => {const fallbackLogLevel = Internals.useLogLevel();@@ -302,73 +309,97 @@ const VideoInner: React.FC<effects ?? [],);const refForOutline = React.useRef<HTMLElement | null>(null);+ const {+ effectivePostmountFor,+ effectivePremountFor,+ freezeFrame,+ isPremountingOrPostmounting,+ postmountingActive,+ premountingActive,+ premountingStyle,+ } = Internals.usePremounting({+ from: from ?? 0,+ durationInFrames: videoSequenceDuration ?? Infinity,+ premountFor: premountFor ?? null,+ postmountFor: postmountFor ?? null,+ style: style ?? null,+ styleWhilePremounted: styleWhilePremounted ?? null,+ styleWhilePostmounted: styleWhilePostmounted ?? null,+ hideWhilePremounted: 'display-none',+ });if (sequenceDurationInFrames === 0) {return null;}return (- <Sequence- layout="none"- from={from ?? 0}- durationInFrames={videoSequenceDuration}- freeze={freeze}- _remotionInternalStack={stack}- _remotionInternalIsMedia={isMedia}- name={name ?? '<Video>'}- _remotionInternalDocumentationLink={- name === undefined- ? 'https://www.remotion.dev/docs/media/video'- : undefined- }- controls={controls}- _remotionInternalLoopDisplay={loopDisplay}- _remotionInternalEffects={memoizedEffectDefinitions}- outlineRef={refForOutline}- showInTimeline={showInTimeline ?? true}- hidden={hidden}- >- <InnerVideo- {...props}- audioStreamIndex={audioStreamIndex ?? 0}- className={className}- delayRenderRetries={delayRenderRetries ?? null}- delayRenderTimeoutInMilliseconds={- delayRenderTimeoutInMilliseconds ?? null- }- disallowFallbackToOffthreadVideo={- disallowFallbackToOffthreadVideo ?? false+ <Freeze frame={freezeFrame} active={isPremountingOrPostmounting}>+ <Sequence+ layout="none"+ from={from ?? 0}+ durationInFrames={videoSequenceDuration}+ freeze={freeze}+ _remotionInternalStack={stack}+ _remotionInternalIsMedia={isMedia}+ _remotionInternalPremountDisplay={effectivePremountFor || null}+ _remotionInternalPostmountDisplay={effectivePostmountFor || null}+ _remotionInternalIsPremounting={premountingActive}+ _remotionInternalIsPostmounting={postmountingActive}+ name={name ?? '<Video>'}+ _remotionInternalDocumentationLink={+ name === undefined+ ? 'https://www.remotion.dev/docs/media/video'+ : undefined}- fallbackOffthreadVideoProps={fallbackOffthreadVideoProps ?? {}}- logLevel={logLevel ?? fallbackLogLevel}- loop={loop ?? false}- loopVolumeCurveBehavior={loopVolumeCurveBehavior ?? 'repeat'}- muted={muted ?? false}- onVideoFrame={onVideoFrame}- playbackRate={playbackRate ?? 1}- showInTimeline={showInTimeline ?? true}- src={src}- style={style ?? {}}- trimAfter={trimAfter}- trimBefore={trimBefore}- volume={volume ?? 1}- toneFrequency={toneFrequency ?? 1}- stack={stack}- debugOverlay={debugOverlay ?? false}- headless={headless ?? false}- onError={onError}- credentials={credentials}- requestInit={requestInit}controls={controls}- objectFit={objectFit ?? 'contain'}- _experimentalInitiallyDrawCachedFrame={- _experimentalInitiallyDrawCachedFrame ?? false- }- effects={memoizedEffects}- setMediaDurationInSeconds={setMediaDurationInSeconds}- refForOutline={refForOutline}- />- </Sequence>+ _remotionInternalLoopDisplay={loopDisplay}+ _remotionInternalEffects={memoizedEffectDefinitions}+ outlineRef={refForOutline}+ showInTimeline={showInTimeline ?? true}+ hidden={hidden}+ >+ <InnerVideo+ {...props}+ audioStreamIndex={audioStreamIndex ?? 0}+ className={className}+ delayRenderRetries={delayRenderRetries ?? null}+ delayRenderTimeoutInMilliseconds={+ delayRenderTimeoutInMilliseconds ?? null+ }+ disallowFallbackToOffthreadVideo={+ disallowFallbackToOffthreadVideo ?? false+ }+ fallbackOffthreadVideoProps={fallbackOffthreadVideoProps ?? {}}+ logLevel={logLevel ?? fallbackLogLevel}+ loop={loop ?? false}+ loopVolumeCurveBehavior={loopVolumeCurveBehavior ?? 'repeat'}+ muted={muted ?? false}+ onVideoFrame={onVideoFrame}+ playbackRate={playbackRate ?? 1}+ showInTimeline={showInTimeline ?? true}+ src={src}+ style={premountingStyle ?? {}}+ trimAfter={trimAfter}+ trimBefore={trimBefore}+ volume={volume ?? 1}+ toneFrequency={toneFrequency ?? 1}+ stack={stack}+ debugOverlay={debugOverlay ?? false}+ headless={headless ?? false}+ onError={onError}+ credentials={credentials}+ requestInit={requestInit}+ controls={controls}+ objectFit={objectFit ?? 'contain'}+ _experimentalInitiallyDrawCachedFrame={+ _experimentalInitiallyDrawCachedFrame ?? false+ }+ effects={memoizedEffects}+ setMediaDurationInSeconds={setMediaDurationInSeconds}+ refForOutline={refForOutline}+ />+ </Sequence>+ </Freeze>);};diff --git a/packages/studio/src/components/InspectorPanel/use-composition-actions.ts b/packages/studio/src/components/InspectorPanel/use-composition-actions.tsindex fde0224aa6..75b129da71 100644--- a/packages/studio/src/components/InspectorPanel/use-composition-actions.ts+++ b/packages/studio/src/components/InspectorPanel/use-composition-actions.ts@@ -115,6 +115,7 @@ export const useCompositionActions = () => {compositionId: currentCompositionId,destinationDimensions: null,dropPosition: null,+ svgImportMode: 'image',});} finally {setIsAddingAsset(false);