Timing and trimming
All Remotion components share the same timing props.
from: Move an item
from moves an item on the timeline.
By default, its children start at frame 0 when it appears:
MyComposition.tsximport {Interactive ,useCurrentFrame } from 'remotion'; constCounter = () => <div >{useCurrentFrame ()}</div >; export constMyComposition = () => ( <Interactive .Div from ={30}> <Counter /> </Interactive .Div > );
trimBefore: Trim the beginning
trimBefore trims the beginning of an item.
MyComposition.tsximport {Interactive ,useCurrentFrame } from 'remotion'; constCounter = () => <div >{useCurrentFrame ()}</div >; export constMyComposition = () => ( <Interactive .Div from ={30}trimBefore ={15}> <Counter /> </Interactive .Div > );
durationInFrames: Set the duration
durationInFrames selects how many frames of the child timeline are shown, starting at trimBefore.
MyComposition.tsximport {Interactive ,useCurrentFrame } from 'remotion'; constCounter = () => <div >{useCurrentFrame ()}</div >; export constMyComposition = () => ( <Interactive .Div from ={30}trimBefore ={45}durationInFrames ={30} > <Counter /> </Interactive .Div > );
playbackRate: Change speed of an item
MyComposition.tsximport {Interactive ,useCurrentFrame } from 'remotion'; constCounter = () => <div >{useCurrentFrame ()}</div >; export constMyComposition = () => ( <Interactive .Div from ={30}trimBefore ={15}durationInFrames ={60}playbackRate ={2} > <Counter /> </Interactive .Div > );
loop: Repeat an item
loop repeats the range selected by trimBefore and durationInFrames until the parent ends.
MyComposition.tsximport {Interactive ,useCurrentFrame } from 'remotion'; constCounter = () => <div >{useCurrentFrame ()}</div >; export constMyComposition = () => ( <Interactive .Div from ={30}trimBefore ={45}durationInFrames ={60}playbackRate ={2}loop > <Counter /> </Interactive .Div > );
To loop an item, durationInFrames must be set.
The following components are exempt: <Video>, <Audio>, <Lottie>, <Gif>, and <AnimatedImage>, because they have an intrinsic duration.
Order of operations
The timing props as applying to the content in this order:
frompositions the item in its parent timeline.trimBeforesets the first frame in the child timeline.durationInFramesselects the child range.playbackRatestretches or compresses the selected range.looprepeats the selected range until the parent ends.
Formula
Timing props affect what child components retrieve when they call useCurrentFrame().
The formula is as follows:
trimBefore + (frame - from) * playbackRateIf the item loops:
trimBefore + ((frame - from) * playbackRate) % durationInFrames