🎥 Make videos programmatically with React
improve doc page "The fundamentals"
Jonny Burger7b3d8ebc98e5
diff --git a/packages/docs/docs/the-fundamentals.md b/packages/docs/docs/the-fundamentals.mdindex 2d49c1fda0..39783e75f8 100644--- a/packages/docs/docs/the-fundamentals.md+++ b/packages/docs/docs/the-fundamentals.md@@ -4,30 +4,30 @@ title: The fundamentals---```twoslash include example-import { useCurrentFrame } from "remotion";+import { useCurrentFrame, AbsoluteFill } from "remotion";-export const MyVideo = () => {+export const MyComposition = () => {const frame = useCurrentFrame();return (- <div+ <AbsoluteFillstyle={{- flex: 1,- textAlign: "center",- fontSize: "7em",+ justifyContent: "center",+ alignItems: "center",+ fontSize: 100,}}>The current frame is {frame}.- </div>+ </AbsoluteFill>);};-// - MyVideo+// - MyComposition```-The basic idea behind Remotion is that we'll give you a frame number and a blank canvas, and the freedom to render anything you want using **[React](https://reactjs.org)**.+The basic idea behind Remotion is that we'll give you a frame number and a blank canvas, and the freedom to render anything you want using [React](https://reactjs.org).```tsx twoslash-// @include: example-MyVideo+// @include: example-MyComposition```A video is a function of images over time. If you change content every frame, you'll end up with an animation.@@ -36,28 +36,30 @@ A video is a function of images over time. If you change content every frame, yoA video has 4 properties:-- `width` and `height` in pixels.+- `width` in pixels.+- `height` in pixels.- `durationInFrames`: The number of frames which the video is long.-- `fps`: The amount of frames per second. The duration in frames divided by FPS results in the duration in seconds.+- `fps`: Frames per second. The duration in frames divided by FPS results in the duration in seconds.-These properties are variable and you can reuse a component multiple times with different properties. This is why you better not hard-code these properties, but instead derive them from the [`useVideoConfig()`](/docs/use-video-config) hook:+These properties are variable and you can reuse a component multiple times with different properties.+Rather than hardcoding these values, we can derive them from the [`useVideoConfig()`](/docs/use-video-config) hook:```tsx twoslash-import { useVideoConfig } from "remotion";+import { AbsoluteFill, useVideoConfig } from "remotion";-export const MyVideo = () => {+export const MyComposition = () => {const { fps, durationInFrames, width, height } = useVideoConfig();return (- <div+ <AbsoluteFillstyle={{- flex: 1,- textAlign: "center",- fontSize: "7em",- }}- >- This {width}px x {height}px video is {durationInFrames / fps} seconds long.- </div>+ justifyContent: "center",+ alignItems: "center",+ fontSize: 60,+ }}+ >+ This {width}x{height}px video is {durationInFrames / fps} seconds long.+ </AbsoluteFill>);};```@@ -66,31 +68,29 @@ A video's first frame is `0` and it's last frame is `durationInFrames - 1`.## Defining compositions-Compositions are components with the above mentioned metadata. You can define compositions in `src/Video.tsx` to make them show up in the left sidebar.+Using a [composition](/docs/terminology#composition) you can define a video that should be rendered.-```tsx twoslash+You define a composition by rendering a [`<Composition>`](/docs/composition) component in `src/Video.tsx`, giving it an `id`, defining values for its `height`, `width`, `fps` and `durationInFrames`, and passing a React component to `component`.++```tsx twoslash title="src/Video.tsx"import { Composition } from "remotion";-// @include: example-MyVideo+// @include: example-MyComposition// ---cut---export const RemotionVideo: React.FC = () => {return (<><Composition- id="MyVideo"- component={MyVideo}+ id="MyComposition"durationInFrames={150}fps={30}width={1920}height={1080}- // Optionally, you can define props that get passed to the component- defaultProps={{ hello: "world" }}+ component={MyComposition}/></>);};```-Remember that if you like, you can register multiple compositions that rely on the same component. For example, if you like to make a square video for social media feeds, and a portrait video for Stories, you can reuse the component and try to make it 'responsive'.--Besides the [`<Composition />`](/docs/composition) component, you can also use a [`<Still />`](/docs/still) component and define a still image rather than a video.+You can render as many compositions as you like in `src/Video.tsx`.