Skip to content

🎥 Make videos programmatically with React

`remotion`: Add `showInTimeline` prop to `<Audio>`, `<Video>` and `<OffthreadVideo>`

Jonny Burgerf88674b2cd26
diff --git a/packages/core/src/audio/Audio.tsx b/packages/core/src/audio/Audio.tsx
index cab31d4479..94c80b7d9d 100644
--- a/packages/core/src/audio/Audio.tsx
+++ b/packages/core/src/audio/Audio.tsx
@@ -28,8 +28,15 @@ const AudioRefForwardingFunction: React.ForwardRefRenderFunction<
}
> = (props, ref) => {
const audioContext = useContext(SharedAudioContext);
- const {startFrom, endAt, name, stack, pauseWhenBuffering, ...otherProps} =
- props;
+ const {
+ startFrom,
+ endAt,
+ name,
+ stack,
+ pauseWhenBuffering,
+ showInTimeline,
+ ...otherProps
+ } = props;
const {loop, ...propsOtherThanLoop} = props;
const {fps} = useVideoConfig();
const environment = getRemotionEnvironment();
@@ -150,6 +157,7 @@ const AudioRefForwardingFunction: React.ForwardRefRenderFunction<
// Proposal: Make this default to true in v5
pauseWhenBuffering={pauseWhenBuffering ?? false}
_remotionInternalNeedsDurationCalculation={Boolean(loop)}
+ showInTimeline={showInTimeline ?? true}
/>
);
};
diff --git a/packages/core/src/audio/AudioForPreview.tsx b/packages/core/src/audio/AudioForPreview.tsx
index 2dac8ffed6..ec316cac76 100644
--- a/packages/core/src/audio/AudioForPreview.tsx
+++ b/packages/core/src/audio/AudioForPreview.tsx
@@ -33,6 +33,7 @@ type AudioForPreviewProps = RemotionAudioProps & {
pauseWhenBuffering: boolean;
_remotionInternalNativeLoopPassed: boolean;
_remotionInternalStack: string | null;
+ showInTimeline: boolean;
};
const AudioForDevelopmentForwardRefFunction: React.ForwardRefRenderFunction<
@@ -67,6 +68,7 @@ const AudioForDevelopmentForwardRefFunction: React.ForwardRefRenderFunction<
allowAmplificationDuringRender,
name,
pauseWhenBuffering,
+ showInTimeline,
...nativeProps
} = props;
const {hidden} = useContext(SequenceVisibilityToggleContext);
@@ -138,7 +140,8 @@ const AudioForDevelopmentForwardRefFunction: React.ForwardRefRenderFunction<
playbackRate: playbackRate ?? 1,
displayName: name ?? null,
id: timelineId,
- stack: props._remotionInternalStack,
+ stack: _remotionInternalStack,
+ showInTimeline,
});
useMediaPlayback({
diff --git a/packages/core/src/audio/props.ts b/packages/core/src/audio/props.ts
index 52458d78c9..35a286ed05 100644
--- a/packages/core/src/audio/props.ts
+++ b/packages/core/src/audio/props.ts
@@ -21,4 +21,5 @@ export type RemotionAudioProps = Omit<
_remotionInternalNativeLoopPassed?: boolean;
toneFrequency?: number;
pauseWhenBuffering?: boolean;
+ showInTimeline?: boolean;
};
diff --git a/packages/core/src/test/use-media-in-timeline.test.tsx b/packages/core/src/test/use-media-in-timeline.test.tsx
index b2f171e0c9..fc7483a7e7 100644
--- a/packages/core/src/test/use-media-in-timeline.test.tsx
+++ b/packages/core/src/test/use-media-in-timeline.test.tsx
@@ -74,6 +74,7 @@ test('useMediaInTimeline registers and unregisters new sequence', () => {
displayName: null,
id: 'test',
stack: null,
+ showInTimeline: true,
}),
{
wrapper,
diff --git a/packages/core/src/use-media-in-timeline.ts b/packages/core/src/use-media-in-timeline.ts
index 77807ba018..67052be247 100644
--- a/packages/core/src/use-media-in-timeline.ts
+++ b/packages/core/src/use-media-in-timeline.ts
@@ -34,6 +34,7 @@ export const useMediaInTimeline = ({
displayName,
id,
stack,
+ showInTimeline,
}: {
volume: VolumeProp | undefined;
mediaVolume: number;
@@ -44,6 +45,7 @@ export const useMediaInTimeline = ({
displayName: string | null;
id: string;
stack: string | null;
+ showInTimeline: boolean;
}) => {
const videoConfig = useVideoConfig();
const {rootId, audioAndVideoTags} = useContext(TimelineContext);
@@ -102,6 +104,10 @@ export const useMediaInTimeline = ({
return;
}
+ if (!showInTimeline) {
+ return;
+ }
+
registerSequence({
type: mediaType,
src,
@@ -142,6 +148,7 @@ export const useMediaInTimeline = ({
playbackRate,
displayName,
stack,
+ showInTimeline,
]);
useEffect(() => {
diff --git a/packages/core/src/video/OffthreadVideo.tsx b/packages/core/src/video/OffthreadVideo.tsx
index cb0ba5e847..668eda16e2 100644
--- a/packages/core/src/video/OffthreadVideo.tsx
+++ b/packages/core/src/video/OffthreadVideo.tsx
@@ -14,8 +14,15 @@ import {VideoForPreview} from './VideoForPreview.js';
export const OffthreadVideo: React.FC<OffthreadVideoProps> = (props) => {
// Should only destruct `startFrom` and `endAt` from props,
// rest gets drilled down
- const {startFrom, endAt, name, pauseWhenBuffering, stack, ...otherProps} =
- props;
+ const {
+ startFrom,
+ endAt,
+ name,
+ pauseWhenBuffering,
+ stack,
+ showInTimeline,
+ ...otherProps
+ } = props;
const environment = getRemotionEnvironment();
const onDuration = useCallback(() => undefined, []);
@@ -70,6 +77,7 @@ export const OffthreadVideo: React.FC<OffthreadVideoProps> = (props) => {
onDuration={onDuration}
onlyWarnForMediaSeekingError
pauseWhenBuffering={pauseWhenBuffering ?? false}
+ showInTimeline={showInTimeline ?? true}
{...withoutTransparent}
/>
);
diff --git a/packages/core/src/video/Video.tsx b/packages/core/src/video/Video.tsx
index 77eab87133..a7421fc65d 100644
--- a/packages/core/src/video/Video.tsx
+++ b/packages/core/src/video/Video.tsx
@@ -32,6 +32,7 @@ const VideoForwardingFunction: React.ForwardRefRenderFunction<
pauseWhenBuffering,
stack,
_remotionInternalNativeLoopPassed,
+ showInTimeline,
...otherProps
} = props;
const {loop, ...propsOtherThanLoop} = props;
@@ -130,6 +131,7 @@ const VideoForwardingFunction: React.ForwardRefRenderFunction<
_remotionInternalNativeLoopPassed={
_remotionInternalNativeLoopPassed ?? false
}
+ showInTimeline={showInTimeline ?? true}
/>
);
};
diff --git a/packages/core/src/video/VideoForPreview.tsx b/packages/core/src/video/VideoForPreview.tsx
index 7da6e06304..6a4915481b 100644
--- a/packages/core/src/video/VideoForPreview.tsx
+++ b/packages/core/src/video/VideoForPreview.tsx
@@ -33,6 +33,7 @@ type VideoForPreviewProps = RemotionVideoProps & {
pauseWhenBuffering: boolean;
_remotionInternalNativeLoopPassed: boolean;
_remotionInternalStack: string | null;
+ showInTimeline: boolean;
};
const VideoForDevelopmentRefForwardingFunction: React.ForwardRefRenderFunction<
@@ -65,6 +66,7 @@ const VideoForDevelopmentRefForwardingFunction: React.ForwardRefRenderFunction<
_remotionInternalStack,
style,
pauseWhenBuffering,
+ showInTimeline,
...nativeProps
} = props;
if (typeof acceptableTimeShift !== 'undefined') {
@@ -87,7 +89,8 @@ const VideoForDevelopmentRefForwardingFunction: React.ForwardRefRenderFunction<
playbackRate: props.playbackRate ?? 1,
displayName: name ?? null,
id: timelineId,
- stack: props._remotionInternalStack,
+ stack: _remotionInternalStack,
+ showInTimeline,
});
useSyncVolumeWithMediaTag({
diff --git a/packages/core/src/video/props.ts b/packages/core/src/video/props.ts
index e5384d3912..03348ef51f 100644
--- a/packages/core/src/video/props.ts
+++ b/packages/core/src/video/props.ts
@@ -24,6 +24,7 @@ export type RemotionVideoProps = Omit<
allowAmplificationDuringRender?: boolean;
toneFrequency?: number;
pauseWhenBuffering?: boolean;
+ showInTimeline?: boolean;
};
type DeprecatedOffthreadVideoProps = {
@@ -53,5 +54,6 @@ export type OffthreadVideoProps = {
* @deprecated For internal use only
*/
stack?: string;
+ showInTimeline?: boolean;
} & RemotionMainVideoProps &
DeprecatedOffthreadVideoProps;
diff --git a/packages/docs/docs/audio.md b/packages/docs/docs/audio.mdx
similarity index 97%
rename from packages/docs/docs/audio.md
rename to packages/docs/docs/audio.mdx
index ff9a60d7df..3a16ae235d 100644
--- a/packages/docs/docs/audio.md
+++ b/packages/docs/docs/audio.mdx
@@ -152,6 +152,10 @@ In the Remotion Studio, the volume will be limited to `1`, since the browser can
If set to `true` and the audio is buffering, the Player will enter into the [native buffering state](/docs/player/buffer-state). The default is `false`, but will become `true` in Remotion 5.0.
+### `showInTimeline`<AvailableFrom v="4.0.122"/>
+
+If set to `false`, no layer will be shown in the timeline of the Remotion Studio. The default is `true`.
+
## See also
- [Source code for this component](https://github.com/remotion-dev/remotion/blob/main/packages/core/src/audio/Audio.tsx)
diff --git a/packages/docs/docs/offthreadvideo.mdx b/packages/docs/docs/offthreadvideo.mdx
index 778afeccda..43c0b0d65d 100644
--- a/packages/docs/docs/offthreadvideo.mdx
+++ b/packages/docs/docs/offthreadvideo.mdx
@@ -208,6 +208,10 @@ Disabling tone mapping will speed up rendering, but may result in less vibrant c
Prior to Remotion 4.0.117, tone mapping was always disabled, and the `toneMapped` prop was not available.
+### `showInTimeline`<AvailableFrom v="4.0.122"/>
+
+If set to `false`, no layer will be shown in the timeline of the Remotion Studio. The default is `true`.
+
### ~~`imageFormat` <AvailableFrom v="3.0.22" />~~
_removed in v4.0.0_
diff --git a/packages/docs/docs/video.md b/packages/docs/docs/video.mdx
similarity index 98%
rename from packages/docs/docs/video.md
rename to packages/docs/docs/video.mdx
index d2a4478513..49f81661c9 100644
--- a/packages/docs/docs/video.md
+++ b/packages/docs/docs/video.mdx
@@ -216,6 +216,10 @@ Handle an error playing the video. From v3.3.89, if you pass an `onError` callba
If set to `true` and the video is loading, the Player will enter into the [native buffering state](/docs/player/buffer-state). The default is `false`, but will become `true` in Remotion 5.0.
+### `showInTimeline`<AvailableFrom v="4.0.122"/>
+
+If set to `false`, no layer will be shown in the timeline of the Remotion Studio. The default is `true`.
+
## Speed up renders for video with silent audio
Remotion will download the whole video during render in order to mix its audio. If the video contains a silent audio track, you can add the muted property to signal to Remotion that it does not need to download the video and make the render more efficient.