Skip to content

🎥 Make videos programmatically with React

Derive timeline edge rounding from container boundaries

Jonny Burger55863d3de9f1
diff --git a/packages/core/src/CompositionManager.tsx b/packages/core/src/CompositionManager.tsx
index 4ef813b763..beb5e2e0bb 100644
--- a/packages/core/src/CompositionManager.tsx
+++ b/packages/core/src/CompositionManager.tsx
@@ -121,9 +121,6 @@ export type SequenceControls = SequenceRegistrationControls & {
};
export type TSequence = {
- // Optional for compatibility with consumers constructing this exported type.
- // null means the layer has no explicit endpoint of its own.
- explicitDurationInFrames?: number | null;
from: number;
trimBefore: number | null;
duration: number;
diff --git a/packages/core/src/Sequence.tsx b/packages/core/src/Sequence.tsx
index fcf866ab14..c600c8a786 100644
--- a/packages/core/src/Sequence.tsx
+++ b/packages/core/src/Sequence.tsx
@@ -64,10 +64,6 @@ export type LayoutAndStyle =
};
export type SequencePropsWithoutDuration = {
- /**
- * @deprecated For internal use only.
- */
- readonly _remotionInternalExplicitDurationInFrames?: number | null;
readonly children?: React.ReactNode;
readonly width?: number;
readonly height?: number;
@@ -162,7 +158,6 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<
_remotionInternalPremountDisplay: premountDisplay,
_remotionInternalPostmountDisplay: postmountDisplay,
_remotionInternalIsMedia: isMedia,
- _remotionInternalExplicitDurationInFrames = durationInFrames,
outlineRef: passedRefForOutline,
cropLeft,
cropRight,
@@ -460,12 +455,6 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<
controlsSupportsEffects,
]);
- const explicitDurationInFrames = Number.isFinite(
- _remotionInternalExplicitDurationInFrames,
- )
- ? _remotionInternalExplicitDurationInFrames
- : null;
-
const getSequenceForRegistration = useCallback((): TSequence => {
if (isMedia) {
if (isMedia.type === 'image') {
@@ -477,7 +466,6 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<
displayName: timelineClipName,
documentationLink: resolvedDocumentationLink,
duration: actualDurationInFrames,
- explicitDurationInFrames,
from,
trimBefore: registeredTrimBefore,
id,
@@ -505,7 +493,6 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<
documentationLink: resolvedDocumentationLink,
doesVolumeChange: isMedia.data.doesVolumeChange,
duration: actualDurationInFrames,
- explicitDurationInFrames,
from,
trimBefore: registeredTrimBefore,
id,
@@ -534,7 +521,6 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<
from,
trimBefore: registeredTrimBefore,
duration: actualDurationInFrames,
- explicitDurationInFrames,
id,
displayName: timelineClipName,
documentationLink: resolvedDocumentationLink,
@@ -559,7 +545,6 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<
timelineClipName,
parentSequence?.id,
actualDurationInFrames,
- explicitDurationInFrames,
from,
registeredTrimBefore,
showInTimeline,
diff --git a/packages/example/e2e/timeline-right-edge.test.mts b/packages/example/e2e/timeline-right-edge.test.mts
index 1c44690e4d..f67e62e09e 100644
--- a/packages/example/e2e/timeline-right-edge.test.mts
+++ b/packages/example/e2e/timeline-right-edge.test.mts
@@ -22,6 +22,7 @@ const Layers = () => <>
<AbsoluteFill name="Fill clipped before own cutoff" durationInFrames={240} />
<Sequence name="Fill parent" durationInFrames={30}>
<AbsoluteFill name="Inherited fill" />
+ <AbsoluteFill name="Explicit parent match" durationInFrames={30} />
<AbsoluteFill name="Child clipped before own cutoff" durationInFrames={60} />
</Sequence>
<Solid name="Solid cutoff" color="gray" width={100} height={100} from={27} durationInFrames={9} trimBefore={27} />
@@ -59,10 +60,11 @@ export const E2eTestRoot = () => <Composition id="timeline-edges" component={Lay
for (const [name, radius] of [
['Fill available time', '2px'],
['Explicit fill cutoff', '0px'],
- ['Explicit composition match', '0px'],
+ ['Explicit composition match', '2px'],
['Fill clipped before own cutoff', '2px'],
['Fill parent', '0px'],
['Inherited fill', '2px'],
+ ['Explicit parent match', '2px'],
['Child clipped before own cutoff', '2px'],
['Natural end', '2px'],
['Solid cutoff', '0px'],
diff --git a/packages/media/src/audio/audio.tsx b/packages/media/src/audio/audio.tsx
index f5aa8bd575..9f112992ce 100644
--- a/packages/media/src/audio/audio.tsx
+++ b/packages/media/src/audio/audio.tsx
@@ -185,17 +185,6 @@ const AudioInner: React.FC<
layout="none"
from={from ?? 0}
durationInFrames={basicInfo.duration}
- _remotionInternalExplicitDurationInFrames={Math.min(
- durationInFrames ?? Infinity,
- props.trimAfter === undefined || props.loop
- ? Infinity
- : Internals.calculateMediaDuration({
- mediaDurationInFrames: Infinity,
- trimBefore: props.trimBefore,
- trimAfter: props.trimAfter,
- playbackRate: props.playbackRate ?? 1,
- }),
- )}
freeze={freeze}
_remotionInternalIsMedia={isMedia}
_remotionInternalPremountDisplay={effectivePremountFor || null}
diff --git a/packages/studio/src/components/Timeline/TimelineSequence.tsx b/packages/studio/src/components/Timeline/TimelineSequence.tsx
index dbb8c0dc05..3ffb9f93a2 100644
--- a/packages/studio/src/components/Timeline/TimelineSequence.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequence.tsx
@@ -1,3 +1,7 @@
+import {
+ getTimelineVisibleDuration,
+ getTimelineVisibleStart,
+} from '@remotion/canvas';
import React, {useCallback, useContext, useMemo, useRef} from 'react';
import type {_InternalTypes, TSequence} from 'remotion';
import {Internals, useCurrentFrame} from 'remotion';
@@ -420,6 +424,7 @@ const TimelineSequenceInner: React.FC<{
// if that is the case, it needs to be asynchronously determined
const video = Internals.useVideo();
+ const {sequences} = useContext(Internals.SequenceManager);
const renderWindow = useContext(TimelineViewportContext);
const dragAwareDoubleClick = useMemo(
() => createDragAwareDoubleClickTracker(),
@@ -859,17 +864,20 @@ const TimelineSequenceInner: React.FC<{
),
) === Math.ceil(naturalMediaDuration);
- const endsAtExplicitDuration =
- s.explicitDurationInFrames !== null &&
- s.explicitDurationInFrames !== undefined &&
- Number.isFinite(s.explicitDurationInFrames) &&
- Math.ceil(s.explicitDurationInFrames - sequenceFrameOffset) <=
- Math.ceil(
- Math.min(displayDurationInFrames, video.durationInFrames - s.from),
- );
+ const parentSequence = sequences.find(
+ (candidate) => candidate.id === s.parent,
+ );
+ const parentEnd = parentSequence
+ ? getTimelineVisibleStart(parentSequence, sequences) +
+ getTimelineVisibleDuration(parentSequence, sequences)
+ : video.durationInFrames;
+ const endsAtContainerBoundary =
+ Math.ceil(s.from + displayDurationInFrames) >=
+ Math.ceil(Math.min(parentEnd, video.durationInFrames));
+
const showRightBorderRadius =
visibleLayout?.rightEdgeVisible === true &&
- (!endsAtExplicitDuration || endsAtNaturalMediaDuration);
+ (endsAtContainerBoundary || endsAtNaturalMediaDuration);
const style: React.CSSProperties = useMemo(() => {
return {