Skip to main content

getCompositions()

Part of the @remotion/renderer package.

Gets a list of compositions defined in a Remotion project based on a Remotion Bundle by evaluating the Remotion Root.

For every compositions their calculateMetadata() function is evaluated. If you just want to evaluate one composition that you want to render, use selectComposition().

ts
const getCompositions: (
serveUrlOrWebpackUrl: string,
options?: GetCompositionsConfig,
) => Promise<TComposition[]>;
ts
const getCompositions: (
serveUrlOrWebpackUrl: string,
options?: GetCompositionsConfig,
) => Promise<TComposition[]>;

Arguments

serveUrlOrWebpackUrl

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

options?

optional

An object containing one or more of the following options:

inputProps

optional in <5.0, required from 5.0

Input Props to pass to the selected composition of your video..
Must be a JSON object.
From the root component the props can be read using getInputProps().
You may transform input props using calculateMetadata().

puppeteerInstance?v3.0.0

optional

An already open Puppeteer Browser instance. Use openBrowser() to create a new 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.

browserExecutable?v2.3.1

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. If puppeteerInstance is defined, it will take precedence over browserExecutable.

onBrowserLog?v3.0.0

optional

Gets called when your project calls console.log or another method from console. A browser log has three properties:

  • text: The message being printed
  • stackTrace: An array of objects containing the following properties:
    • url: URL of the resource that logged.
    • lineNumber: 0-based line number in the file where the log got called.
    • columnNumber: 0-based column number in the file where the log got called.
  • type: The console method - one of log, debug, info, error, warning, dir, dirxml, table, trace, clear, startGroup, startGroupCollapsed, endGroup, assert, profile, profileEnd, count, timeEnd, verbose
tsx
getCompositions({
// ...
onBrowserLog: (info) => {
console.log(`${info.type}: ${info.text}`);
console.log(
info.stackTrace
.map((stack) => {
return ` ${stack.url}:${stack.lineNumber}:${stack.columnNumber}`;
})
.join('\n'),
);
},
});
tsx
getCompositions({
// ...
onBrowserLog: (info) => {
console.log(`${info.type}: ${info.text}`);
console.log(
info.stackTrace
.map((stack) => {
return ` ${stack.url}:${stack.lineNumber}:${stack.columnNumber}`;
})
.join('\n'),
);
},
});

timeoutInMilliseconds?v2.6.3

A number describing how long one frame may take to resolve all delayRender() calls before the [render times out and fails(/docs/timeout). Default: 30000

port?

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

logLevel?v4.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.
Default info.

chromiumOptions?v2.6.5

optional

Allows you to set certain Chromium / Google Chrome flags. See: Chromium flags.

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.

ffmpegExecutable

removed in v4.0, optional

An absolute path overriding the ffmpeg executable to use.

ffprobeExecutable? v3.0.17

removed in v4.0

An absolute path overriding the ffprobe executable to use.

Return value

Returns a promise that resolves to an array of available compositions. Example value:

ts
[
{
id: 'HelloWorld',
width: 1920,
height: 1080,
fps: 30,
durationInFrames: 120,
defaultProps: {
title: 'Hello World',
},
},
{
id: 'Title',
width: 1080,
height: 1080,
fps: 30,
durationInFrames: 90,
defaultProps: undefined,
},
];
ts
[
{
id: 'HelloWorld',
width: 1920,
height: 1080,
fps: 30,
durationInFrames: 120,
defaultProps: {
title: 'Hello World',
},
},
{
id: 'Title',
width: 1080,
height: 1080,
fps: 30,
durationInFrames: 90,
defaultProps: undefined,
},
];

The defaultProps only get returned since v2.5.7.

See also