Skip to content

🎥 Make videos programmatically with React

Docs: Show local frame in timing timeline

JonnyBurger4535b1f00061
diff --git a/packages/docs/components/TimingTimeline.tsx b/packages/docs/components/TimingTimeline.tsx
index 45fd51c592..1eef0aadd0 100644
--- a/packages/docs/components/TimingTimeline.tsx
+++ b/packages/docs/components/TimingTimeline.tsx
@@ -3,11 +3,16 @@ import React, {useRef, useState} from 'react';
export const TimingTimeline: React.FC<{
readonly from: number;
readonly durationInFrames: number;
-}> = ({from, durationInFrames}) => {
+ readonly trimBefore: number;
+}> = ({from, durationInFrames, trimBefore}) => {
const [frame, setFrame] = useState(from);
const scrubbingPointer = useRef<number | null>(null);
const totalFrames = 90;
const fps = 30;
+ const localFrame =
+ frame >= from && frame < from + durationInFrames
+ ? frame - from + trimBefore
+ : null;
const seconds = Math.floor(frame / fps);
const timecode = `00:${String(seconds).padStart(2, '0')}.${String(frame % fps).padStart(2, '0')}`;
@@ -170,8 +175,27 @@ export const TimingTimeline: React.FC<{
border: '1px solid rgba(255, 255, 255, 0.2)',
borderRadius: 2,
backgroundColor: '#0b84f3',
+ display: 'flex',
+ alignItems: 'center',
+ paddingLeft: 5,
}}
- />
+ >
+ {localFrame === null ? null : (
+ <span
+ style={{
+ fontSize: 11,
+ fontFamily: 'Arial, Helvetica, sans-serif',
+ color: '#fff',
+ opacity: 0.5,
+ whiteSpace: 'nowrap',
+ pointerEvents: 'none',
+ userSelect: 'none',
+ }}
+ >
+ {localFrame}
+ </span>
+ )}
+ </div>
</div>
</div>
<div
diff --git a/packages/docs/docs/timing.mdx b/packages/docs/docs/timing.mdx
index ab6dec2140..1610e12982 100644
--- a/packages/docs/docs/timing.mdx
+++ b/packages/docs/docs/timing.mdx
@@ -22,7 +22,7 @@ The listed components also accept `playbackRate`, except [`<Img>`](/docs/img) an
`from` moves an item on its parent timeline. By default, its children start at frame `0` when it appears:
-<TimingTimeline from={30} durationInFrames={30} />
+<TimingTimeline from={30} durationInFrames={30} trimBefore={0} />
```tsx twoslash title="MyComposition.tsx"
import {Interactive, useCurrentFrame} from 'remotion';
@@ -36,13 +36,13 @@ export const MyComposition = () => (
);
```
-Drag the playhead across the element. The Studio counter shows composition frames `30` through `59`, while `<Counter>` inside the element runs from `0` through `29`.
+Drag the playhead across the element. The counter on the left shows composition frames `30` through `59`. The label inside the element shows its local frame, `0` through `29`, matching `<Counter>`.
## Trim the beginning and end
`trimBefore` skips the beginning of an item's content without moving the item from its `from` position. Set `durationInFrames` to control how long it remains on the parent timeline. For `<Interactive.Div>`, `trimBefore` advances the frame seen by its children when they first appear. It is available on `<Interactive.Div>` from <AvailableFrom v="4.0.482" inline />:
-<TimingTimeline from={30} durationInFrames={45} />
+<TimingTimeline from={30} durationInFrames={45} trimBefore={15} />
```tsx twoslash title="MyComposition.tsx"
import {Interactive, useCurrentFrame} from 'remotion';
@@ -60,7 +60,7 @@ export const MyComposition = () => (
);
```
-The element now occupies composition frames `30` through `74`. The Studio counter shows those frames, while `<Counter>` inside the element runs from `15` through `59`. On `<Audio>` and `<Video>`, the same `trimBefore={15}` starts playback 15 frames into the source while leaving the item at frame `30`. To trim the end of `<Interactive.Div>`, set `durationInFrames`; it has no `trimAfter` prop.
+The element now occupies composition frames `30` through `74`. The counter on the left shows those frames, while the label inside the element and `<Counter>` run from `15` through `59`. On `<Audio>` and `<Video>`, the same `trimBefore={15}` starts playback 15 frames into the source while leaving the item at frame `30`. To trim the end of `<Interactive.Div>`, set `durationInFrames`; it has no `trimAfter` prop.
## Change playback speed