v4.0 迁移
在从 Remotion 3 升级到 Remotion 4 时,请注意以下更改并将其应用到您的项目中。
如何升级
查看 变更日志 以找到最新版本。
将 remotion
和所有以 @remotion
开头的包升级到最新版本,例如 4.0.0
:
diff
- "remotion": "^3.3.43"- "@remotion/bundler": "^3.3.43"- "@remotion/eslint-config": "^3.3.43"- "@remotion/eslint-plugin": "^3.3.43"- "@remotion/cli": "^3.3.43"- "@remotion/renderer": "^3.3.43"+ "remotion": "4.0.0"+ "@remotion/bundler": "4.0.0"+ "@remotion/eslint-config": "4.0.0"+ "@remotion/eslint-plugin": "4.0.0"+ "@remotion/cli": "4.0.0"+ "@remotion/renderer": "4.0.0"
diff
- "remotion": "^3.3.43"- "@remotion/bundler": "^3.3.43"- "@remotion/eslint-config": "^3.3.43"- "@remotion/eslint-plugin": "^3.3.43"- "@remotion/cli": "^3.3.43"- "@remotion/renderer": "^3.3.43"+ "remotion": "4.0.0"+ "@remotion/bundler": "4.0.0"+ "@remotion/eslint-config": "4.0.0"+ "@remotion/eslint-plugin": "4.0.0"+ "@remotion/cli": "4.0.0"+ "@remotion/renderer": "4.0.0"
然后分别运行 npm i
、yarn
或 pnpm i
。
系统要求
最低 Node 版本现在为 16.0.0。
仅支持以下平台:Windows(仅限 x64)、macOS、Linux。
具有 glibc 的 Linux 发行版需要至少版本 2.35。在此处查看 更多信息。
配置文件更改
CLI 配置文件已从核心 Remotion 包移动到 @remotion/cli/config
。更新您的导入如下:
diff
- import {Config} from 'remotion';+ import {Config} from '@remotion/cli/config';
diff
- import {Config} from 'remotion';+ import {Config} from '@remotion/cli/config';
选项已被展平。例如,不再使用 Config.Bundling.overrideWebpackConfig
,而是现在使用 Config.overrideWebpackConfig
。
diff
- Config.Bundling.overrideWebpackConfig()+ Config.overrideWebpackConfig()- Config.Output.setOverwriteOutput(true);+ Config.setOverwriteOutput(true);
diff
- Config.Bundling.overrideWebpackConfig()+ Config.overrideWebpackConfig()- Config.Output.setOverwriteOutput(true);+ Config.setOverwriteOutput(true);
将此应用于所有配置调用。
分离 ImageFormat
以前,imageFormat
选项将用于静态图像和视频。虽然对于静态图像,PNG 通常更可取,但对于视频来说,默认情况下使用 JPEG 整体速度更快。在 Remotion 4.0 中,图像格式被分开,因此您可以分别为视频和静态图像设置默认值。
Config.setImageFormat
被Config.setVideoImageFormat()
和Config.setStillImageFormat()
替换。
diff
- Config.setImageFormat('jpeg');+ Config.setVideoImageFormat('jpeg');
diff
- Config.setImageFormat('jpeg');+ Config.setVideoImageFormat('jpeg');
- 所有命令的 CLI 选项仍为
--image-format
。 - Node.JS API 名称仍为
imageFormat
。 - TypeScript 类型
ImageFormat
已分为StillImageFormat
和VideoImageFormat
。 StillImageFormat
现在还支持webp
和pdf
!
简化的日志记录
对于getCompositions()
, renderMedia()
, renderStill()
, getCompositionsOnLambda()
, renderMediaOnLambda()
和 renderStillOnLambda()
:
verbose
和 dumpBrowserLogs
已被弃用,推荐使用 "logLevel": "verbose"
。这使得选项等同于 CLI 选项。
不再支持 Lambda architecture
在部署 Lambda 时,您以前可以在 arm64
和 x86_64
架构之间进行选择。
从 v4.0 开始,仅支持 arm64
。这应该更快、更便宜,并且不会有 任何与 x86_64
不同的行为。
升级方法:
- 从
estimatePrice()
和deployFunction()
中移除architecture
选项。
移除了丰富的时间轴
由于性能问题,使用 "丰富的时间轴" 选项已被移除。
现在时间轴始终处于简单模式,但支持同时显示更多时间轴层。
ProRes 视频现在默认导出未压缩音频
以前,ProRes 导出的默认音频编解码器是 aac
。现在默认是 pcm_s16le
,代表未压缩的 16 位低端 PCM 音频。
这一变更是因为用户主要导出 ProRes 以获取高质量素材,以便在视频编辑程序中进一步使用。
将 quality
选项重命名为 jpegQuality
为了澄清此选项的含义,现在通用称为 "JPEG 质量"。调整以下选项:
npx remotion render
: 使用--jpeg-quality
替代--quality
npx remotion still
: 使用--jpeg-quality
替代--quality
npx remotion benchmark
: 使用--jpeg-quality
替代--quality
npx remotion lambda render
: 使用--jpeg-quality
替代--quality
npx remotion lambda still
: 使用--jpeg-quality
替代--quality
renderFrames()
: 使用jpegQuality
替代quality
renderMedia()
: 使用jpegQuality
替代quality
renderStill()
: 使用jpegQuality
替代quality
renderMediaOnLambda()
: 使用jpegQuality
替代quality
renderStillOnLambda()
: 使用jpegQuality
替代quality
不再需要安装FFmpeg,ffmpegExecutable
选项已移除
FFmpeg 现在已经内置到 @remotion/renderer
包中。因此,ffmpegExecutable
和 ffprobeExecutable
选项已被移除。
此外,npx remotion install ffmpeg
和 npx remotion install ffprobe
命令也不再存在。
升级方法:
- 从
renderMedia()
、renderStill()
、getCompositions()
、renderFrames()
和stitchFramesToVideo()
调用中移除ffmpegExecutable
选项。 - 从
renderMedia()
、renderStill()
、getCompositions()
、renderFrames()
和stitchFramesToVideo()
调用中移除ffprobeExecutable
选项。 - 移除所有对
ensureFfmpeg()
的调用。 - 移除所有对
ensureFfprobe()
的调用。 - 从
npx remotion render
、npx remotion still
和npx remotion benchmark
命令中移除--ffmpeg-executable
标志。 - 从
npx remotion render
、npx remotion still
和npx remotion benchmark
命令中移除--ffprobe-executable
标志。 - 不再使用
npx remotion install
命令
新增 npx remotion ffmpeg
和 npx remotion ffprobe
由于不再需要安装 FFmpeg 和 FFprobe,你的环境中可能也不再有 ffmpeg
和 ffprobe
命令。为了仍然能够使用一些有用的 FFmpeg 命令,我们引入了 npx remotion ffmpeg
和 npx remotion ffprobe
。请注意,为了保持二进制文件的大小,这些 FFmpeg 二进制文件只支持 Remotion 本身支持的编解码器:H.264、H.265、VP8、VP9 和 ProRes。
移动了 onSlowestFrames
API
在 V3 中,onSlowestFrames
是一个回调函数,你可以将其传递给 renderMedia()
。
在 V4 中,这些数据已经移动到返回值中。
ImageFormat 已移除
@remotion/renderer 中的 ImageFormat
类型已被更具体的类型 VideoImageFormat
和 StillImageFormat
替换。