🎥 Make videos programmatically with React
and docs and example to testbet
Jonny Burger7a8e98f423b8
diff --git a/packages/docs/docs/audio.md b/packages/docs/docs/audio.mdindex 7dcbebef22..47b1ee834e 100644--- a/packages/docs/docs/audio.md+++ b/packages/docs/docs/audio.md@@ -43,6 +43,32 @@ You can use the `playbackRate` prop to control the speed of the audio. `1` is thWhile Remotion doesn't limit the range of possible playback speeds, in development mode the [`HTMLMediaElement.playbackRate`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playbackRate) API is used which throws errors on extreme values. At the time of writing, Google Chrome throws an exception if the playback rate is below `0.0625` or above `16`.+## Using `<source>` tags++_Available from v2.4.4_++You can use the browser-native [`<source>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source) tags to provide different media to support a broader range of browsers. While rendering always happens in Chrome, this feature is useful if you are showing a preview in [`<Player />`](/docs/player).++```tsx twoslash+import {Audio, interpolate} from 'remotion';+// ---cut---++const Comp: React.FC = () => {+ return (+ <Audio>+ <source+ src="https://example.com/kid-laugh.mp3"+ type="audio/mpeg"+ />+ <source+ src="https://example.com/cow-moo.ogg"+ type="audio/ogg"+ />+ </Audio>+ );+}+```+## See also- [Using audio](/docs/audio)diff --git a/packages/docs/docs/video.md b/packages/docs/docs/video.mdindex 8d0d164f69..3a7834c1fe 100644--- a/packages/docs/docs/video.md+++ b/packages/docs/docs/video.md@@ -55,6 +55,33 @@ You can use the `playbackRate` prop to control the speed of the video. `1` is thWhile Remotion doesn't limit the range of possible playback speeds, in development mode the [`HTMLMediaElement.playbackRate`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/playbackRate) API is used which throws errors on extreme values. At the time of writing, Google Chrome throws an exception if the playback rate is below `0.0625` or above `16`.+## Using `<source>` tags++_Available from v2.4.4_++You can use the browser-native [`<source>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source) tags to provide different media to support a broader range of browsers. While rendering always happens in Chrome, this feature is useful if you are showing a preview in [`<Player />`](/docs/player).++```tsx twoslash+import {Video, interpolate} from 'remotion';+const source1 = "https://example.com/kid-laugh.mp3"+// ---cut---++const Comp: React.FC = () => {+ return (+ <Video>+ <source+ src="https://example.com/me-at-the-zoo.mp4"+ type="video/mp4"+ />+ <source+ src="https://example.com/big-buck-bunny.webm"+ type="video/webm"+ />+ </Video>+ );+}+```+## See also- [`<Audio />`](/docs/audio)diff --git a/packages/example/src/Source/index.tsx b/packages/example/src/Source/index.tsxnew file mode 100644index 0000000000..fa45439bc4--- /dev/null+++ b/packages/example/src/Source/index.tsx@@ -0,0 +1,17 @@+import {Sequence, useVideoConfig, Video} from 'remotion';+import videoMp4 from '../VideoTesting/framer.mp4';+import videoWebm from '../VideoTesting/framer.webm';++export const SourceTesting: React.FC = () => {+ const {durationInFrames} = useVideoConfig();+ return (+ <div>+ <Sequence from={0} durationInFrames={durationInFrames}>+ <Video>+ <source src={videoMp4} type="video/mp4" />+ <source src={videoWebm} type="video/webm" />+ </Video>+ </Sequence>+ </div>+ );+};diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsxindex 92e64abe4c..6f17a377ab 100644--- a/packages/example/src/Video.tsx+++ b/packages/example/src/Video.tsx@@ -6,6 +6,7 @@ import {Framer} from './Framer';import {MissingImg} from './MissingImg';import RemoteVideo from './RemoteVideo';import {SkipZeroFrame} from './SkipZeroFrame';+import {SourceTesting} from './Source';import {SeriesTesting} from './StaggerTesting';import {TenFrameTester} from './TenFrameTester';import ThreeBasic from './ThreeBasic';@@ -273,6 +274,14 @@ export const Index: React.FC = () => {fps={30}durationInFrames={100}/>+ <Composition+ id="source-testing"+ component={SourceTesting}+ width={1080}+ height={1080}+ fps={30}+ durationInFrames={100}+ /></>);};