Skip to content

🎥 Make videos programmatically with React

Update documentation for trimLeft/trimRight props

copilot-swe-agent[bot]6260c1516716
diff --git a/packages/docs/docs/audio.mdx b/packages/docs/docs/audio.mdx
index 39d91669bc..f777c6f0f1 100644
--- a/packages/docs/docs/audio.mdx
+++ b/packages/docs/docs/audio.mdx
@@ -62,9 +62,39 @@ Controls the `frame` which is returned when using the [`volume`](#volume) callba
Can be either `"repeat"` (default, start from 0 on each iteration) or `"extend"` (keep increasing frames).
-### `startFrom?` / `endAt?`
+### `trimLeft?` / `trimRight?`<AvailableFrom v="4.0.319"/>
-`<Audio>` has two more helper props you can use:
+`<Audio>` has two helper props you can use to trim audio:
+
+- `trimLeft` will remove a portion of the audio at the beginning (left side)
+- `trimRight` will remove a portion of the audio at the end (right side)
+
+In the following example, we assume that the [`fps`](/docs/composition#fps) of the composition is `30`.
+
+By passing `trimLeft={60}`, the playback starts immediately, but with the first 2 seconds of the audio trimmed away.
+By passing `trimRight={120}`, any audio after the 4 second mark in the file will be trimmed away.
+
+The audio will play the range from `00:02:00` to `00:04:00`, meaning the audio will play for 2 seconds.
+
+```tsx twoslash
+import {AbsoluteFill, Audio, staticFile} from 'remotion';
+
+export const MyVideo = () => {
+ return (
+ <AbsoluteFill>
+ <Audio src={staticFile('audio.mp3')} trimLeft={60} trimRight={120} />
+ </AbsoluteFill>
+ );
+};
+```
+
+### `startFrom?` / `endAt?` <DeprecatedBlock>
+
+:::note Deprecated
+These props are deprecated in favor of [`trimLeft`](#trimleft--trimright) and [`trimRight`](#trimleft--trimright). They will continue to work but you cannot use them together with the new props.
+:::
+
+`<Audio>` has two helper props you can use:
- `startFrom` will remove a portion of the audio at the beginning
- `endAt` will remove a portion of the audio at the end
@@ -88,6 +118,8 @@ export const MyVideo = () => {
};
```
+</DeprecatedBlock>
+
### `playbackRate?`<AvailableFrom v="2.2.0"/>
You can use the `playbackRate` prop to control the speed of the audio. `1` is the default and means regular speed, `0.5` slows down the audio so it's twice as long and `2` speeds up the audio so it's twice as fast.
diff --git a/packages/docs/docs/audio/trimming.mdx b/packages/docs/docs/audio/trimming.mdx
index 0e4ec1ce04..73fd0d06d5 100644
--- a/packages/docs/docs/audio/trimming.mdx
+++ b/packages/docs/docs/audio/trimming.mdx
@@ -9,7 +9,7 @@ crumb: 'Audio'
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
-The [`<Audio />`](/docs/audio) tag supports the [`startFrom`](/docs/audio#startfrom--endat) and [`endAt`](/docs/audio#startfrom--endat) props.
+The [`<Audio />`](/docs/audio) tag supports the [`trimLeft`](/docs/audio#trimleft--trimright) and [`trimRight`](/docs/audio#trimleft--trimright) props.
With it, you can trim off parts of the audio.
```tsx twoslash {8} title="MyComp.tsx"
@@ -20,7 +20,7 @@ export const MyComposition = () => {
return (
<AbsoluteFill>
- <Audio src={staticFile('audio.mp3')} startFrom={2 * fps} endAt={4 * fps} />
+ <Audio src={staticFile('audio.mp3')} trimLeft={2 * fps} trimRight={4 * fps} />
</AbsoluteFill>
);
};
@@ -29,3 +29,7 @@ export const MyComposition = () => {
This will result the audio to play the range from `00:02:00` to `00:04:00`, meaning the audio will play for 2 seconds.
The audio will still play immediately at the beginning - to see how to shift the audio to appear later in the composition, see the [next article](/docs/audio/delaying).
+
+:::note Legacy props
+You can also use the deprecated [`startFrom`](/docs/audio#startfrom--endat) and [`endAt`](/docs/audio#startfrom--endat) props, but the new `trimLeft` and `trimRight` props are preferred.
+:::
diff --git a/packages/docs/docs/offthreadvideo.mdx b/packages/docs/docs/offthreadvideo.mdx
index cde28586a4..d3b1718bdc 100644
--- a/packages/docs/docs/offthreadvideo.mdx
+++ b/packages/docs/docs/offthreadvideo.mdx
@@ -45,7 +45,41 @@ export const MyComposition = () => {
The URL of the video to be rendered. Can be a remote URL or a local file referenced with [`staticFile()`](/docs/staticfile).
-### `startFrom?`
+### `trimLeft?`<AvailableFrom v="4.0.319"/>
+
+Will remove a portion of the video at the beginning (left side).
+
+In the following example, we assume that the [`fps`](/docs/composition#fps) of the composition is `30`.
+
+By passing `trimLeft={60}`, the playback starts immediately, but with the first 2 seconds of the video trimmed away.
+By passing `trimRight={120}`, any video after the 4 second mark in the file will be trimmed away.
+
+The video will play the range from `00:02:00` to `00:04:00`, meaning the video will play for 2 seconds.
+
+For exact behavior, see: [Order of operations](/docs/audio/order-of-operations).
+
+```tsx twoslash
+import {AbsoluteFill, OffthreadVideo, staticFile} from 'remotion';
+
+// ---cut---
+export const MyComposition = () => {
+ return (
+ <AbsoluteFill>
+ <OffthreadVideo src={staticFile('video.webm')} trimLeft={60} trimRight={120} />
+ </AbsoluteFill>
+ );
+};
+```
+
+### `trimRight?`<AvailableFrom v="4.0.319"/>
+
+Removes a portion of the video at the end (right side). See [`trimLeft`](/docs/offthreadvideo#trimleft) for an explanation.
+
+### `startFrom?` <DeprecatedBlock>
+
+:::note Deprecated
+This prop is deprecated in favor of [`trimLeft`](#trimleft). It will continue to work but you cannot use it together with the new prop.
+:::
Will remove a portion of the video at the beginning.
@@ -71,9 +105,17 @@ export const MyComposition = () => {
};
```
-### `endAt?`
+</DeprecatedBlock>
+
+### `endAt?` <DeprecatedBlock>
+
+:::note Deprecated
+This prop is deprecated in favor of [`trimRight`](#trimright). It will continue to work but you cannot use it together with the new prop.
+:::
+
+Removes a portion of the video at the end. See [`startFrom`](/docs/offthreadvideo#startfrom) for an explanation.
-Removes a portion of the video at the end. See [`startAt`](/docs/video#startfrom) for an explanation.
+</DeprecatedBlock>
### `transparent?`<AvailableFrom v="4.0.0" />
diff --git a/packages/docs/docs/video.mdx b/packages/docs/docs/video.mdx
index aa2ea57726..0936c5efcc 100644
--- a/packages/docs/docs/video.mdx
+++ b/packages/docs/docs/video.mdx
@@ -49,7 +49,41 @@ export const MyComposition = () => {
The URL of the video to be rendered. Can be a remote URL or a local file referenced with [`staticFile()`](/docs/staticfile).
-### `startFrom?`
+### `trimLeft?`<AvailableFrom v="4.0.319"/>
+
+Will remove a portion of the video at the beginning (left side).
+
+In the following example, we assume that the [`fps`](/docs/composition#fps) of the composition is `30`.
+
+By passing `trimLeft={60}`, the playback starts immediately, but with the first 2 seconds of the video trimmed away.
+By passing `trimRight={120}`, any video after the 4 second mark in the file will be trimmed away.
+
+The video will play the range from `00:02:00` to `00:04:00`, meaning the video will play for 2 seconds.
+
+For exact behavior, see: [Order of operations](/docs/audio/order-of-operations).
+
+```tsx twoslash
+import {AbsoluteFill, staticFile, Video} from 'remotion';
+
+// ---cut---
+export const MyComposition = () => {
+ return (
+ <AbsoluteFill>
+ <Video src={staticFile('video.webm')} trimLeft={60} trimRight={120} />
+ </AbsoluteFill>
+ );
+};
+```
+
+### `trimRight?`<AvailableFrom v="4.0.319"/>
+
+Removes a portion of the video at the end (right side). See [`trimLeft`](/docs/video#trimleft) for an explanation.
+
+### `startFrom?` <DeprecatedBlock>
+
+:::note Deprecated
+This prop is deprecated in favor of [`trimLeft`](#trimleft). It will continue to work but you cannot use it together with the new prop.
+:::
Will remove a portion of the video at the beginning.
@@ -75,10 +109,18 @@ export const MyComposition = () => {
};
```
-### `endAt?`
+</DeprecatedBlock>
+
+### `endAt?` <DeprecatedBlock>
+
+:::note Deprecated
+This prop is deprecated in favor of [`trimRight`](#trimright). It will continue to work but you cannot use it together with the new prop.
+:::
Removes a portion of the video at the end. See [`startFrom`](/docs/video#startfrom) for an explanation.
+</DeprecatedBlock>
+
### `style?`
You can pass any style you can pass to a native `<video>` element. For example, set its size: