Skip to main content

selectComposition()v4.0.0

Evaluates the list of compositions from a Remotion Bundle by evaluating the Remotion Root and evaluating calculateMetadata() on the specified composition.

If you want to get a list of all compositions, use getCompositions().

If no composition with the specified ID exists, then this function will throw.

Example
tsx
import { bundle } from "@remotion/bundler";
import { selectComposition } from "@remotion/renderer";
 
const bundled = await bundle({ entryPoint: require.resolve("./src/index.ts") });
const composition = await selectComposition({
serveUrl: bundled,
id: "MyComposition",
inputProps: {},
});
 
console.log(composition.id); // "MyComposition"
console.log(composition.width, composition.height);
console.log(composition.fps, composition.durationInFrames);
Example
tsx
import { bundle } from "@remotion/bundler";
import { selectComposition } from "@remotion/renderer";
 
const bundled = await bundle({ entryPoint: require.resolve("./src/index.ts") });
const composition = await selectComposition({
serveUrl: bundled,
id: "MyComposition",
inputProps: {},
});
 
console.log(composition.id); // "MyComposition"
console.log(composition.width, composition.height);
console.log(composition.fps, composition.durationInFrames);

API

Accepts an object with the following properties:

serveUrl

A string pointing to a Remotion Bundle generated by bundle() or a URL that hosts the the bundled Remotion project.

id

The ID of the composition you want to evaluate.

inputProps

optional in <5.0, required from 5.0

React props that can be obtained using getInputProps() from inside your project.

logLevel?

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.
Default info.

port?

Prefer a specific port that will be used to serve the Remotion project. If not specified, a random port will be used.

chromiumOptions?

See: Chromium Flags

timeoutInMilliseconds?

A number describing how long the render may take to resolve all delayRender() calls before it times out. Default: 30000

browserExecutable?

A string defining the absolute path on disk of the browser executable that should be used. By default Remotion will try to detect it automatically and download one if none is available.

onBrowserLog?

Gets called when your project calls console.log or another method from console. See the documentation for renderFrames for more information.

puppeteerInstance?

An already open Puppeteer Browser instance. Reusing a browser across multiple function calls can speed up the rendering process. You are responsible for opening and closing the browser yourself. If you don't specify this option, a new browser will be opened and closed at the end.

envVariables?

An object containing environment variables to be injected in your project.

See: Environment variables

offthreadVideoCacheSizeInBytes?v4.0.23

From v4.0, Remotion has a cache for <OffthreadVideo> frames. The default is null, corresponding to half of the system memory available when the render starts.
This option allows to override the size of the cache. The higher it is, the faster the render will be, but the more memory will be used.
The used value will be printed when running in verbose mode.
Default: null

binariesDirectory?v4.0.120

The directory where the platform-specific binaries and libraries that Remotion needs are located. Those include an ffmpeg and ffprobe binary, a Rust binary for various tasks, and various shared libraries. If the value is set to null, which is the default, then the path of a platform-specific package located at node_modules/@remotion/compositor-* is selected.
This option is useful in environments where Remotion is not officially supported to run like bundled serverless functions or Electron.

onBrowserDownload?v4.0.137

Gets called when no compatible local browser is detected on the system and this API needs to download a browser. Return a callback to observe progress. See here for how to use this option.

See also