🎥 Make videos programmatically with React
Docs: Quality guide
Jonny Burger3571a1535e72
diff --git a/packages/docs/docs/encoding.md b/packages/docs/docs/encoding.mdxsimilarity index 67%rename from packages/docs/docs/encoding.mdrename to packages/docs/docs/encoding.mdxindex 16afb63f46..61426e1a36 100644--- a/packages/docs/docs/encoding.md+++ b/packages/docs/docs/encoding.mdx@@ -20,39 +20,65 @@ Remotion supports 5 video codecs: `h264` (_default_), `h265`, `vp8`, `vp9` and `<th>Browser compatibility</th></tr><tr>- <td>H.264 <sub>also known as MPEG-4</sub></td>+ <td>+ H.264 <sub>also known as MPEG-4</sub>+ </td><td>.mp4, .mov or .mkv</td>- <td style={{color: 'darkorange'}}>Medium</td>- <td style={{color: 'green', fontWeight: 'bold'}}>Very fast</td>- <td><a href="https://caniuse.com/mpeg4" style={{color: 'green', fontWeight: 'bold'}}>Very good</a></td>+ <td style={{ color: "darkorange" }}>Medium</td>+ <td style={{ color: "green", fontWeight: "bold" }}>Very fast</td>+ <td>+ <a+ href="https://caniuse.com/mpeg4"+ style={{ color: "green", fontWeight: "bold" }}+ >+ Very good+ </a>+ </td></tr><tr>- <td>H.265 <sub>also known as HEVC</sub></td>+ <td>+ H.265 <sub>also known as HEVC</sub>+ </td><td>.mp4 or .hevc</td>- <td style={{color: 'darkorange'}}>Medium</td>- <td style={{color: 'green'}}>Fast</td>- <td><a href="https://caniuse.com/hevc" style={{color: 'red', fontWeight: 'bold'}}>Very poor</a></td>+ <td style={{ color: "darkorange" }}>Medium</td>+ <td style={{ color: "green" }}>Fast</td>+ <td>+ <a+ href="https://caniuse.com/hevc"+ style={{ color: "red", fontWeight: "bold" }}+ >+ Very poor+ </a>+ </td></tr><tr><td>VP8</td><td>.webm</td>- <td style={{color: 'green'}}>Small</td>- <td style={{color: 'red'}}>Slow</td>- <td><a href="https://caniuse.com/webm" style={{color: 'darkorange'}}>Okay</a></td>+ <td style={{ color: "green" }}>Small</td>+ <td style={{ color: "red" }}>Slow</td>+ <td>+ <a href="https://caniuse.com/webm" style={{ color: "darkorange" }}>+ Okay+ </a>+ </td></tr><tr><td>VP9</td><td>.webm</td>- <td style={{color: 'green', fontWeight: 'bold'}}>Very small</td>- <td style={{color: 'red', fontWeight: 'bold'}}>Very slow</td>- <td><a href="https://caniuse.com/webm" style={{color: 'darkorange'}}>Okay</a></td>+ <td style={{ color: "green", fontWeight: "bold" }}>Very small</td>+ <td style={{ color: "red", fontWeight: "bold" }}>Very slow</td>+ <td>+ <a href="https://caniuse.com/webm" style={{ color: "darkorange" }}>+ Okay+ </a>+ </td></tr><tr><td>ProRes</td><td>.mov</td>- <td style={{color: 'red'}}>Large</td>- <td style={{color: 'green'}}>Fast</td>- <td style={{color: 'red', fontWeight: 'bold'}}>None</td>+ <td style={{ color: "red" }}>Large</td>+ <td style={{ color: "green" }}>Fast</td>+ <td style={{ color: "red", fontWeight: "bold" }}>None</td></tr></table>@@ -70,84 +96,48 @@ No matter which codec you end up using, there's always a tradeoff between file sBe 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:-<details style={{fontSize: '0.9em'}}>-<summary>-Changelog-</summary>-<ul>-<li>-Since version 2.1.3, Remotion doesn't allow the CRF to be set to <code>0</code> anymore because of the issues it causes on macOS/iOS and possible other scenarios. Set the CRF to 1 or higher.-</li>-</ul>+<details style={{ fontSize: "0.9em" }}>+ <summary>Changelog</summary>+ <ul>+ <li>+ Since version 2.1.3, Remotion doesn't allow the CRF to be set to{" "}+ <code>0</code> anymore because of the issues it causes on macOS/iOS and+ possible other scenarios. Set the CRF to 1 or higher.+ </li>+ </ul></details>-<div style={{height: 10}}/>+<div style={{ height: 10 }} /><table>-<tr>-<th>-Codec-</th>-<th>-Minimum - Best quality-</th>-<th>-Maximum - Best compression-</th>-<th>-Default-</th>-</tr>-<tr>-<td>-H264-</td>-<td>-1-</td>-<td>-51</td>-<td>-18-</td>-</tr>-<tr>-<td>-H265-</td>-<td>-0-</td>-<td>-51</td>-<td>-23-</td>-</tr>-<tr>-<td>-VP8-</td>-<td>-4-</td>-<td>-63</td>-<td>-9-</td>-</tr>-<tr>-<td>-VP9-</td>-<td>-0-</td>-<td>-63</td>-<td>-28-</td>-</tr>+ <tr>+ <th>Codec</th>+ <th>Minimum - Best quality</th>+ <th>Maximum - Best compression</th>+ <th>Default</th>+ </tr>+ <tr>+ <td>H264</td>+ <td>1</td>+ <td>51</td>+ <td>18</td>+ </tr>+ <tr>+ <td>H265</td>+ <td>0</td>+ <td>51</td>+ <td>23</td>+ </tr>+ <tr>+ <td>VP8</td>+ <td>4</td>+ <td>63</td>+ <td>9</td>+ </tr>+ <tr>+ <td>VP9</td>+ <td>0</td>+ <td>63</td>+ <td>28</td>+ </tr></table>You can [set a CRF in the config file using the `Config.setCrf()`](/docs/config#setcrf) function or use the [`--crf`](/docs/cli#flags) command line flag.@@ -160,15 +150,9 @@ For ProRes, there is no CRF option, but there are profiles which you can set usi<table><tr>- <th>- Value- </th>- <th>- FFmpeg setting- </th>- <th>- Bitrate- </th>+ <th>Value</th>+ <th>FFmpeg setting</th>+ <th>Bitrate</th><th><a href="/docs/transparent-videos">Supports alpha channel</a></th>@@ -241,7 +225,10 @@ Using the [`--audio-codec`](/docs/config#setaudiocodec) flag, you can set the foThe container format will be automatically derived based on the file extension.-import {SupportedAudioCodecTable, FileExtensionTable} from '../components/SupportedAudioCodec';+import {+ SupportedAudioCodecTable,+ FileExtensionTable,+} from "../components/SupportedAudioCodec";<SupportedAudioCodecTable />diff --git a/packages/docs/docs/quality.mdx b/packages/docs/docs/quality.mdxnew file mode 100644index 0000000000..a0da69e586--- /dev/null+++ b/packages/docs/docs/quality.mdx@@ -0,0 +1,81 @@+---+image: /generated/articles-docs-quality.png+id: quality+title: Quality Guide+crumb: "Codecs and more"+---++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++The main setting to control the quality of the video is the [Constant Rate Factor (CRF)](/docs/encoding/#controlling-quality-using-the-crf-setting).+All ways to render a video in Remotion allow passing a CRF value. Allowed values depend on the codec.++## 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.++Consider a 1920x1080 video, in which you render text:++```tsx twoslash+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:++```html+<video src="video.mp4" width="1920" height="1080"></video>+```++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](/docs/scaling) to render the video with a higher pixel density.++## JPEG Quality++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`](/docs/cli/render#--jpeg-quality) flag or switch to PNG as the image format using [`--image-format=png`](/docs/cli/render#--image-format) (slower).++## Color accuracy++Export your video in [`bt709`](/docs/cli/render#--color-space) for more accurate colors.++:::note+This will become the default in Remotion 5.0.+:::++## GIF Colors++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++You can use the [`--video-bitrate`](/docs/cli/render#--video-bitrate) flag to control the bitrate of the video.+It is mutually exclusive with [`--crf`](/docs/cli/render#--crf) option, which means you can not use both at the same time.++## x264 Preset++When exporting a H.264 video, you can use the [`--x264-preset`](/docs/cli/render#--x264-preset) flag to control the quality/speed/compression tradeoff.diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex d1f2196cf7..e123c53fda 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -621,6 +621,7 @@ module.exports = {"transparent-videos","render-as-gif","overlay",+ "quality","dataset-render","render-all","miscellaneous/video-formats",diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex 79e7706ffd..d49b3c7b93 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -695,7 +695,7 @@ export const articles = [{id: "encoding",title: "Encoding Guide",- relativePath: "docs/encoding.md",+ relativePath: "docs/encoding.mdx",compId: "articles-docs-encoding",crumb: "Codecs and more",},@@ -2234,6 +2234,13 @@ export const articles = [compId: "articles-docs-preview",crumb: "Timeline basics",},+ {+ id: "quality",+ title: "Quality Guide",+ relativePath: "docs/quality.mdx",+ compId: "articles-docs-quality",+ crumb: "Codecs and more",+ },{id: "random",title: "random()",diff --git a/packages/docs/static/generated/articles-docs-quality.png b/packages/docs/static/generated/articles-docs-quality.pngnew file mode 100644index 0000000000..9cdd636744Binary files /dev/null and b/packages/docs/static/generated/articles-docs-quality.png differ