Skip to content

🎥 Make videos programmatically with React

Docs: Explain trimming consistently for media

JonnyBurger3b95e41e3af4
diff --git a/packages/docs/docs/timing.mdx b/packages/docs/docs/timing.mdx
index bbf5e79120..930c6dc5df 100644
--- a/packages/docs/docs/timing.mdx
+++ b/packages/docs/docs/timing.mdx
@@ -7,18 +7,15 @@ crumb: 'Getting started'
import {TimingTimeline} from '../components/TimingTimeline';
-## Components
-
The [`from`](/docs/sequence#from), [`trimBefore`](/docs/sequence#trimbefore) and [`durationInFrames`](/docs/sequence#durationinframes) props apply to these timeline components:
- [`Interactive` elements](/docs/interactive), such as `<Interactive.Div>`, and [`<AbsoluteFill>`](/docs/absolute-fill).
- [`<Img>`](/docs/img), [`<CanvasImage>`](/docs/canvasimage), [`<AnimatedImage>`](/docs/animatedimage), [`<Solid>`](/docs/solid) and [`<HtmlInCanvas>`](/docs/remotion/html-in-canvas).
- [`<Gif>`](/docs/gif/gif), [`<Lottie>`](/docs/lottie), [`<ThreeCanvas>`](/docs/three-canvas) and [`<RemotionRiveCanvas>`](/docs/rive/remotionrivecanvas).
-- [`@remotion/shapes` components](/docs/shapes), [`<LightLeak>`](/docs/light-leaks/light-leak), [`<Starburst>`](/docs/starburst/starburst), [Rough Notation components](/docs/rough-notation/api), [`<MacOSCursor>`](/docs/mac-cursors/mac-os-cursor) and [MapTiler components](/docs/maps).
+- [`@remotion/shapes`](/docs/shapes), [`@remotion/rough-notation`](/docs/rough-notation/api), [`<MacOSCursor>`](/docs/mac-cursors/mac-os-cursor).
+- [`<Audio>`](/docs/media/audio) and [`<Video>`](/docs/media/video) from `@remotion/media`.
- Custom components built with [`Interactive.withSchema()`](/docs/interactive-with-schema) that expose these props.
-[`<Audio>`](/docs/media/audio) and [`<Video>`](/docs/media/video) also accept these props, but their `trimBefore` selects a frame in the source file, as explained below.
-
## Position with `from`
`from` moves an item on its parent timeline. By default, its children start at frame `0` when it appears:
@@ -41,7 +38,7 @@ The element occupies composition frames `30` through `89`. Its counter runs from
## Trim the beginning and end
-`trimBefore` skips frames at the start of an item's content. For `<Interactive.Div>`, it advances the frame seen by its children when they first appear. It is available from <AvailableFrom v="4.0.482" inline />. Shorten `durationInFrames` to stop rendering the children earlier:
+`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} />
@@ -57,7 +54,7 @@ export const MyComposition = () => (
);
```
-The element now occupies composition frames `30` through `74`. Its counter runs from `15` through `59`. To trim the end of `<Interactive.Div>`, set `durationInFrames`; it has no `trimAfter` prop.
+The element now occupies composition frames `30` through `74`. Its counter 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.
## Change playback speed
@@ -69,11 +66,11 @@ From <AvailableFrom v="4.0.528" inline />, `playbackRate` on `<Interactive.Div>`
For example, adding `playbackRate={2}` to the preceding `<Interactive.Div>` makes the counter read `15` at composition frame `30` and `35` at frame `40`. The element still lasts 45 frames on the parent timeline. Nested `<Interactive.Div>` elements apply their timing from the outer element to the inner one; their playback rates multiply.
-## Trimming a media source
+## Trim a media source with `trimAfter`
-[`<Audio>`](/docs/media/audio) and [`<Video>`](/docs/media/video) from `@remotion/media` use their own `trimBefore` and `trimAfter` props to select a range of the source file. `trimAfter` is the frame at which the source range ends, not a number of frames to remove. This differs from `<Interactive.Div trimBefore>`, which advances the timeline seen by all its children.
+`<Audio>` and `<Video>` also accept `trimAfter` to select where playback stops in the source. Together with `trimBefore`, it selects a source range. `trimAfter` is the frame at which that range ends, not a number of frames to remove.
-At 30 FPS, this video plays source frames `45` through `104` (1.5 to 3.5 seconds). At double speed, it takes 30 composition frames and appears from frame `30` through `59`:
+At 30 composition FPS, `trimBefore={45}` and `trimAfter={105}` select the source from 1.5 to 3.5 seconds. At double speed, it lasts 30 composition frames and appears from frame `30` through `59`:
```tsx twoslash title="MyComposition.tsx"
import {staticFile} from 'remotion';