getCompositions()
@remotion/renderer 包的一部分.
🌐 Part of the @remotion/renderer package.
通过评估 Remotion 根,根据 Remotion Bundle 获取在 Remotion 项目中定义的合成列表。
🌐 Gets a list of compositions defined in a Remotion project based on a Remotion Bundle by evaluating the Remotion Root.
对于每个组合,它们的 calculateMetadata() 函数都会被评估。如果你只想评估你想渲染的一个组合,可以使用 selectComposition()。
🌐 For every compositions their calculateMetadata() function is evaluated. If you just want to evaluate one composition that you want to render, use selectComposition().
const getCompositions: (serveUrlOrWebpackUrl: string, options?: GetCompositionsConfig) => Promise<TComposition[]>;参数
🌐 Arguments
serveUrlOrWebpackUrl
一个指向由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.
options?
一个包含以下一个或多个选项的对象:
🌐 An object containing one or more of the following options:
inputProps
在 v4.x 中是可选的,从 v5.0 起是必需的。
🌐 Optional in v4.x, required from v5.0.
传递给所选视频组合的输入属性。。
必须是一个 JSON 对象。
可以从根组件使用 getInputProps() 读取属性。
你可以使用 calculateMetadata() 转换输入属性。
puppeteerInstance?v3.0.0
一个已打开的 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.
尽管名字如此,实际上不兼容 puppeteer,仅兼容 openBrowser()。
browserExecutable?v2.3.1
一个字符串,定义应使用的浏览器可执行文件在磁盘上的绝对路径。默认情况下,Remotion 会尝试自动检测它,如果不可用,将下载一个。如果定义了 puppeteerInstance,它将优先于 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. If puppeteerInstance is defined, it will take precedence over browserExecutable.
onBrowserLog?v3.0.0
当你的项目调用 console.log 或控制台中的其他方法时会被调用。浏览器日志有三个属性:
🌐 Gets called when your project calls console.log or another method from console. A browser log has three properties:
text:正在打印的消息stackTrace:一个包含以下属性的对象数组:url:记录的资源的 URL。lineNumber:日志被调用时文件中的零起点行号。columnNumber:日志被调用时文件中的零起始列号。
type:控制台方法——以下之一log、debug、info、error、warning、dir、dirxml、table、trace、clear、startGroup、startGroupCollapsed、endGroup、assert、profile、profileEnd、count、timeEnd、verbose
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
一个数字,描述在渲染超时并失败之前,一帧可能需要多长时间来处理所有 delayRender() 调用。默认值:30000
🌐 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?
偏好用于服务 Remotion 项目的特定端口。如果未指定,将使用随机端口。
🌐 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 trace, verbose, info, warn, error.Determines how much info is being logged to the console.
Default
info.
chromiumOptions?v2.6.5
允许你设置某些 Chromium / Google Chrome 标志。见:Chromium 标志。
🌐 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
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.
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.
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.
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.
ffmpegExecutable
ffmpegExecutable在 v4.0 中移除
🌐 removed in v4.0
用于覆盖 ffmpeg 可执行文件的绝对路径。
🌐 An absolute path overriding the ffmpeg executable to use.
ffprobeExecutable? v3.0.17
ffprobeExecutable?在 v4.0 中移除
🌐 removed in v4.0
用于覆盖 ffprobe 可执行文件的绝对路径。
🌐 An absolute path overriding the ffprobe executable to use.
返回值
🌐 Return value
返回一个解析为可用组合数组的承诺。示例值:
🌐 Returns a promise that resolves to an array of available compositions. Example value:
[
{
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 ,
},
];defaultProps 仅从 v2.5.7 版本开始返回。
🌐 The defaultProps only get returned since v2.5.7.
兼容性
🌐 Compatibility
| Browsers | Servers | Environments | |||||||
|---|---|---|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | Node.js | Bun | Serverless Functions | ||||
另请参阅
🌐 See also