renderStill()
@remotion/renderer
包的一部分。从 v2.3 版本开始可用。
将单个帧渲染为图像并将其写入指定的输出位置。
如果要渲染视频,请改用 renderMedia()。
示例用法
首先需要打包项目并获取合成。阅读网站上有关服务器端渲染的代码片段以了解如何生成 bundleLocation
和 composition
变量的示例。
ts
awaitrenderStill ({composition ,serveUrl :bundleLocation ,output : '/tmp/still.png',inputProps : {custom : 'data',},});
ts
awaitrenderStill ({composition ,serveUrl :bundleLocation ,output : '/tmp/still.png',inputProps : {custom : 'data',},});
参数
接受具有���下属性的对象:
composition
VideoConfig
描述使用 id
、width
、height
、fps
、durationInFrames
、defaultProps
和 props
的合成的对象。
调用 selectComposition()
或 getCompositions()
来获取可能配置的数组。
serveUrl
要么是指向由 bundle()
生成的 Remotion Webpack bundle 的本地路径,要么是捆绑包托管的 URL。
port?
首选用于提供 Remotion 项目的特定端口。如果未指定,将使用随机端口。
output
帧应该渲染到的绝对路径。
inputProps?
可选
传递给视频所选合成的输入属性。。
必须是 JSON 对象。
从根组件中,可以使用 getInputProps()
读取属性。
您可以使用 calculateMetadata()
转换输入属性。
frame?
可选 - 默认值: 0
应该基于其编号渲染哪个帧。帧是从零开始索引的。
从 v3.2.27 版本开始,允许负值,其中 -1
是最后一帧。
imageFormat?
可选 - 默认值: "png"
图像应该具有的输出格式,可以是 png
、jpeg
、webp
或 pdf
。
scale?
可选
通过因子缩放输出尺寸。查看Scaling以了解更多关于此功能的信息。
jpegQuality?
可选 - 默认值:undefined
设置 JPEG 质量 - 必须是介于 0 和 100 之间的整数,只能在 imageFormat
设置为 jpeg
时传递。
puppeteerInstance?
可选 - 默认值 null
一个已经打开的 Puppeteer Browser
实例。在多个函数调用之间重用浏览器可以加快渲染过程。您负责自行打开和关闭浏览器。如果不指定此选项,将在最后打开并关闭一个新的浏览器。
envVariables?
可选 - 默认值 {}
一个包含环境变量键值对的对象,这些变量将被注入到您的 Remotion 项目中,并且可以通过读取全局 process.env
对象来访问。
logLevel?
v4.0.115
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
.
onArtifact?
v4.0.176
处理由 <Artifact>
组件发出的工件。
overwrite?
可选 - 默认值 true
如果输出已经存在,是否应覆盖文件。
browserExecutable?
v2.3.1
可选
定义应使用的浏览器可执行文件在磁盘上的绝对路径的字符串。默认情况下,Remotion 将尝试自动检测并下载一个可执行文件。
onBrowserLog?
v3.3.93
可选
当您的项目调用 console.log
或控制台的另一个方法时调用。有关更多信息,请参阅renderFrames
的文档。
timeoutInMilliseconds?
v2.6.3
可选
描述渲染可能需要多长时间来解析所有 delayRender()
调用在超时之前。默认值:30000
cancelSignal?
v3.0.15
_optional_
一个允许取消渲染的令牌。查看:makeCancelSignal()
chromiumOptions?
v2.6.5
optional
允许您设置某些 Chromium / Google Chrome 标志。查看:Chromium flags.
需要在浏览器启动时设置 Chromium 标志。如果您使用 puppeteerInstance
传递一个实例,则传递给 renderStill()
的选项将不适用,而是传递给 openBrowser()
的标志。
disableWebSecurity
boolean - 默认值 false
这将主要禁用 CORS 和其他安全功能。
enableMultiProcessOnLinux?
v4.0.42
Removes the --single-process
flag that gets passed to Chromium on Linux by default. This will make the render faster because multiple processes can be used, but may cause issues with some Linux distributions or if window server libraries are missing.Default:
false
until v4.0.136, then true
from v4.0.137 on because newer Chrome versions don't allow rendering with the --single-process
flag. This flag will be removed in Remotion v5.0.
ignoreCertificateErrors?
boolean - 默认值 false
导致无效的 SSL 证书(如自签名证书)被忽略。
headless?
If disabled, the render will open an actual Chrome window where you can see the render happen. The default is headless mode.
gl
Changelog
- From Remotion v2.6.7 until v3.0.7, the default for Remotion Lambda was
swiftshader
, but from v3.0.8 the default isswangle
(Swiftshader on Angle) since Chrome 101 added support for it. - From Remotion v2.4.3 until v2.6.6, the default was
angle
, however it turns out to have a small memory leak that could crash long Remotion renders.
Select the OpenGL renderer backend for Chromium.
Accepted values:
"angle"
"egl"
"swiftshader"
"swangle"
"vulkan"
(from Remotion v4.0.41)"angle-egl"
(from Remotion v4.0.51)
The default is null
, letting Chrome decide, except on Lambda where the default is "swangle"
userAgent
v3.3.83
允许您设置 headless Chrome 浏览器所使用的自定义用户代理。
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.
dumpBrowserLogs?
dumpBrowserLogs?
optional - 默认值 false
,在 v4.0 中已弃用
已弃用,建议使用 logLevel
。
quality?
quality?
在 v4.0.0
中更名为 jpegQuality
。
返回值
返回值是一个解析为具有以下键的对象的 Promise:
buffer
: (从 v3.3.9 开始可用) 一个Buffer
,仅在未提供output
选项时存在。否则为 null。
参见
I'm ready to translate the Markdown content into Chinese. Please go ahead and paste the content for translation.