Skip to content

🎥 Make videos programmatically with React

finish

Jonny Burger948300ea3788
diff --git a/packages/docs/docs/composition.md b/packages/docs/docs/composition.md
index 623f014b32..1722cc19f2 100644
--- a/packages/docs/docs/composition.md
+++ b/packages/docs/docs/composition.md
@@ -25,17 +25,13 @@ The component takes the following props:
- `component` **or** `lazyComponent`: Pass the component in directly **or** pass a function that returns a dynamic import. Passing neither or both of the props is an error.
-:::tip
-If you use `lazyComponent`, Remotion will use React Suspense to load the component. Components will be compiled by Webpack as they are needed, which will reduce startup time of Remotion.
-:::
-
-:::info
-If you use `lazyComponent`, you need to use a default export for your component. This is a restriction of React Suspense.
+:::note
+If you use `lazyComponent`, Remotion will use React Suspense to load the component. Components will be compiled by Webpack as they are needed, which will reduce startup time of Remotion. If you use `lazyComponent`, you need to use a default export for your component. This is a restriction of React Suspense.
:::
- `defaultProps` _optional_: Give your component default props that will be shown in the preview. You can override these props during render using a CLI flag.
-:::tip
+:::note
Type your components using the `React.FC<{}>` type and the `defaultProps` prop will be typesafe.
:::
@@ -86,6 +82,42 @@ export const MyVideo = () => {
};
```
+## Organize compositions using folders
+
+You can use the [`<Folder />`](/docs/folder) component to organize your compositions in the sidebar.
+
+```tsx twoslash
+import React from "react";
+const Component: React.FC = () => null;
+// ---cut---
+import { Composition, Folder } from "remotion";
+
+export const Video = () => {
+ return (
+ <>
+ <Folder name="Visuals">
+ <Composition
+ id="CompInFolder"
+ durationInFrames={100}
+ fps={30}
+ width={1080}
+ height={1080}
+ component={Component}
+ />
+ </Folder>
+ <Composition
+ id="CompOutsideFolder"
+ durationInFrames={100}
+ fps={30}
+ width={1080}
+ height={1080}
+ component={Component}
+ />
+ </>
+ );
+};
+```
+
## See also
- [registerRoot()](/docs/register-root)
@@ -93,3 +125,4 @@ export const MyVideo = () => {
- [CLI options](/docs/cli)
- [`<Sequence />`](/docs/sequence)
- [`<Still />`](/docs/still)
+- [`<Folder />`](/docs/folder)
diff --git a/packages/docs/docs/folder.md b/packages/docs/docs/folder.md
new file mode 100644
index 0000000000..76b991ff12
--- /dev/null
+++ b/packages/docs/docs/folder.md
@@ -0,0 +1,56 @@
+---
+title: <Folder />
+id: folder
+---
+
+_Available from v3.0.1_
+
+By wrapping a [`<Composition />`](/docs/composition) inside a `<Folder />`, you can visually categorize it in your sidebar, should you have many compositions.
+
+## Example
+
+```tsx twoslash
+import React from "react";
+const Component: React.FC = () => null;
+// ---cut---
+import { Composition, Folder } from "remotion";
+
+export const Video = () => {
+ return (
+ <>
+ <Folder name="Visuals">
+ <Composition
+ id="CompInFolder"
+ durationInFrames={100}
+ fps={30}
+ width={1080}
+ height={1080}
+ component={Component}
+ />
+ </Folder>
+ <Composition
+ id="CompOutsideFolder"
+ durationInFrames={100}
+ fps={30}
+ width={1080}
+ height={1080}
+ component={Component}
+ />
+ </>
+ );
+};
+```
+
+will create a tree structure in the sidebar that looks like this:
+
+<img src="/img/folders.png"/>
+
+## Folder behavior
+
+- Folder names can only contain `a-z`, `A-Z`, `0-9` and `-`.
+- Folders can be nested.
+- They only visually change the sidebar in the preview.
+
+## See also
+
+- [`<Composition />`](/docs/composition)
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index 5565c00438..df28dd38ed 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -181,6 +181,7 @@ module.exports = {
"freeze",
"still",
"series",
+ "folder",
"easing",
],
},
diff --git a/packages/docs/static/img/folders.png b/packages/docs/static/img/folders.png
new file mode 100644
index 0000000000..ce3ce3b5f1
Binary files /dev/null and b/packages/docs/static/img/folders.png differ
diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsx
index 3b8a484302..5f068661cc 100644
--- a/packages/example/src/Video.tsx
+++ b/packages/example/src/Video.tsx
@@ -1,25 +1,5 @@
import React from 'react';
-import {Composition, Folder, getInputProps, Still} from 'remotion';
-import {TwentyTwoKHzAudio} from './22KhzAudio';
-import BetaText from './BetaText';
-import {ColorInterpolation} from './ColorInterpolation';
-import {FontDemo} from './Fonts';
-import {Framer} from './Framer';
-import {FreezeExample} from './Freeze/FreezeExample';
-import {MissingImg} from './MissingImg';
-import {OrbScene} from './Orb';
-import InfinityVideo from './ReallyLongVideo';
-import RemoteVideo from './RemoteVideo';
-import {Scripts} from './Scripts';
-import {SkipZeroFrame} from './SkipZeroFrame';
-import {SeriesTesting} from './StaggerTesting';
-import {StaticDemo} from './StaticServer';
-import {TenFrameTester} from './TenFrameTester';
-import ThreeBasic from './ThreeBasic';
-import {VideoOnCanvas} from './VideoOnCanvas';
-import {Greenscreen} from './VideoOnCanvas/greenscreen';
-import {VideoSpeed} from './VideoSpeed';
-import {VideoTesting} from './VideoTesting';
+import {Composition, Folder, getInputProps} from 'remotion';
// Use it to test that UI does not regress on weird CSS
// import './weird-css.css';
@@ -28,307 +8,24 @@ export const Index: React.FC = () => {
const inputProps = getInputProps();
return (
<>
- <Folder name="components">
+ <Folder name="Visuals">
<Composition
- id="iframe"
+ id="CompInFolder"
lazyComponent={() => import('./IframeTest')}
width={1080}
height={1080}
fps={30}
durationInFrames={10}
/>
- <Composition
- id="looped"
- lazyComponent={() => import('./LoopedVideo')}
- durationInFrames={200}
- fps={60}
- height={1080}
- width={1080}
- />
- <Composition
- id="gif"
- lazyComponent={() => import('./GifTest')}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={150}
- />
- <Composition
- id="stagger-test"
- component={SeriesTesting}
- width={1280}
- height={720}
- fps={30}
- durationInFrames={100}
- />
-
- <Composition
- id="freeze-example"
- component={FreezeExample}
- width={1280}
- height={720}
- fps={30}
- durationInFrames={300}
- />
- </Folder>
- <Folder name="regression-testing">
- <Composition
- id="missing-img"
- component={MissingImg}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={10}
- />
- <Composition
- id="ten-frame-tester"
- component={TenFrameTester}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={10}
- />
-
- <Composition
- id="framer"
- component={Framer}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={100}
- />
-
- <Composition
- id="skip-zero-frame"
- component={SkipZeroFrame}
- width={1280}
- height={720}
- fps={30}
- durationInFrames={100}
- />
-
- <Composition
- id="scripts"
- component={Scripts}
- width={1280}
- height={720}
- fps={30}
- durationInFrames={100}
- />
- </Folder>
- <Folder name="creatives">
- <Composition
- id="drop-dots"
- lazyComponent={() => import('./DropDots/DropDots')}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={180 * 30}
- />
- <Composition
- id="tiles"
- lazyComponent={() => import('./Tiles')}
- width={1080}
- height={1920}
- fps={30}
- durationInFrames={90}
- />
- <Composition
- id="title"
- lazyComponent={() => import('./Title')}
- width={1080}
- height={1920}
- fps={30}
- durationInFrames={90}
- defaultProps={{
- line1: 'Test',
- line2: 'text',
- }}
- />
- <Composition
- id="beta-text"
- component={BetaText}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={3 * 30}
- defaultProps={{
- word1: getInputProps().word1,
- }}
- />
- <Composition
- id="react-svg"
- lazyComponent={() => import('./ReactSvg')}
- width={1920}
- height={1080}
- fps={60}
- durationInFrames={300}
- defaultProps={{
- transparent: true,
- }}
- />
- </Folder>
- <Folder name="video-tests">
- <Composition
- id="video-testing-mp4"
- component={VideoTesting}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={100}
- defaultProps={{
- codec: 'mp4' as const,
- }}
- />
- <Composition
- id="video-testing-webm"
- component={VideoTesting}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={100}
- defaultProps={{
- codec: 'webm' as const,
- }}
- />
- <Composition
- id="remote-video"
- component={RemoteVideo}
- width={1280}
- height={720}
- fps={30}
- durationInFrames={600}
- />
- <Composition
- id="2hrvideo"
- component={InfinityVideo}
- width={1920}
- height={1080}
- fps={30}
- durationInFrames={2 * 60 * 60 * 30}
- />
-
- <Composition
- id="video-speed"
- component={VideoSpeed}
- width={1280}
- height={720}
- fps={30}
- durationInFrames={100}
- />
- <Composition
- id="video-on-canvas"
- component={VideoOnCanvas}
- width={1920}
- height={1080}
- fps={30}
- durationInFrames={100}
- />
- <Composition
- id="greenscreen"
- component={Greenscreen}
- width={1920}
- height={1080}
- fps={30}
- durationInFrames={100}
- />
- </Folder>
- <Folder name="features">
- <Composition
- id="mdx-test"
- lazyComponent={() => import('./MdxTest')}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={30 * 30}
- />
- <Composition
- id="color-interpolation"
- component={ColorInterpolation}
- width={1280}
- height={720}
- fps={30}
- durationInFrames={100}
- />
- <Still
- id="static-demo"
- component={StaticDemo}
- width={1000}
- height={1000}
- />
- <Still id="font-demo" component={FontDemo} width={1000} height={1000} />
- <Composition
- id="dynamic-duration"
- component={VideoTesting}
- width={1080}
- height={1080}
- fps={30}
- // Change the duration of the video dynamically by passing
- // `--props='{"duration": 100}'`
- durationInFrames={inputProps?.duration ?? 20}
- />
- <Composition
- id="nested"
- lazyComponent={() => import('./NestedSequences')}
- durationInFrames={200}
- fps={60}
- height={1080}
- width={1080}
- />
- </Folder>
- <Folder name="audio-tests">
- <Composition
- id="22khz"
- component={TwentyTwoKHzAudio}
- width={1920}
- height={1080}
- fps={30}
- durationInFrames={90}
- />
- <Composition
- id="offline-audio-buffer"
- lazyComponent={() => import('./OfflineAudioBuffer')}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={100}
- />
- <Composition
- id="audio-testing-mute"
- lazyComponent={() => import('./AudioTestingMute')}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={300}
- />
- <Composition
- id="audio-testing"
- lazyComponent={() => import('./AudioTesting')}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={300}
- />
- <Composition
- id="audio-visualization"
- lazyComponent={() => import('./AudioVisualization')}
- width={1080}
- height={1080}
- fps={30}
- durationInFrames={180 * 30}
- />
- </Folder>
- <Folder name="three">
- <Still id="Orb" component={OrbScene} width={2000} height={2000} />
- <Composition
- id="three-basic"
- component={ThreeBasic}
- width={1280}
- height={720}
- fps={30}
- durationInFrames={600}
- />
</Folder>
+ <Composition
+ id="CompOutsideFolder"
+ lazyComponent={() => import('./IframeTest')}
+ width={1080}
+ height={1080}
+ fps={30}
+ durationInFrames={10}
+ />
</>
);
};