🎥 Make videos programmatically with React
startAt -> startFrom
Jonny Burger1f15df95445d
diff --git a/packages/core/src/audio/Audio.tsx b/packages/core/src/audio/Audio.tsxindex 5e0a86e2f1..7443937389 100644--- a/packages/core/src/audio/Audio.tsx+++ b/packages/core/src/audio/Audio.tsx@@ -9,16 +9,16 @@ import {RemotionAudioProps, RemotionMainAudioProps} from './props';export const Audio: React.FC<RemotionAudioProps & RemotionMainAudioProps> = (props) => {- const {startAt, endAt, ...otherProps} = props;- if (typeof startAt !== 'undefined' || typeof endAt !== 'undefined') {- validateStartFromProps(startAt, endAt);+ const {startFrom, endAt, ...otherProps} = props;+ if (typeof startFrom !== 'undefined' || typeof endAt !== 'undefined') {+ validateStartFromProps(startFrom, endAt);- const startAtFrameNo = startAt ?? 0;+ const startFromFrameNo = startFrom ?? 0;const endAtFrameNo = endAt ?? Infinity;return (<Sequencelayout="none"- from={0 - startAtFrameNo}+ from={0 - startFromFrameNo}showInTimeline={false}durationInFrames={endAtFrameNo}>diff --git a/packages/core/src/audio/props.ts b/packages/core/src/audio/props.tsindex 4d4b897f1b..075269d5dc 100644--- a/packages/core/src/audio/props.ts+++ b/packages/core/src/audio/props.ts@@ -1,7 +1,7 @@import {VolumeProp} from '../volume-prop';export type RemotionMainAudioProps = {- startAt?: number;+ startFrom?: number;endAt?: number;};diff --git a/packages/core/src/test/audio.test.tsx b/packages/core/src/test/audio.test.tsxindex ad441dcea0..220f8a3b2c 100644--- a/packages/core/src/test/audio.test.tsx+++ b/packages/core/src/test/audio.test.tsx@@ -3,10 +3,10 @@ import React from 'react';import {Audio} from '../audio';import {expectToThrow} from './expect-to-throw';-test('It should throw if startAt prop is negative', () => {+test('It should throw if startFrom prop is negative', () => {expectToThrow(- () => render(<Audio startAt={-40} />),- /startAt must be greater than equal to 0 instead got -40./+ () => render(<Audio startFrom={-40} />),+ /startFrom must be greater than equal to 0 instead got -40./);});@@ -17,10 +17,10 @@ test('It should throw if endAt prop is negative', () => {);});-test('It should throw if endAt is less than startAt', () => {+test('It should throw if endAt is less than startFrom', () => {expectToThrow(- () => render(<Audio startAt={10} endAt={1} />),- /endAt prop must be greater than startAt prop/+ () => render(<Audio startFrom={10} endAt={1} />),+ /endAt prop must be greater than startFrom prop/);});@@ -32,11 +32,11 @@ test('It should throw if endAt is not a number', () => {);});-test('It should throw if startAt is not a number', () => {+test('It should throw if startFrom is not a number', () => {expectToThrow(//@ts-expect-error- () => render(<Audio startAt={'hey'} />),- /type of startAt prop must be a number, instead got type string./+ () => render(<Audio startFrom={'hey'} />),+ /type of startFrom prop must be a number, instead got type string./);});@@ -47,13 +47,13 @@ test('It should throw if endAt is NaN', () => {);});-test('It should throw if startAt is NaN or Infinity', () => {+test('It should throw if startFrom is NaN or Infinity', () => {expectToThrow(- () => render(<Audio startAt={NaN} />),- /startAt prop can not be NaN or Infinity./+ () => render(<Audio startFrom={NaN} />),+ /startFrom prop can not be NaN or Infinity./);expectToThrow(- () => render(<Audio startAt={Infinity} />),- /startAt prop can not be NaN or Infinity./+ () => render(<Audio startFrom={Infinity} />),+ /startFrom prop can not be NaN or Infinity./);});diff --git a/packages/core/src/test/nested-sequences.test.tsx b/packages/core/src/test/nested-sequences.test.tsxindex 47afd73435..1c804d918e 100644--- a/packages/core/src/test/nested-sequences.test.tsx+++ b/packages/core/src/test/nested-sequences.test.tsx@@ -74,11 +74,11 @@ test('Nested negative offset test', () => {return <div>{'frame' + frame}</div>;};- const startAt = 40;+ const startFrom = 40;const endAt = 90;const content = (- <Sequence from={0 - startAt} durationInFrames={endAt}>+ <Sequence from={0 - startFrom} durationInFrames={endAt}><NestedChild /></Sequence>);@@ -112,12 +112,12 @@ test('Negative offset edge case', () => {return <div>{'frame' + frame}</div>;};- const startAt = 40;+ const startFrom = 40;const endAt = 90;const content = (<Sequence from={40} durationInFrames={Infinity}>- <Sequence from={0 - startAt} durationInFrames={endAt}>+ <Sequence from={0 - startFrom} durationInFrames={endAt}><NestedChild /></Sequence></Sequence>diff --git a/packages/core/src/test/video.test.tsx b/packages/core/src/test/video.test.tsxindex d28c9891f2..662d774ee8 100644--- a/packages/core/src/test/video.test.tsx+++ b/packages/core/src/test/video.test.tsx@@ -3,10 +3,10 @@ import React from 'react';import {Video} from '../video';import {expectToThrow} from './expect-to-throw';-test('It should throw if startAt prop is negative', () => {+test('It should throw if startFrom prop is negative', () => {expectToThrow(- () => render(<Video startAt={-40} />),- /startAt must be greater than equal to 0 instead got -40./+ () => render(<Video startFrom={-40} />),+ /startFrom must be greater than equal to 0 instead got -40./);});@@ -17,10 +17,10 @@ test('It should throw if endAt prop is negative', () => {);});-test('It should throw if endAt is less than startAt', () => {+test('It should throw if endAt is less than startFrom', () => {expectToThrow(- () => render(<Video startAt={10} endAt={1} />),- /endAt prop must be greater than startAt prop/+ () => render(<Video startFrom={10} endAt={1} />),+ /endAt prop must be greater than startFrom prop/);});@@ -32,11 +32,11 @@ test('It should throw if endAt is not a number', () => {);});-test('It should throw if startAt is not a number', () => {+test('It should throw if startFrom is not a number', () => {expectToThrow(//@ts-expect-error- () => render(<Video startAt={'hey'} />),- /type of startAt prop must be a number, instead got type string./+ () => render(<Video startFrom={'hey'} />),+ /type of startFrom prop must be a number, instead got type string./);});@@ -47,13 +47,13 @@ test('It should throw if endAt is NaN', () => {);});-test('It should throw if startAt is NaN or Infinity', () => {+test('It should throw if startFrom is NaN or Infinity', () => {expectToThrow(- () => render(<Video startAt={NaN} />),- /startAt prop can not be NaN or Infinity./+ () => render(<Video startFrom={NaN} />),+ /startFrom prop can not be NaN or Infinity./);expectToThrow(- () => render(<Video startAt={Infinity} />),- /startAt prop can not be NaN or Infinity./+ () => render(<Video startFrom={Infinity} />),+ /startFrom prop can not be NaN or Infinity./);});diff --git a/packages/core/src/validate-start-from-props.ts b/packages/core/src/validate-start-from-props.tsindex e2156c15ad..a7eb759108 100644--- a/packages/core/src/validate-start-from-props.ts+++ b/packages/core/src/validate-start-from-props.ts@@ -1,19 +1,19 @@export const validateStartFromProps = (- startAt: number | undefined,+ startFrom: number | undefined,endAt: number | undefined) => {- if (typeof startAt !== 'undefined') {- if (typeof startAt !== 'number') {+ if (typeof startFrom !== 'undefined') {+ if (typeof startFrom !== 'number') {throw new TypeError(- `type of startAt prop must be a number, instead got type ${typeof startAt}.`+ `type of startFrom prop must be a number, instead got type ${typeof startFrom}.`);}- if (isNaN(startAt) || startAt === Infinity) {- throw new TypeError('startAt prop can not be NaN or Infinity.');+ if (isNaN(startFrom) || startFrom === Infinity) {+ throw new TypeError('startFrom prop can not be NaN or Infinity.');}- if (startAt < 0) {+ if (startFrom < 0) {throw new TypeError(- `startAt must be greater than equal to 0 instead got ${startAt}.`+ `startFrom must be greater than equal to 0 instead got ${startFrom}.`);}}@@ -32,7 +32,7 @@ export const validateStartFromProps = ();}}- if ((endAt as number) < (startAt as number)) {- throw new TypeError('endAt prop must be greater than startAt prop');+ if ((endAt as number) < (startFrom as number)) {+ throw new TypeError('endAt prop must be greater than startFrom prop');}};diff --git a/packages/core/src/video/Video.tsx b/packages/core/src/video/Video.tsxindex 8225fecd9b..6801d0fce7 100644--- a/packages/core/src/video/Video.tsx+++ b/packages/core/src/video/Video.tsx@@ -9,16 +9,16 @@ import {VideoForRendering} from './VideoForRendering';export const Video: React.FC<RemotionVideoProps & RemotionMainVideoProps> = (props) => {- const {startAt, endAt, ...otherProps} = props;- if (typeof startAt !== 'undefined' || typeof endAt !== 'undefined') {- validateStartFromProps(startAt, endAt);+ const {startFrom, endAt, ...otherProps} = props;+ if (typeof startFrom !== 'undefined' || typeof endAt !== 'undefined') {+ validateStartFromProps(startFrom, endAt);- const startAtFrameNo = startAt ?? 0;+ const startFromFrameNo = startFrom ?? 0;const endAtFrameNo = endAt ?? Infinity;return (<Sequencelayout="none"- from={0 - startAtFrameNo}+ from={0 - startFromFrameNo}showInTimeline={false}durationInFrames={endAtFrameNo}>diff --git a/packages/core/src/video/props.ts b/packages/core/src/video/props.tsindex bd60b7f40a..1d665d79af 100644--- a/packages/core/src/video/props.ts+++ b/packages/core/src/video/props.ts@@ -1,7 +1,7 @@import {VolumeProp} from '../volume-prop';export type RemotionMainVideoProps = {- startAt?: number;+ startFrom?: number;endAt?: number;};diff --git a/packages/docs/docs/audio.md b/packages/docs/docs/audio.mdindex 96490f57dd..3d32c4493b 100644--- a/packages/docs/docs/audio.md+++ b/packages/docs/docs/audio.md@@ -14,7 +14,7 @@ Using this component, you can add audio to your video. All audio formats which aUse an import or require to load an audio file and pass it to the `src` props of the `<Audio />` component.-`<Audio>` has two more helper props: `startAt` and `endAt` for defining the start frame and end frame. Both are optional and do not get forwarded to the native `<audio>` element but tell Remotion which portion of the audio should be included.+`<Audio>` has two more helper props: `startFrom` and `endAt` for defining the start frame and end frame. Both are optional and do not get forwarded to the native `<audio>` element but tell Remotion which portion of the audio should be included.```tsximport {Audio} from 'remotion';@@ -26,7 +26,7 @@ export const MyVideo = () => {<div>Hello World!</div><Audiosrc={audio}- startAt={59} // if composition is 30fps, then it will start at 2s+ startFrom={59} // if composition is 30fps, then it will start at 2sendAt={120} // if composition is 30fps, then it will end at 4s/></div>diff --git a/packages/docs/docs/video.md b/packages/docs/docs/video.mdindex ca3000f6d4..987d204ba5 100644--- a/packages/docs/docs/video.md+++ b/packages/docs/docs/video.md@@ -13,7 +13,7 @@ Videos with audio are not supported - yet! Audio will be muted in the final rendUse an import or require to load an video file and pass it as the `src` prop. All the props that the native `<video>` element accepts (except `autoplay` and `controls`) will be forwarded (but of course not all are useful for Remotion). This means you can use all CSS to style the video.-`<Video>` has two more helper props: `startAt` and `endAt` to define when the video should start and end. Both are optional and do not get forwarded to the native `<video>` element but tell Remotion which portion of the video to use.+`<Video>` has two more helper props: `startFrom` and `endAt` to define when the video should start and end. Both are optional and do not get forwarded to the native `<video>` element but tell Remotion which portion of the video to use.```tsximport {Video} from 'remotion';@@ -25,7 +25,7 @@ export const MyVideo = () => {<div>Hello World!</div><Videosrc={video}- startAt={59} // if video is 30fps, then it will start at 2s+ startFrom={59} // if video is 30fps, then it will start at 2sendAt={120} // if video is 30fps, then it will end at 4sstyle={{height: 1080 / 2, width: 1920 / 2}}/>diff --git a/packages/example/src/AudioTesting/index.tsx b/packages/example/src/AudioTesting/index.tsxindex 0b976f9db0..6c03469f66 100644--- a/packages/example/src/AudioTesting/index.tsx+++ b/packages/example/src/AudioTesting/index.tsx@@ -6,7 +6,7 @@ const AudioTesting: React.FC = () => {<div><Sequence from={100} durationInFrames={100}><Audio- startAt={100}+ startFrom={100}endAt={200}src={music}volume={(f) =>diff --git a/packages/renderer/src/test/asset-calculation.test.tsx b/packages/renderer/src/test/asset-calculation.test.tsxindex 96fb085556..f38a3f57d9 100644--- a/packages/renderer/src/test/asset-calculation.test.tsx+++ b/packages/renderer/src/test/asset-calculation.test.tsx@@ -153,12 +153,12 @@ test('Should calculate volumes correctly', async () => {});});-test('Should calculate startAt correctly', async () => {+test('Should calculate startFrom correctly', async () => {const assetPositions = await getPositions(() => {return (<Sequence from={1} durationInFrames={Infinity}><Audio- startAt={100}+ startFrom={100}endAt={200}src={'https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/1080/Big_Buck_Bunny_1080_10s_1MB.mp4'