Skip to main content

selectComposition()v4.0.0

通过评估Remotion Root并在指定的composition上评估calculateMetadata()来评估来自Remotion Bundle的作品列表。

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

如果你想获取所有作品的列表,请使用 getCompositions()

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

如果指定的 ID 没有对应的作品存在,则此函数将抛出异常。

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

Example
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

一个指向由bundle()生成的Remotion Bundle的字符串,或托管打包后的Remotion项目的URL。

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

id

你想评估的作品的 ID

🌐 The ID of the composition you want to evaluate.

inputProps

在 v4.x 中是可选的,从 v5.0 起是必需的。

🌐 Optional in v4.x, required from v5.0.

传递给所选视频组合的输入属性。
必须是一个 JSON 对象。
可以从根组件使用 getInputProps() 读取属性。
你可以使用 calculateMetadata() 转换输入属性。

logLevel?

One of trace, verbose, info, warn, error.
Determines how much info is being logged to the console.

Default info.

port?

偏好用于服务 Remotion 项目的特定端口。如果未指定,将使用随机端口。

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

chromiumOptions?

参见:Chromium Flags

🌐 See: Chromium Flags

timeoutInMilliseconds?

一个数字,描述渲染可能花多长时间来解决所有 delayRender() 调用 在超时之前。默认值:30000

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

browserExecutable?

一个字符串,定义应使用的浏览器可执行文件在磁盘上的绝对路径。默认情况下,如果没有可用的,Remotion 将尝试自动检测并下载一个。

🌐 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?

当你的项目调用 console.log 或从控制台调用的其他方法时会被调用。有关更多信息,请参阅 renderFrames 文档。

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

puppeteerInstance?

一个已打开的 Browser 实例。使用 openBrowser() 来创建一个新实例。在多个函数调用中重复使用同一个浏览器可以加快渲染过程。你需要自己负责打开和关闭浏览器。如果你不指定此选项,将会在结束时打开并关闭一个新的浏览器。

🌐 An already open 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.

note

尽管名字如此,实际上不兼容 puppeteer,仅兼容 openBrowser()

envVariables?

包含要注入到你的项目中的环境变量的对象。

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

请参阅:环境变量

🌐 See: Environment variables

mediaCacheSizeInBytes?v4.0.352

Specify the maximum size of the cache that <Video> and <Audio> from @remotion/media may use combined, in bytes.
The default is half of the available system memory when the render starts.

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

offthreadVideoThreads?v4.0.261

The number of threads that<OffthreadVideo> can start to extract frames. The default is 2. Increase carefully, as too many threads may cause instability.

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.

chromeMode?v4.0.248

One of headless-shell, chrome-for-testing. Default headless-shell. Use chrome-for-testing to take advantage of GPU drivers on Linux.

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.

兼容性

🌐 Compatibility

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

另请参阅

🌐 See also