Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion remotion-composer/src/CinematicRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,17 @@ const SceneVideo: React.FC<{ scene: CinematicVideoScene }> = ({ scene }) => {
scene.trimBeforeSeconds !== undefined
? Math.round(scene.trimBeforeSeconds * fps)
: undefined;
// Remotion's <OffthreadVideo> enforces trimAfter via an internal Sequence
// bounded by source frames without scaling for playbackRate. For clips with
// custom playbackRate (especially speed < 1), this causes playback to stop
// early and leaves the remainder of the scene black.
// The enclosing <Sequence> already bounds the scene to durationSeconds, so
// omitting trimAfter when playbackRate is not 1 ensures the clip fills
// the entire scene without premature cutoff.
const trimAfter =
scene.trimAfterSeconds !== undefined
scene.trimAfterSeconds !== undefined &&
(scene.playbackRate === undefined ||
Math.abs(scene.playbackRate - 1) < 1e-6)
? Math.round(scene.trimAfterSeconds * fps)
: undefined;

Expand Down
9 changes: 9 additions & 0 deletions tests/contracts/test_remotion_video_transition_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ def test_cinematic_fades_are_bounded_by_each_scene_duration() -> None:
assert "durationInFrames - fadeOutFrames" in source


def test_cinematic_custom_playback_rate_omits_trim_after() -> None:
source = (REPO_ROOT / "remotion-composer/src/CinematicRenderer.tsx").read_text(
encoding="utf-8"
)

assert "scene.playbackRate === undefined ||" in source
assert "Math.abs(scene.playbackRate - 1)" in source


def _jsx_block(source: str, component: str) -> str:
"""Return the JSX element text for <Component ... /> in the source."""
start = source.index(f"<{component}")
Expand Down