Skip to main content

编码指南

FFmpeg 提供支持,Remotion 允许你配置各种编码设置。本页的目的是帮助你浏览这些设置,并帮助你选择合适的设置。

🌐 Backed by FFmpeg, Remotion allows you to configure a variety of encoding settings. The goal of this page is to help you navigate through the settings and to help you choose the right one.

选择编解码器

🌐 Choosing a codec

Remotion 支持 5 种视频编解码器:h264默认)、h265vp8vp9prores。虽然 H264 在大多数情况下表现良好,但有时选择其他编解码器会更合适。请参考下表以查看每种编解码器的优缺点。

🌐 Remotion supports 5 video codecs: h264 (default), h265, vp8, vp9 and prores. While H264 will work well in most cases, sometimes it's worth going for a different codec. Refer to the table below to see the advantages and drawbacks of each codec.

视频编解码器文件扩展名文件大小编码时间浏览器兼容性是否可硬件加速

H.264 也称为MPEG-4

.mp4, .mov或.mkv中等非常快

非常好

H.265 也称为HEVC

.mp4或.hevc中等

非常差

VP8.webm

一般

VP9.webm非常小非常慢

一般

ProRes.mov在macOS上
info

点击浏览器兼容性链接以查看 caniuse.com 上支持的具体浏览器。

你可以使用配置文件中的 Config.setCodec() 设置配置,或使用 --codec 命令行标志。

🌐 You can set a config using Config.setCodec() in the config file or the --codec CLI flag.

硬件加速 从 Remotion 4.0.228 开始可用。

使用CRF设置控制质量

🌐 Controlling quality using the CRF setting

仅适用于 h264h265vp8vp9

🌐 Applies only to h264, h265, vp8 and vp9.

无论你最终使用哪种编解码器,文件大小和视频质量之间总是存在权衡。你可以通过设置所谓的 CRF(恒定速率因子)来控制。数值越低,质量越好,数值越高,文件越小——当然这是以牺牲质量为代价的。

🌐 No matter which codec you end up using, there's always a tradeoff between file size and video quality. You can control it by setting the so called CRF (Constant Rate Factor). The lower the number, the better the quality, the higher the number, the smaller the file is – of course at the cost of quality.

小心:每种编码器都有自己的可接受值范围和不同的默认值。因此,虽然 23 在 H264 视频上看起来非常好,但在 WebM 视频上看起来会很糟。使用此图表来确定使用哪个 CRF 值:

🌐 Be cautious: Every codec has it's own range of acceptable values and a different default. So while 23 will look very good on a H264 video, it will look terrible on a WebM video. Use this chart to determine which CRF value to use:

编解码器最小值 - 最佳质量最大值 - 最佳压缩默认
H26415118
H26505123
VP84639
VP906328

你可以使用 Config.setCrf() 函数在配置文件中设置 CRF,或者使用命令行标志 --crf

🌐 You can set a CRF in the config file using the Config.setCrf() function or use the --crf command line flag.

note

如果你启用硬件加速,你将无法设置crf

使用 --video-bitrate--audio-bitrate 控制质量

🌐 Controlling quality using --video-bitrate and --audio-bitrate

使用以下选项设置视频和音频比特率:

🌐 Use the following options to set the video and audio bitrate:

此选项与其他质量选项不兼容。

🌐 This option is incompatible with other quality options.

使用 ProRes 配置文件控制质量

🌐 Controlling quality using ProRes profile

仅适用于 prores 编解码器

🌐 Applies only to prores codec.

对于 ProRes,没有 CRF 选项,但可以使用 --prores-profile 标志setProResProfile 配置文件选项设置配置文件。

🌐 For ProRes, there is no CRF option, but there are profiles which you can set using the --prores-profile flag or the setProResProfile config file option.

FFmpeg 设置比特率支持 alpha 通道
"proxy"0~45Mbps
"light"1~102Mbps

"standard"(默认)

2~147Mbps
"hq"3~220Mbps
"4444"4~330Mbps
"4444-xq"4~500Mbps

更高的比特率意味着更高的质量和更大的文件大小。

🌐 Higher bitrate means higher quality and higher file size.

仅音频导出

🌐 Audio-only export

你可以将 mp3wavaac 作为编解码器传入。如果你这样做,将会输出对应格式的音频文件。质量设置将被忽略。

🌐 You can pass mp3, wav or aac as a codec. If you do it, an audio file will be output in the corresponding format. Quality settings will be ignored.

动图

🌐 GIFs

你也可以将你的视频导出为 GIF

🌐 You can also render your video as a GIF.

音频编解码器

🌐 Audio codec

从 v3.3.42 起可用

🌐 available from v3.3.42

使用 --audio-codec 标志,你可以设置嵌入视频中的音频格式。并非所有编解码器和音频编解码器组合都受支持,某些组合需要特定的文件扩展名和容器格式。

🌐 Using the --audio-codec flag, you can set the format of the audio that is embedded in the video. Not all codec and audio codec combinations are supported and certain combinations require a certain file extension and container format.

容器格式将根据文件扩展名自动推导。

🌐 The container format will be automatically derived based on the file extension.

Video codecDefaultSupported audio codecsPossible file extensions
h264aac.mp4 (default), .mkv , .mov
pcm-16.mkv (default), .mov
mp3.mp4 (default), .mkv , .mov
h264-tspcm-16.ts (default)
aac.ts (default)
aacaac.aac (default), .3gp , .m4a , .m4b , .mpg , .mpeg
pcm-16.wav (default)
h265aac.mp4 (default), .mkv , .hevc
pcm-16.mkv (default)
mp3mp3.mp3 (default)
pcm-16.wav (default)
prores *aac.mov (default), .mkv , .mxf
pcm-16.mov (default), .mkv , .mxf
vp8opus.webm (default)
pcm-16.mkv (default)
vp9opus.webm (default)
pcm-16.mkv (default)
wavpcm-16.wav (default)

GIF不支持音频。

🌐 GIFs don't support audio.

  • 注意:在 v4.0.0 之前的版本中,ProRes 的默认音频编解码器是 aac。现在是 pcm-16

文件扩展名

🌐 File extensions

在渲染媒体时指定文件扩展名将决定默认编解码器。只要上表中的组合受支持,你可以使用 --codec 覆盖编解码器。

🌐 Specifying a file extension when rendering media will determine the default codec. You may override the codec using --codec as long as the combination is supported in the table above.

File extensionDefault codec
.3gpaac
.aacaac
.gifgif
.hevch265
.m4aaac
.m4baac
.mkvh264-mkv
.movprores
.mp3mp3
.mp4h264
.mpegaac
.mpgaac
.mxfprores
.wavwav
.webmvp8
.tsh264-ts

你还需要其他哪些设置?

🌐 What other settings do you need?

FFmpeg 支持的众多选项中,你希望在 Remotion 中看到哪些被公开?请通过在我们的问题追踪器上提交问题让我们知道!

🌐 Which of the dozens of options that FFmpeg supports would you like to see exposed in Remotion? Let us know by opening an issue on our issue tracker!

另请参阅

🌐 See also