Skip to main content

质量指南

视频编码涉及对视频数据进行大幅压缩以减小文件大小,这是一种有损过程。 本文档解释了可以用来控制视频质量的一些因素和设置。

🌐 Video encoding involves heavily compressing the video data to reduce the file size, which is a lossy process.
This document explains a few factors and settings that can be used to control the quality of the video.

病例报告表

🌐 CRF

控制视频质量的主要设置是 恒定速率因子 (CRF)
在 Remotion 中渲染视频的所有方式都允许传递 CRF 值。允许的值取决于编解码器。

🌐 The main setting to control the quality of the video is the Constant Rate Factor (CRF).
All ways to render a video in Remotion allow passing a CRF value. Allowed values depend on the codec.

note

如果启用硬件加速,则无法设置 crf。请改用--video-bitrate选项。

分辨率(文字不清晰)

🌐 Resolution (Unsharp text)

一种有些令人惊讶的质量损失方式是,许多电脑拥有高密度显示屏,但视频的尺寸并未考虑到这一点。

🌐 A somewhat surprising way to lose quality is the fact that many computers have a high-density display, but the dimensions of a video don't consider that.

考虑一个1920x1080的视频,在其中你渲染文本:

🌐 Consider a 1920x1080 video, in which you render text:

import { Composition } from "remotion";

const MyComponent = () => {
  return <div>Hello World</div>;
};

const Root: React.FC = () => {
  return (
    <Composition
      width={1920}
      height={1080}
      fps={30}
      durationInFrames={100}
      component={MyComponent}
      id="MyComp"
    />
  );
};

如果你渲染它并将视频嵌入网页:

🌐 If you render it out and embed the video on a webpage:

<video src="video.mp4" width="1920" height="1080"></video>

如果视频在高密度显示屏(如 Macbook)上显示,你看到的文字会不那么清晰。
这是因为设备有 2 倍的像素密度,而视频是 1920x1080,这意味着每个像素比设备的像素大 2 倍。
要在高密度显示屏上显示与低密度显示屏上相同清晰度的字体,你需要渲染一个 4K 视频。

🌐 You will have a less sharp text if the video is displayed on a high-density display (like a Macbook).
This is because the device has a 2x pixel density, but the video is 1920x1080, which means that each pixel is 2x bigger than the device's pixel.
To display the font with the same sharpness as on a low-density display, you would need to render a 4K video.

使用 输出缩放 以更高像素密度渲染视频。

🌐 Use Output Scaling to render the video with a higher pixel density.

JPEG质量

🌐 JPEG Quality

Remotion 默认以 JPEG 格式截取浏览器页面的屏幕截图。 默认的 JPEG 质量是 80(在 0 到 100 的范围内)。 你可以使用 --jpeg-quality 标志进行调整,或者使用 --image-format=png 切换为 PNG 格式(速度较慢)。

🌐 Remotion makes screenshots of the browser page by default in JPEG format.
The JPEG quality by default is 80 (on a scale of 0 to 100).
You may tweak it using the --jpeg-quality flag or switch to PNG as the image format using --image-format=png (slower).

颜色准确性

🌐 Color accuracy

将你的视频导出为 bt709 以获得更准确的颜色。

🌐 Export your video in bt709 for more accurate colors.

note

这将在 Remotion 5.0 中成为默认设置。

GIF 颜色

🌐 GIF Colors

确保你使用的 Remotion 版本至少为 v4.0.138,以获得最佳的颜色准确性。 GIF 仅支持 256 色调色板,这会导致较大的画质损失。要么接受它,要么如果不能接受,请选择其他格式。

🌐 Ensure you are on at least Remotion version v4.0.138 to get the best color accuracy.
GIFs only support a 256 colors palette, which leads to a big quality loss. Embrace it, or choose a different format if it is not acceptable.

视频比特率

🌐 Video bitrate

你可以使用 --video-bitrate 标志来控制视频的比特率。 它与 --crf 选项互斥,这意味着你不能同时使用两者。

🌐 You can use the --video-bitrate flag to control the bitrate of the video.
It is mutually exclusive with --crf option, which means you can not use both at the same time.

x264 预设

🌐 x264 Preset

在导出 H.264 视频时,你可以使用 --x264-preset 标志来控制质量/速度/压缩的权衡。

🌐 When exporting a H.264 video, you can use the --x264-preset flag to control the quality/speed/compression tradeoff.