🎥 Make videos programmatically with React
trimBefore and trimAfter
Jonny Burger2085823457dc
diff --git a/packages/core/src/audio/Audio.tsx b/packages/core/src/audio/Audio.tsxindex 2c2ae2056e..405ae112d2 100644--- a/packages/core/src/audio/Audio.tsx+++ b/packages/core/src/audio/Audio.tsx@@ -34,8 +34,8 @@ const AudioRefForwardingFunction: React.ForwardRefRenderFunction<const {startFrom,endAt,- trimLeft,- trimRight,+ trimBefore,+ trimAfter,name,stack,pauseWhenBuffering,@@ -87,13 +87,13 @@ const AudioRefForwardingFunction: React.ForwardRefRenderFunction<durations[getAbsoluteSrc(preloadedSrc)] ??durations[getAbsoluteSrc(props.src)];- validateMediaTrimProps({startFrom, endAt, trimLeft, trimRight});+ validateMediaTrimProps({startFrom, endAt, trimBefore, trimAfter});- const {trimLeftValue, trimRightValue} = resolveTrimProps({+ const {trimBeforeValue, trimAfterValue} = resolveTrimProps({startFrom,endAt,- trimLeft,- trimRight,+ trimBefore,+ trimAfter,});if (loop && durationFetched !== undefined) {@@ -113,10 +113,10 @@ const AudioRefForwardingFunction: React.ForwardRefRenderFunction<<Looplayout="none"durationInFrames={calculateLoopDuration({- endAt: trimRightValue ?? endAt,+ endAt: trimAfterValue ?? endAt,mediaDuration: duration,playbackRate: props.playbackRate ?? 1,- startFrom: trimLeftValue ?? startFrom,+ startFrom: trimBeforeValue ?? startFrom,})}><Audio@@ -129,15 +129,15 @@ const AudioRefForwardingFunction: React.ForwardRefRenderFunction<}if (- typeof trimLeftValue !== 'undefined' ||- typeof trimRightValue !== 'undefined'+ typeof trimBeforeValue !== 'undefined' ||+ typeof trimAfterValue !== 'undefined') {return (<Sequencelayout="none"- from={0 - (trimLeftValue ?? 0)}+ from={0 - (trimBeforeValue ?? 0)}showInTimeline={false}- durationInFrames={trimRightValue}+ durationInFrames={trimAfterValue}name={name}><Audiodiff --git a/packages/core/src/audio/props.ts b/packages/core/src/audio/props.tsindex 1185c4b737..02b658d0f0 100644--- a/packages/core/src/audio/props.ts+++ b/packages/core/src/audio/props.ts@@ -3,21 +3,21 @@ import type {LoopVolumeCurveBehavior} from './use-audio-frame.js';export type RemotionMainAudioProps = {/**- * @deprecated `startFrom` was renamed to `trimLeft`+ * @deprecated `startFrom` was renamed to `trimBefore`*/startFrom?: number;/**- * @deprecated `endAt` was renamed to `trimRight`+ * @deprecated `endAt` was renamed to `trimAfter`*/endAt?: number;/*** Trim of the audio from the left (start) in frames.*/- trimLeft?: number;+ trimBefore?: number;/*** Trim of the audio from the right (end) in frames.*/- trimRight?: number;+ trimAfter?: number;};export type NativeAudioProps = Omit<diff --git a/packages/core/src/test/audio.test.tsx b/packages/core/src/test/audio.test.tsxindex 51205e441b..0ee9de5e8e 100644--- a/packages/core/src/test/audio.test.tsx+++ b/packages/core/src/test/audio.test.tsx@@ -22,7 +22,7 @@ describe('Render correctly with props', () => {expect(() =>render(<WrapSequenceContext>- <Audio src="test" volume={1} trimLeft={10} />+ <Audio src="test" volume={1} trimBefore={10} /></WrapSequenceContext>,),).not.toThrow();@@ -32,7 +32,7 @@ describe('Render correctly with props', () => {expect(() =>render(<WrapSequenceContext>- <Audio src="test" volume={1} trimRight={10} />+ <Audio src="test" volume={1} trimAfter={10} /></WrapSequenceContext>,),).not.toThrow();@@ -42,7 +42,7 @@ describe('Render correctly with props', () => {expect(() =>render(<WrapSequenceContext>- <Audio src="test" volume={1} trimLeft={10} trimRight={20} />+ <Audio src="test" volume={1} trimBefore={10} trimAfter={20} /></WrapSequenceContext>,),).not.toThrow();@@ -52,69 +52,69 @@ describe('Render correctly with props', () => {expect(() =>render(<WrapSequenceContext>- <Audio src="test" volume={1} trimLeft={10} trimRight={20} loop />+ <Audio src="test" volume={1} trimBefore={10} trimAfter={20} loop /></WrapSequenceContext>,),).not.toThrow();});- test('It should render Audio with trimLeft props', () => {+ test('It should render Audio with trimBefore props', () => {expect(() =>render(<WrapSequenceContext>- <Audio src="test" volume={1} trimLeft={10} />+ <Audio src="test" volume={1} trimBefore={10} /></WrapSequenceContext>,),).not.toThrow();});- test('It should render Audio with trimRight props', () => {+ test('It should render Audio with trimAfter props', () => {expect(() =>render(<WrapSequenceContext>- <Audio src="test" volume={1} trimRight={10} />+ <Audio src="test" volume={1} trimAfter={10} /></WrapSequenceContext>,),).not.toThrow();});- test('It should render Audio with trimLeft and trimRight props', () => {+ test('It should render Audio with trimBefore and trimAfter props', () => {expect(() =>render(<WrapSequenceContext>- <Audio src="test" volume={1} trimLeft={10} trimRight={20} />+ <Audio src="test" volume={1} trimBefore={10} trimAfter={20} /></WrapSequenceContext>,),).not.toThrow();});- test('It should render Audio with loop, trimLeft and trimRight props', () => {+ test('It should render Audio with loop, trimBefore and trimAfter props', () => {expect(() =>render(<WrapSequenceContext>- <Audio src="test" volume={1} trimLeft={10} trimRight={20} loop />+ <Audio src="test" volume={1} trimBefore={10} trimAfter={20} loop /></WrapSequenceContext>,),).not.toThrow();});- test('It should throw when both startFrom and trimLeft are provided', () => {+ test('It should throw when both startFrom and trimBefore are provided', () => {expect(() =>render(<WrapSequenceContext>- <Audio src="test" volume={1} startFrom={10} trimLeft={5} />+ <Audio src="test" volume={1} startFrom={10} trimBefore={5} /></WrapSequenceContext>,),- ).toThrow(/Cannot use both startFrom and trimLeft props/);+ ).toThrow(/Cannot use both startFrom and trimBefore props/);});- test('It should throw when both endAt and trimRight are provided', () => {+ test('It should throw when both endAt and trimAfter are provided', () => {expect(() =>render(<WrapSequenceContext>- <Audio src="test" volume={1} endAt={15} trimRight={20} />+ <Audio src="test" volume={1} endAt={15} trimAfter={20} /></WrapSequenceContext>,),- ).toThrow(/Cannot use both endAt and trimRight props/);+ ).toThrow(/Cannot use both endAt and trimAfter props/);});});diff --git a/packages/core/src/test/offthread-video.test.tsx b/packages/core/src/test/offthread-video.test.tsxindex 44d2a46453..b1fca466f0 100644--- a/packages/core/src/test/offthread-video.test.tsx+++ b/packages/core/src/test/offthread-video.test.tsx@@ -48,53 +48,53 @@ describe('OffthreadVideo render correctly with props', () => {).not.toThrow();});- test('It should render OffthreadVideo with trimLeft props', () => {+ test('It should render OffthreadVideo with trimBefore props', () => {expect(() =>render(<WrapSequenceContext>- <OffthreadVideo src="test" trimLeft={10} />+ <OffthreadVideo src="test" trimBefore={10} /></WrapSequenceContext>,),).not.toThrow();});- test('It should render OffthreadVideo with trimRight props', () => {+ test('It should render OffthreadVideo with trimAfter props', () => {expect(() =>render(<WrapSequenceContext>- <OffthreadVideo src="test" trimRight={10} />+ <OffthreadVideo src="test" trimAfter={10} /></WrapSequenceContext>,),).not.toThrow();});- test('It should render OffthreadVideo with trimLeft and trimRight props', () => {+ test('It should render OffthreadVideo with trimBefore and trimAfter props', () => {expect(() =>render(<WrapSequenceContext>- <OffthreadVideo src="test" trimLeft={10} trimRight={20} />+ <OffthreadVideo src="test" trimBefore={10} trimAfter={20} /></WrapSequenceContext>,),).not.toThrow();});- test('It should throw when both startFrom and trimLeft are provided', () => {+ test('It should throw when both startFrom and trimBefore are provided', () => {expect(() =>render(<WrapSequenceContext>- <OffthreadVideo src="test" startFrom={10} trimLeft={5} />+ <OffthreadVideo src="test" startFrom={10} trimBefore={5} /></WrapSequenceContext>,),- ).toThrow(/Cannot use both startFrom and trimLeft props/);+ ).toThrow(/Cannot use both startFrom and trimBefore props/);});- test('It should throw when both endAt and trimRight are provided', () => {+ test('It should throw when both endAt and trimAfter are provided', () => {expect(() =>render(<WrapSequenceContext>- <OffthreadVideo src="test" endAt={15} trimRight={20} />+ <OffthreadVideo src="test" endAt={15} trimAfter={20} /></WrapSequenceContext>,),- ).toThrow(/Cannot use both endAt and trimRight props/);+ ).toThrow(/Cannot use both endAt and trimAfter props/);});-});\ No newline at end of file+});diff --git a/packages/core/src/test/validate-start-from-props.test.ts b/packages/core/src/test/validate-start-from-props.test.tsindex e2be0cc465..01ac59acbc 100644--- a/packages/core/src/test/validate-start-from-props.test.ts+++ b/packages/core/src/test/validate-start-from-props.test.ts@@ -68,90 +68,90 @@ describe('ValidateStartFrom props should throw', () => {});describe('ValidateTrim props should throw', () => {- describe('Throw with invalid trimLeft prop', () => {- test('It should throw if trimLeft prop is negative', () => {+ describe('Throw with invalid trimBefore prop', () => {+ test('It should throw if trimBefore prop is negative', () => {expectToThrow(() => validateTrimProps(-40, 1),- /trimLeft must be greater than equal to 0 instead got -40./,+ /trimBefore must be greater than equal to 0 instead got -40./,);});- test('It should throw if trimLeft is not a number', () => {+ test('It should throw if trimBefore is not a number', () => {expectToThrow(// @ts-expect-error() => validateTrimProps('10', 20),- /type of trimLeft prop must be a number, instead got type string./,+ /type of trimBefore prop must be a number, instead got type string./,);});- test('It should throw if trimLeft is NaN', () => {+ test('It should throw if trimBefore is NaN', () => {expectToThrow(() => validateTrimProps(NaN, 20),- /trimLeft prop can not be NaN or Infinity./,+ /trimBefore prop can not be NaN or Infinity./,);});- test('It should throw if trimLeft is Infinity', () => {+ test('It should throw if trimBefore is Infinity', () => {expectToThrow(() => validateTrimProps(Infinity, 20),- /trimLeft prop can not be NaN or Infinity./,+ /trimBefore prop can not be NaN or Infinity./,);});});- describe('Throw with invalid trimRight prop', () => {- test('It should throw if trimRight prop is negative', () => {+ describe('Throw with invalid trimAfter prop', () => {+ test('It should throw if trimAfter prop is negative', () => {expectToThrow(() => validateTrimProps(0, -40),- /trimRight must be a positive number, instead got -40./,+ /trimAfter must be a positive number, instead got -40./,);});- test('It should throw if trimRight is less than trimLeft', () => {+ test('It should throw if trimAfter is less than trimBefore', () => {expectToThrow(() => validateTrimProps(10, 1),- /trimRight prop must be greater than trimLeft prop./,+ /trimAfter prop must be greater than trimBefore prop./,);});- test('It should throw if trimRight is not a number', () => {+ test('It should throw if trimAfter is not a number', () => {expectToThrow(// @ts-expect-error() => validateTrimProps(10, '20'),- /type of trimRight prop must be a number, instead got type string./,+ /type of trimAfter prop must be a number, instead got type string./,);});- test('It should throw if trimRight is NaN', () => {+ test('It should throw if trimAfter is NaN', () => {expectToThrow(() => validateTrimProps(10, NaN),- /trimRight prop can not be NaN./,+ /trimAfter prop can not be NaN./,);});});});describe('ValidateMediaTrim props should throw on conflicts', () => {- test('It should throw if both startFrom and trimLeft are provided', () => {+ test('It should throw if both startFrom and trimBefore are provided', () => {expectToThrow(() =>validateMediaTrimProps({startFrom: 10,endAt: undefined,- trimLeft: 5,- trimRight: undefined,+ trimBefore: 5,+ trimAfter: undefined,}),- /Cannot use both startFrom and trimLeft props. Use trimLeft instead as startFrom is deprecated./,+ /Cannot use both startFrom and trimBefore props. Use trimBefore instead as startFrom is deprecated./,);});- test('It should throw if both endAt and trimRight are provided', () => {+ test('It should throw if both endAt and trimAfter are provided', () => {expectToThrow(() =>validateMediaTrimProps({startFrom: undefined,endAt: 20,- trimLeft: undefined,- trimRight: 15,+ trimBefore: undefined,+ trimAfter: 15,}),- /Cannot use both endAt and trimRight props. Use trimRight instead as endAt is deprecated./,+ /Cannot use both endAt and trimAfter props. Use trimAfter instead as endAt is deprecated./,);});@@ -161,10 +161,10 @@ describe('ValidateMediaTrim props should throw on conflicts', () => {validateMediaTrimProps({startFrom: 10,endAt: 20,- trimLeft: 5,- trimRight: 15,+ trimBefore: 5,+ trimAfter: 15,}),- /Cannot use both startFrom and trimLeft props. Use trimLeft instead as startFrom is deprecated./,+ /Cannot use both startFrom and trimBefore props. Use trimBefore instead as startFrom is deprecated./,);});});diff --git a/packages/core/src/test/video.test.tsx b/packages/core/src/test/video.test.tsxindex f2829f9143..b566eaa121 100644--- a/packages/core/src/test/video.test.tsx+++ b/packages/core/src/test/video.test.tsx@@ -44,50 +44,50 @@ test('It should render Video with startFrom and endAt props', () => {).not.toThrow();});-test('It should render Video with trimLeft props', () => {+test('It should render Video with trimBefore props', () => {expect(() =>render(<WrapSequenceContext>- <Video src="test" trimLeft={10} />+ <Video src="test" trimBefore={10} /></WrapSequenceContext>,),).not.toThrow();});-test('It should render Video with trimRight props', () => {+test('It should render Video with trimAfter props', () => {expect(() =>render(<WrapSequenceContext>- <Video src="test" trimRight={10} />+ <Video src="test" trimAfter={10} /></WrapSequenceContext>,),).not.toThrow();});-test('It should render Video with trimLeft and trimRight props', () => {+test('It should render Video with trimBefore and trimAfter props', () => {expect(() =>render(<WrapSequenceContext>- <Video src="test" trimLeft={10} trimRight={15} />+ <Video src="test" trimBefore={10} trimAfter={15} /></WrapSequenceContext>,),).not.toThrow();});-test('It should throw when both startFrom and trimLeft are provided', () => {+test('It should throw when both startFrom and trimBefore are provided', () => {expect(() =>render(<WrapSequenceContext>- <Video src="test" startFrom={10} trimLeft={5} />+ <Video src="test" startFrom={10} trimBefore={5} /></WrapSequenceContext>,),- ).toThrow(/Cannot use both startFrom and trimLeft props/);+ ).toThrow(/Cannot use both startFrom and trimBefore props/);});-test('It should throw when both endAt and trimRight are provided', () => {+test('It should throw when both endAt and trimAfter are provided', () => {expect(() =>render(<WrapSequenceContext>- <Video src="test" endAt={15} trimRight={20} />+ <Video src="test" endAt={15} trimAfter={20} /></WrapSequenceContext>,),- ).toThrow(/Cannot use both endAt and trimRight props/);+ ).toThrow(/Cannot use both endAt and trimAfter props/);});diff --git a/packages/core/src/validate-start-from-props.ts b/packages/core/src/validate-start-from-props.tsindex cbf583f79a..3952ae4c7c 100644--- a/packages/core/src/validate-start-from-props.ts+++ b/packages/core/src/validate-start-from-props.ts@@ -44,82 +44,82 @@ export const validateStartFromProps = (};export const validateTrimProps = (- trimLeft: number | undefined,- trimRight: number | undefined,+ trimBefore: number | undefined,+ trimAfter: number | undefined,) => {- if (typeof trimLeft !== 'undefined') {- if (typeof trimLeft !== 'number') {+ if (typeof trimBefore !== 'undefined') {+ if (typeof trimBefore !== 'number') {throw new TypeError(- `type of trimLeft prop must be a number, instead got type ${typeof trimLeft}.`,+ `type of trimBefore prop must be a number, instead got type ${typeof trimBefore}.`,);}- if (isNaN(trimLeft) || trimLeft === Infinity) {- throw new TypeError('trimLeft prop can not be NaN or Infinity.');+ if (isNaN(trimBefore) || trimBefore === Infinity) {+ throw new TypeError('trimBefore prop can not be NaN or Infinity.');}- if (trimLeft < 0) {+ if (trimBefore < 0) {throw new TypeError(- `trimLeft must be greater than equal to 0 instead got ${trimLeft}.`,+ `trimBefore must be greater than equal to 0 instead got ${trimBefore}.`,);}}- if (typeof trimRight !== 'undefined') {- if (typeof trimRight !== 'number') {+ if (typeof trimAfter !== 'undefined') {+ if (typeof trimAfter !== 'number') {throw new TypeError(- `type of trimRight prop must be a number, instead got type ${typeof trimRight}.`,+ `type of trimAfter prop must be a number, instead got type ${typeof trimAfter}.`,);}- if (isNaN(trimRight)) {- throw new TypeError('trimRight prop can not be NaN.');+ if (isNaN(trimAfter)) {+ throw new TypeError('trimAfter prop can not be NaN.');}- if (trimRight <= 0) {+ if (trimAfter <= 0) {throw new TypeError(- `trimRight must be a positive number, instead got ${trimRight}.`,+ `trimAfter must be a positive number, instead got ${trimAfter}.`,);}}- if ((trimRight as number) < (trimLeft as number)) {- throw new TypeError('trimRight prop must be greater than trimLeft prop.');+ if ((trimAfter as number) < (trimBefore as number)) {+ throw new TypeError('trimAfter prop must be greater than trimBefore prop.');}};export const validateMediaTrimProps = ({startFrom,endAt,- trimLeft,- trimRight,+ trimBefore,+ trimAfter,}: {startFrom: number | undefined;endAt: number | undefined;- trimLeft: number | undefined;- trimRight: number | undefined;+ trimBefore: number | undefined;+ trimAfter: number | undefined;}) => {// Check for conflicting props- if (typeof startFrom !== 'undefined' && typeof trimLeft !== 'undefined') {+ if (typeof startFrom !== 'undefined' && typeof trimBefore !== 'undefined') {throw new TypeError(- 'Cannot use both startFrom and trimLeft props. Use trimLeft instead as startFrom is deprecated.',+ 'Cannot use both startFrom and trimBefore props. Use trimBefore instead as startFrom is deprecated.',);}- if (typeof endAt !== 'undefined' && typeof trimRight !== 'undefined') {+ if (typeof endAt !== 'undefined' && typeof trimAfter !== 'undefined') {throw new TypeError(- 'Cannot use both endAt and trimRight props. Use trimRight instead as endAt is deprecated.',+ 'Cannot use both endAt and trimAfter props. Use trimAfter instead as endAt is deprecated.',);}// Validate using the appropriate validation functionconst hasNewProps =- typeof trimLeft !== 'undefined' || typeof trimRight !== 'undefined';+ typeof trimBefore !== 'undefined' || typeof trimAfter !== 'undefined';const hasOldProps =typeof startFrom !== 'undefined' || typeof endAt !== 'undefined';if (hasNewProps) {- validateTrimProps(trimLeft, trimRight);+ validateTrimProps(trimBefore, trimAfter);} else if (hasOldProps) {validateStartFromProps(startFrom, endAt);}@@ -128,17 +128,17 @@ export const validateMediaTrimProps = ({export const resolveTrimProps = ({startFrom,endAt,- trimLeft,- trimRight,+ trimBefore,+ trimAfter,}: {startFrom: number | undefined;endAt: number | undefined;- trimLeft: number | undefined;- trimRight: number | undefined;-}): {trimLeftValue: number; trimRightValue: number} => {+ trimBefore: number | undefined;+ trimAfter: number | undefined;+}): {trimBeforeValue: number; trimAfterValue: number} => {// Use new props if available, otherwise fall back to old props- const trimLeftValue = trimLeft ?? startFrom ?? 0;- const trimRightValue = trimRight ?? endAt ?? Infinity;+ const trimBeforeValue = trimBefore ?? startFrom ?? 0;+ const trimAfterValue = trimAfter ?? endAt ?? Infinity;- return {trimLeftValue, trimRightValue};+ return {trimBeforeValue, trimAfterValue};};diff --git a/packages/core/src/video/OffthreadVideo.tsx b/packages/core/src/video/OffthreadVideo.tsxindex eb92e97e9d..e43ddae64c 100644--- a/packages/core/src/video/OffthreadVideo.tsx+++ b/packages/core/src/video/OffthreadVideo.tsx@@ -22,8 +22,8 @@ export const OffthreadVideo: React.FC<RemotionOffthreadVideoProps> = (const {startFrom,endAt,- trimLeft,- trimRight,+ trimBefore,+ trimAfter,name,pauseWhenBuffering,stack,@@ -48,25 +48,25 @@ export const OffthreadVideo: React.FC<RemotionOffthreadVideoProps> = ();}- validateMediaTrimProps({startFrom, endAt, trimLeft, trimRight});+ validateMediaTrimProps({startFrom, endAt, trimBefore, trimAfter});- const {trimLeftValue, trimRightValue} = resolveTrimProps({+ const {trimBeforeValue, trimAfterValue} = resolveTrimProps({startFrom,endAt,- trimLeft,- trimRight,+ trimBefore,+ trimAfter,});if (- typeof trimLeftValue !== 'undefined' ||- typeof trimRightValue !== 'undefined'+ typeof trimBeforeValue !== 'undefined' ||+ typeof trimAfterValue !== 'undefined') {return (<Sequencelayout="none"- from={0 - (trimLeftValue ?? 0)}+ from={0 - (trimBeforeValue ?? 0)}showInTimeline={false}- durationInFrames={trimRightValue}+ durationInFrames={trimAfterValue}name={name}><OffthreadVideodiff --git a/packages/core/src/video/Video.tsx b/packages/core/src/video/Video.tsxindex 20995bae02..5ada7ba24f 100644--- a/packages/core/src/video/Video.tsx+++ b/packages/core/src/video/Video.tsx@@ -31,8 +31,8 @@ const VideoForwardingFunction: React.ForwardRefRenderFunction<const {startFrom,endAt,- trimLeft,- trimRight,+ trimBefore,+ trimAfter,name,pauseWhenBuffering,stack,@@ -74,12 +74,12 @@ const VideoForwardingFunction: React.ForwardRefRenderFunction<durations[getAbsoluteSrc(preloadedSrc)] ??durations[getAbsoluteSrc(props.src)];- validateMediaTrimProps({startFrom, endAt, trimLeft, trimRight});- const {trimLeftValue, trimRightValue} = resolveTrimProps({+ validateMediaTrimProps({startFrom, endAt, trimBefore, trimAfter});+ const {trimBeforeValue, trimAfterValue} = resolveTrimProps({startFrom,endAt,- trimLeft,- trimRight,+ trimBefore,+ trimAfter,});if (loop && durationFetched !== undefined) {@@ -98,10 +98,10 @@ const VideoForwardingFunction: React.ForwardRefRenderFunction<return (<LoopdurationInFrames={calculateLoopDuration({- endAt: trimRightValue ?? undefined,+ endAt: trimAfterValue ?? undefined,mediaDuration,playbackRate: props.playbackRate ?? 1,- startFrom: trimLeftValue ?? undefined,+ startFrom: trimBeforeValue ?? undefined,})}layout="none"name={name}@@ -116,15 +116,15 @@ const VideoForwardingFunction: React.ForwardRefRenderFunction<}if (- typeof trimLeftValue !== 'undefined' ||- typeof trimRightValue !== 'undefined'+ typeof trimBeforeValue !== 'undefined' ||+ typeof trimAfterValue !== 'undefined') {return (<Sequencelayout="none"- from={0 - (trimLeftValue ?? 0)}+ from={0 - (trimBeforeValue ?? 0)}showInTimeline={false}- durationInFrames={trimRightValue}+ durationInFrames={trimAfterValue}name={name}><Videodiff --git a/packages/core/src/video/props.ts b/packages/core/src/video/props.tsindex 385dd0ffff..18dec85e46 100644--- a/packages/core/src/video/props.ts+++ b/packages/core/src/video/props.ts@@ -4,21 +4,21 @@ import type {VolumeProp} from '../volume-prop.js';export type RemotionMainVideoProps = {/**- * @deprecated `startFrom` was renamed to `trimLeft`+ * @deprecated `startFrom` was renamed to `trimBefore`*/startFrom?: number;/**- * @deprecated `endAt` was renamed to `trimRight`+ * @deprecated `endAt` was renamed to `trimAfter`*/endAt?: number;/*** Trim of th e video from the left (start) in frames.*/- trimLeft?: number;+ trimBefore?: number;/*** Trim of the video from the right (end) in frames.*/- trimRight?: number;+ trimAfter?: number;/*** @deprecated Only for internal `transparent` use*/diff --git a/packages/docs/docs/audio.mdx b/packages/docs/docs/audio.mdxindex f777c6f0f1..4a724f7249 100644--- a/packages/docs/docs/audio.mdx+++ b/packages/docs/docs/audio.mdx@@ -62,17 +62,17 @@ Controls the `frame` which is returned when using the [`volume`](#volume) callbaCan be either `"repeat"` (default, start from 0 on each iteration) or `"extend"` (keep increasing frames).-### `trimLeft?` / `trimRight?`<AvailableFrom v="4.0.319"/>+### `trimBefore?` / `trimAfter?`<AvailableFrom v="4.0.319"/>`<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)+- `trimBefore` will remove a portion of the audio at the beginning (left side)+- `trimAfter` 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.+By passing `trimBefore={60}`, the playback starts immediately, but with the first 2 seconds of the audio trimmed away.+By passing `trimAfter={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.@@ -82,7 +82,7 @@ import {AbsoluteFill, Audio, staticFile} from 'remotion';export const MyVideo = () => {return (<AbsoluteFill>- <Audio src={staticFile('audio.mp3')} trimLeft={60} trimRight={120} />+ <Audio src={staticFile('audio.mp3')} trimBefore={60} trimAfter={120} /></AbsoluteFill>);};@@ -91,7 +91,7 @@ export const MyVideo = () => {### `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.+These props are deprecated in favor of [`trimBefore`](#trimbefore--trimafter) and [`trimAfter`](#trimbefore--trimafter). They will continue to work but you cannot use them together with the new props.:::`<Audio>` has two helper props you can use:diff --git a/packages/docs/docs/audio/trimming.mdx b/packages/docs/docs/audio/trimming.mdxindex 73fd0d06d5..7e3a14f29c 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 [`trimLeft`](/docs/audio#trimleft--trimright) and [`trimRight`](/docs/audio#trimleft--trimright) props.+The [`<Audio />`](/docs/audio) tag supports the [`trimBefore`](/docs/audio#trimbefore--trimafter) and [`trimAfter`](/docs/audio#trimbefore--trimafter) 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')} trimLeft={2 * fps} trimRight={4 * fps} />+ <Audio src={staticFile('audio.mp3')} trimBefore={2 * fps} trimAfter={4 * fps} /></AbsoluteFill>);};@@ -31,5 +31,5 @@ This will result the audio to play the range from `00:02:00` to `00:04:00`, meanThe 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.+You can also use the deprecated [`startFrom`](/docs/audio#startfrom--endat) and [`endAt`](/docs/audio#startfrom--endat) props, but the new `trimBefore` and `trimAfter` props are preferred.:::diff --git a/packages/docs/docs/offthreadvideo.mdx b/packages/docs/docs/offthreadvideo.mdxindex d3b1718bdc..049647ef72 100644--- a/packages/docs/docs/offthreadvideo.mdx+++ b/packages/docs/docs/offthreadvideo.mdx@@ -45,14 +45,14 @@ 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).-### `trimLeft?`<AvailableFrom v="4.0.319"/>+### `trimBefore?`<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.+By passing `trimBefore={60}`, the playback starts immediately, but with the first 2 seconds of the video trimmed away.+By passing `trimAfter={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.@@ -65,20 +65,20 @@ import {AbsoluteFill, OffthreadVideo, staticFile} from 'remotion';export const MyComposition = () => {return (<AbsoluteFill>- <OffthreadVideo src={staticFile('video.webm')} trimLeft={60} trimRight={120} />+ <OffthreadVideo src={staticFile('video.webm')} trimBefore={60} trimAfter={120} /></AbsoluteFill>);};```-### `trimRight?`<AvailableFrom v="4.0.319"/>+### `trimAfter?`<AvailableFrom v="4.0.319"/>-Removes a portion of the video at the end (right side). See [`trimLeft`](/docs/offthreadvideo#trimleft) for an explanation.+Removes a portion of the video at the end (right side). See [`trimBefore`](/docs/offthreadvideo#trimbefore) 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.+This prop is deprecated in favor of [`trimBefore`](#trimbefore). 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.@@ -110,7 +110,7 @@ export const MyComposition = () => {### `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.+This prop is deprecated in favor of [`trimAfter`](#trimafter). 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.diff --git a/packages/docs/docs/video.mdx b/packages/docs/docs/video.mdxindex 0936c5efcc..cca43e05bd 100644--- a/packages/docs/docs/video.mdx+++ b/packages/docs/docs/video.mdx@@ -49,14 +49,14 @@ 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).-### `trimLeft?`<AvailableFrom v="4.0.319"/>+### `trimBefore?`<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.+By passing `trimBefore={60}`, the playback starts immediately, but with the first 2 seconds of the video trimmed away.+By passing `trimAfter={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.@@ -69,20 +69,20 @@ import {AbsoluteFill, staticFile, Video} from 'remotion';export const MyComposition = () => {return (<AbsoluteFill>- <Video src={staticFile('video.webm')} trimLeft={60} trimRight={120} />+ <Video src={staticFile('video.webm')} trimBefore={60} trimAfter={120} /></AbsoluteFill>);};```-### `trimRight?`<AvailableFrom v="4.0.319"/>+### `trimAfter?`<AvailableFrom v="4.0.319"/>-Removes a portion of the video at the end (right side). See [`trimLeft`](/docs/video#trimleft) for an explanation.+Removes a portion of the video at the end (right side). See [`trimBefore`](/docs/video#trimbefore) 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.+This prop is deprecated in favor of [`trimBefore`](#trimbefore). 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.@@ -114,7 +114,7 @@ export const MyComposition = () => {### `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.+This prop is deprecated in favor of [`trimAfter`](#trimAfter). 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.