@remotion/studio: Fix bugs in loop display#6496
Merged
JonnyBurger merged 15 commits intomainfrom Feb 10, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes timeline loop/media visualization inaccuracies in @remotion/studio by adding “natural” (unclipped) layout sizing and correcting how media trims / playbackRate influence thumbnail extraction and timeline metadata.
Changes:
- Add
naturalWidthto timeline sequence layout so clipped sequences can still map media-time correctly. - Update timeline video thumbnail extraction to use trim/playbackRate when computing source time ranges.
- Include
trimBeforein timeline sequence registration for@remotion/mediaand add TS project reference wiring.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/studio/src/test/timeline-sequence-layout.test.ts | Updates expectations to include naturalWidth. |
| packages/studio/src/helpers/use-max-media-duration.ts | Adjusts max media duration based on playbackRate. |
| packages/studio/src/helpers/get-timeline-sequence-layout.ts | Computes and returns naturalWidth in addition to clipped width. |
| packages/studio/src/components/Timeline/TimelineVideoInfo.tsx | Uses trimBefore + playbackRate and naturalWidth for thumbnail slotting/extraction. |
| packages/studio/src/components/Timeline/TimelineSequence.tsx | Wires naturalWidth + new props into TimelineVideoInfo. |
| packages/media/tsconfig.json | Adds TS project reference to ../core. |
| packages/media/src/use-media-in-timeline.ts | Includes trimBefore in startMediaFrom for timeline registration. |
Comments suppressed due to low confidence (1)
packages/studio/src/components/Timeline/TimelineVideoInfo.tsx:104
naturalWidthis used to compute the timestamp slots and extraction targets, but the canvas is still created withcanvas.width = visualizationWidth. IfnaturalWidthis much larger than the visible width (e.g. sequences clipped by the composition end), this will request/decode frames for off-canvas positions that will never be drawn, which can become expensive. Consider generating slots only for the visible width while still mapping timestamps using the natural scale (or otherwise cap slot generation tovisualizationWidth).
const ensureSlots = ({
filledSlots,
naturalWidth: visualizationWidth,
fromSeconds,
toSeconds,
aspectRatio,
}: {
filledSlots: Map<number, number | undefined>;
naturalWidth: number;
fromSeconds: number;
toSeconds: number;
aspectRatio: number;
}) => {
const segmentDuration = toSeconds - fromSeconds;
const timestampTargets = calculateTimestampSlots({
visualizationWidth,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6091