Skip to content

🎥 Make videos programmatically with React

Docs: Make it more explicit that `inputProps` should also be passed to selectComposition() and getCompositions()

Jonny Burger033fd821abf2
diff --git a/packages/docs/docs/passing-props.md b/packages/docs/docs/passing-props.md
index 53cfe2e855..6edb8ecbfa 100644
--- a/packages/docs/docs/passing-props.md
+++ b/packages/docs/docs/passing-props.md
@@ -101,35 +101,35 @@ npx remotion render HelloWorld out/helloworld.mp4 --props=./path/to/props.json
When server-rendering using [`renderMedia()`](/docs/renderer/render-media) or [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda), you can pass props using the [`inputProps`](/docs/renderer/render-media#inputprops) option:
-```tsx twoslash {8-10}
+```tsx twoslash {3-5, 10, 18}
// @module: esnext
// @target: es2017
-const composition = {
- fps: 30,
- durationInFrames: 30,
- width: 1080,
- height: 1080,
- id: "my-video",
- defaultProps: {},
- props: {},
- defaultCodec: null,
-};
const serveUrl = "/path/to/bundle";
const outputLocation = "/path/to/frames";
// ---cut---
-import { renderMedia } from "@remotion/renderer";
+import { renderMedia, selectComposition } from "@remotion/renderer";
+
+const inputProps = {
+ titleText: "Hello World",
+};
+
+const composition = await selectComposition({
+ serveUrl,
+ id: "my-video",
+ inputProps,
+});
await renderMedia({
composition,
serveUrl,
codec: "h264",
outputLocation,
- inputProps: {
- titleText: "Hello World",
- },
+ inputProps,
});
```
+You should pass your `inputProps` to both [`selectComposition()`](/docs/renderer/select-composition) and [`renderMedia()`](/docs/renderer/render-media).
+
### Passing input props in GitHub Actions
[See: Render using GitHub Actions](/docs/ssr#render-using-github-actions)
diff --git a/packages/docs/docs/renderer/render-media.md b/packages/docs/docs/renderer/render-media.md
index e88e4ea0a5..571795a85a 100644
--- a/packages/docs/docs/renderer/render-media.md
+++ b/packages/docs/docs/renderer/render-media.md
@@ -9,9 +9,36 @@ _Available since v3.0 - Part of the `@remotion/renderer` package._
Render a video or an audio programmatically.
-## Example
+```tsx twoslash title="render.mjs"
+// @module: esnext
+// @target: es2017
+const serveUrl = "/path/to/bundle";
+const outputLocation = "/path/to/frames";
-See an example of `renderMedia()` together with [`bundle()`](/docs/bundle) and [`getCompositions()`](/docs/renderer/get-compositions) on the [server-side rendering page](/docs/ssr).
+import { renderMedia, selectComposition } from "@remotion/renderer";
+
+const inputProps = {
+ titleText: "Hello World",
+};
+
+const composition = await selectComposition({
+ serveUrl,
+ id: "my-video",
+ inputProps,
+});
+
+// ---cut---
+
+await renderMedia({
+ composition,
+ serveUrl,
+ codec: "h264",
+ outputLocation,
+ inputProps,
+});
+```
+
+See an [example](/docs/ssr-node) of `renderMedia()` together with [`bundle()`](/docs/bundle) and [`selectComposition()`](/docs/renderer/select-composition) on the [server-side rendering page](/docs/ssr-node).
## Arguments
@@ -44,6 +71,34 @@ _"h264" (default) | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" |
Choose a suitable codec for your output media. Refer to the [Encoding guide](/docs/encoding) to find the best codec for your use case.
+### `inputProps?`
+
+_object - optional_
+
+An object of arbitrary shape that:
+
+<Step>1</Step> will be passed as <a href="/docs/parameterized-rendering">props to your component</a><br/>
+<Step>2</Step> can be retrieved using <a href="/docs/get-input-props"><code>getInputProps()</code></a>.<br/><br/>
+
+Make sure to also pass the same `inputProps` to [`selectComposition()`](/docs/renderer/select-composition) for this to work correctly.
+
+### `frameRange?`
+
+_number | [number, number] - optional_
+
+Specify a single frame (passing a `number`) or a range of frames (passing a tuple `[number, number]`) to be rendered. By passing `null` (default) all frames of a composition get rendered.
+
+### `concurrency?`
+
+_optional_
+
+A `number` specifying how many render processes should be started in parallel, a `string` specifying the percentage of the CPU threads to use, or `null` to let Remotion decide based on the CPU of the host machine. Default is half of the CPU threads available.
+
+### `logLevel?`<AvailableFrom v="4.0.0"/>
+
+One of `verbose`, `info`, `warn`, `error`. Determines how much is being logged to the console.
+`verbose` will also log `console.log`'s from the browser.
+
### `audioCodec?`
_"pcm-16" | "aac" | "mp3" | "opus", available from v3.3.41_
@@ -78,18 +133,6 @@ FFMPEG may encode the video in a way that will not result in the exact video bit
This option cannot be set if `--crf` is set.
Example values: `512K` for 512 kbps, `1M` for 1 Mbps.
-### `inputProps?`
-
-_object - optional_
-
-An object of arbitrary shape that will be passed as [props to your composition](/docs/parameterized-rendering) and that can be retrieved using [`getInputProps()`](/docs/get-input-props).
-
-### `concurrency?`
-
-_optional_
-
-A `number` specifying how many render processes should be started in parallel, a `string` specifying the percentage of the CPU threads to use, or `null` to let Remotion decide based on the CPU of the host machine. Default is half of the CPU threads available.
-
### `crf?`
_number | null - optional_
@@ -146,12 +189,6 @@ Sets the quality of the generated JPEG images. Must be an integer between 0 and
Only applies if `imageFormat` is `'jpeg'`, otherwise this option is invalid.
-### `frameRange?`
-
-_number | [number, number] - optional_
-
-Specify a single frame (passing a `number`) or a range of frames (passing a tuple `[number, number]`) to be rendered. By passing `null` (default) all frames of a composition get rendered.
-
### `muted?`<AvailableFrom v="3.2.1" />
_boolean - optional_
@@ -287,11 +324,6 @@ Sets a Preset profile. Only applies to videos rendered with `h264` codec.
Possible values: `superfast`, `veryfast`, `faster`, `fast`, `medium`, `slow`, `slower`, `veryslow`, `placebo`,
Default: `medium`
-### `logLevel?`<AvailableFrom v="4.0.0"/>
-
-One of `verbose`, `info`, `warn`, `error`. Determines how much is being logged to the console.
-`verbose` will also log `console.log`'s from the browser.
-
### `onBrowserLog?`
_function - optional_