渲染 GIF
自 v3.1 版本起可用
🌐 Available since v3.1
你可以通过以下方式将视频渲染为 GIF:
🌐 You can render a video as a GIF by:
- 在命令行中传递
--codec=gif - 在
renderMedia()、stitchFramesToVideo()、renderMediaOnLambda()或renderMediaOnVercel()中设置codec: "gif"。
减少帧率
🌐 Reducing frame rate
通常,GIF 的帧率低于视频。为此,我们支持一个参数 everyNthFrame,其作用如下:
🌐 Commonly a GIF has a lower frame rate than a video. For this, we support a parameter everyNthFrame that works as follows:
- 默认情况下,
everyNthFrame设置为1:帧0、1、2、3、4等被渲染。 - 假设
everyNthFrame是2,则每隔一帧才渲染一次:1、3、5、7,依此类推。一个30FPS的视频现在将变成15FPS的GIF。 - 如果
everyNthFrame是3,则只渲染每第三帧:2、5、8、11,并且该模式继续。
everyNthFrame 被支持:
- 在
renderFrames()、renderMedia()、renderMediaOnLambda()和renderMediaOnVercel() - 在 CLI 中使用
--every-nth-frame=2本地 或 在 Lambda 上。 - 在配置文件中使用
setEveryNthFrame()。
更改循环次数
🌐 Changing the number of loops
numberOfGifLoops 选项允许你按如下方式设置循环次数:
🌐 The numberOfGifLoops option allows you to set the number of loops as follows:
null(或在命令行中省略)表示无限循环播放 GIF。0禁用循环。1循环 GIF 一次(总共播放两次)2循环播放 GIF 两次(总共播放三次)- 等等。
numberOfGifLoops 选项可以设置为:
🌐 The numberOfGifLoops option can be set:
- 在 CLI 中使用
--number-of-gif-loops=0标志在本地 locally 或在 Lambda 上渲染时。 - 在
stitchFramesToVideo()、renderMedia()、renderMediaOnLambda()和renderMediaOnVercel() - 在配置文件中使用
setNumberOfGifLoops()。
导入 GIF
🌐 Importing GIFs
想知道如何将其他 GIF 导入到 Remotion 项目中吗?点击这里。
🌐 Wondering how to import other GIFs into a Remotion project? See here.
透明 GIF
🌐 Transparent GIFs
要渲染透明 GIF,必须将 imageFormat 选项设置为 "png"。在 Remotion Studio 中,可以在“图片”选项卡中设置此选项。
🌐 To render a transparent GIF, the imageFormat option must be set to "png". In the Remotion Studio, this can be set in the "Picture" tab.
另请参阅
🌐 See also