Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion src/components/remotion/code-composition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ function CodeSequences({
lang={seq.lang}
filename={seq.filename}
filenames={filenames}
codeForFrame={(frame) => seq.frames[Math.floor(frame * speed)]}
codeForFrame={(frame) => {
const effectiveSpeed = seq.isTransition ? 1 : speed
const index = Math.min(
Math.floor(frame * effectiveSpeed),
seq.frames.length - 1,
)
return seq.frames[index]
}}
watermark={watermark}
scale={scale}
font={font}
Expand Down
18 changes: 17 additions & 1 deletion src/components/remotion/composition-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,23 @@ export function getCompositionData({
filename: steps[steps.length - 1]?.filename,
})

return { sequences, metadata }
const { speed } = metadata
const scaledSequences =
speed === 1
? sequences
: sequences.map((seq) =>
seq.isTransition
? seq
: {
...seq,
durationInFrames: Math.max(
1,
Math.ceil(seq.durationInFrames / speed),
),
},
)

return { sequences: scaledSequences, metadata }
}

export type CompositionData = ReturnType<typeof getCompositionData>
Expand Down
Loading