🎥 Make videos programmatically with React
start writing docs
Jonny Burger5ae6f70b8406
diff --git a/packages/docs/docs/dynamic-metadata.md b/packages/docs/docs/dynamic-metadata.mdnew file mode 100644index 0000000000..ede97faf20--- /dev/null+++ b/packages/docs/docs/dynamic-metadata.md@@ -0,0 +1,18 @@+---+id: dynamic-metadata+title: Dynamic duration, FPS & dimensions+---++_Available since v2.0._++Using [Input props](parametrized-rendering) you can customize the content of your videos while rendering. But what about if you want to change the duration, frame rate or the dimensions of your video based on input props or asynchronous operations?++## Change metadata based on input props++Use the `getInputProps()` method to retrieve the props that you have passed as an input.+For example if you have passed `--props='{"hello": "world"}'` as a command line flag, you can read the value in your Remotion project like this:++```tsx+const {hello} = getInputProps()+console.log(hello) // "world"+```diff --git a/packages/docs/docs/parametrized-rendering.md b/packages/docs/docs/parametrized-rendering.mdindex 8ce4bf318b..2b3ef06418 100644--- a/packages/docs/docs/parametrized-rendering.md+++ b/packages/docs/docs/parametrized-rendering.md@@ -5,7 +5,7 @@ title: Parametrized renderingParametrized rendering is the idea of creating a video template once and then render as many videos as you want with different parameters. Just like in regular React, we use props to reuse and customize components!-## Defining accepted props and default values+## Defining accepted propsTo define which props your video accepts, simply give your component the `React.FC` type and pass in a generic argument describing the shape of the props you want to accept.@@ -20,6 +20,8 @@ export const MyComponent: React.FC<{}```+## Define default props+When registering the component as a sequence, you can define the default props:```tsx {13-16}@@ -47,7 +49,11 @@ export const Root = () => {By using `React.FC`, you can ensure type safety and avoid errors caused by typos.-## Passing props in the CLI+## Input props++Input props are props that are passed in externally while rendering that can replace or override the default props++### Passing input props in the CLIWhen rendering (for example using the `npm run build` script defined in `package.json`), you can override some or all default props by passing a CLI flag. It must be valid JSON, pay attention to quote escaping. Using this technique, no type safety can be guaranteed.@@ -57,9 +63,9 @@ npx remotion render src/index.tsx HelloWorld helloworld.mp4 --props='{"propOne":[See also: CLI flags](/docs/cli)-## Passing props when server rendering+### Passing input props when server rendering-When server-rendering using `renderFrames`, you can pass props using the `userProps` option:+When server-rendering using `renderFrames`, you can pass props using the `inputProps` option:```tsx {8-10}await renderFrames({@@ -69,7 +75,7 @@ await renderFrames({onFrameUpdate: (f) => void 0,parallelism: null,outputDir: framesDir,- userProps: {+ inputProps: {titleText: 'Hello World'},compositionId: 'HelloWorld',@@ -77,7 +83,7 @@ await renderFrames({});```-## Passing props in GitHub Actions+### Passing input props in GitHub Actions[See: Render using GitHub Actions](/docs/ssr#render-using-github-actions)@@ -96,6 +102,12 @@ workflow_dispatch:default: "black"```+### Retrieve input props++Input props are passed to the component of your composition directly and you can access as regular React component props.++_Available since v2.0._: You can also use the `getInputProps()` function to retrieve props that you have given as an input. This is useful if you need to retrieve the props in a position where you are not inside your component, such as when determining the video duration, dimensions or frame rate.+## You can still use components as normalEven if you have registered a component as a sequence,diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 23b717bdf0..45c99ff2e6 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -26,6 +26,7 @@ module.exports = {"using-randomness","encoding","transparent-videos",+ "dynamic-metadata",],},{