selectComposition()v4.0.0
评估从 Remotion Bundle 中的组合列表,通过评估 Remotion Root 并在指定的 composition 上评估 calculateMetadata()
。
如果您想获取所有组合的列表,请使用 getCompositions()
。
如果不存在具有指定 ID 的组合,则此函数将抛出异常。
Exampletsx
import {bundle } from "@remotion/bundler";import {selectComposition } from "@remotion/renderer";constbundled = awaitbundle ({entryPoint :require .resolve ("./src/index.ts") });constcomposition = awaitselectComposition ({serveUrl :bundled ,id : "MyComposition",inputProps : {},});console .log (composition .id ); // "MyComposition"console .log (composition .width ,composition .height );console .log (composition .fps ,composition .durationInFrames );
Exampletsx
import {bundle } from "@remotion/bundler";import {selectComposition } from "@remotion/renderer";constbundled = awaitbundle ({entryPoint :require .resolve ("./src/index.ts") });constcomposition = awaitselectComposition ({serveUrl :bundled ,id : "MyComposition",inputProps : {},});console .log (composition .id ); // "MyComposition"console .log (composition .width ,composition .height );console .log (composition .fps ,composition .durationInFrames );
API
接受具有以下属性的对象:
serveUrl
指向由 bundle()
生成的 Remotion Bundle 或托管捆绑的 Remotion 项目的 URL。
id
您要评估的组合的 ID。
inputProps
在 <5.0 中为可选,从 5.0 开始为必需
要传递给视频的选定组合的输入属性。。
必须是一个 JSON 对象。
从根组件可以使用 getInputProps()
读取属性。
您可以使用 calculateMetadata()
转换输入属性。
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?
首选用于提供 Remotion 项目的端口。如果未指定,将使用随机端口。
chromiumOptions?
timeoutInMilliseconds?
描述渲染可能需要多长时间来解析所有 delayRender()
调用 在超时之前。默认值:30000
browserExecutable?
定义应使用的浏览器可执行文件的磁盘上的绝对路径的字符串。默认情况下,Remotion 将尝试自动检测并下载一个(如果没有可用的)。
onBrowserLog?
当您的项目调用 console.log
或控制台的其他方法时调用。有关更多信息,请参阅 renderFrames
的文档。
puppeteerInstance?
一个已打开的 Puppeteer Browser
实例。在多个函数调用之间重用浏览器可以加快渲染过程。您负责自行打开和关闭浏览器。如果不指定此选项,将在最后打开并关闭一个新浏览器。
envVariables?
一个包含要注入到您的项目中的环境变量的对象。
查看:环境变量
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.