🎥 Make videos programmatically with React
Enable parallel encoding for VP8, VP9, AV1 and ProRes
Jonny Burgerc9ebf275b302
diff --git a/packages/docs/docs/cli/render.mdx b/packages/docs/docs/cli/render.mdxindex 264a7eaadb..3c414fdbcd 100644--- a/packages/docs/docs/cli/render.mdx+++ b/packages/docs/docs/cli/render.mdx@@ -172,6 +172,8 @@ For example only every second frame, every third frame and so on. Only works forDisallows the renderer from doing rendering frames and encoding at the same time. This makes the rendering process more memory-efficient, but possibly slower.+See [parallel encoding](/docs/encoding#parallel-encoding) for supported codecs and when it is enabled.+From <AvailableFrom v="4.0.533" inline />, parallel encoding is no longer disabled automatically based on the available memory. Set this flag if the machine runs out of memory while rendering.### `--number-of-gif-loops`<AvailableFrom v="3.1.0" />diff --git a/packages/docs/docs/config.mdx b/packages/docs/docs/config.mdxindex 64ea50018f..b89fd7022b 100644--- a/packages/docs/docs/config.mdx+++ b/packages/docs/docs/config.mdx@@ -558,6 +558,8 @@ The [command line flag](/docs/cli/render#--muted) `--muted` will take precedenceDisallows the renderer from doing rendering frames and encoding at the same time. This makes the rendering process more memory-efficient, but possibly slower. Default `false`.+See [parallel encoding](/docs/encoding#parallel-encoding) for supported codecs and when it is enabled.+From <AvailableFrom v="4.0.533" inline />, parallel encoding is no longer disabled automatically based on the available memory. Set this option if the machine runs out of memory while rendering.```ts twoslash title="remotion.config.ts"diff --git a/packages/docs/docs/encoding.mdx b/packages/docs/docs/encoding.mdxindex cfdb6a3f7f..29889e3d3d 100644--- a/packages/docs/docs/encoding.mdx+++ b/packages/docs/docs/encoding.mdx@@ -104,7 +104,7 @@ Remotion supports 6 video codecs: `h264` (_default_), `h265`, `vp8`, `vp9`, `av1Click on a browser compatibility link to see exactly which browsers are supported on caniuse.com.:::-* AV1 is not available on [Remotion Lambda](/docs/lambda) or Linux ARM64 GNU.+- AV1 is not available on [Remotion Lambda](/docs/lambda) or Linux ARM64 GNU.AV1 can achieve very small file sizes, but encoding is significantly slower than H.264 and H.265. Some runtimes ship only the essential codecs to stay lean, so `AV1` output is not available on Remotion Lambda or Linux ARM64 GNU.@@ -112,6 +112,14 @@ You can set a config using [`Config.setCodec()` in the config file](/docs/config[Hardware acceleration](/docs/hardware-acceleration) is available from Remotion 4.0.228.+## Parallel encoding++With parallel encoding, video frames are encoded while other frames are still being rendered. This is enabled by default for H.264 and H.265, and from <AvailableFrom v="4.0.534" inline /> for VP8, VP9, AV1 and ProRes. GIFs and audio-only renders do not use parallel encoding.++On [supported platforms](/docs/shared-memory-chromium-patch#when-it-is-used), parallel encoding also enables [shared-memory capture](/docs/shared-memory-chromium-patch), which avoids compressing frames into JPEG or PNG images before encoding the video.++The browser and FFmpeg run at the same time, which can increase peak memory usage. To render all frames before encoding, use [`--disallow-parallel-encoding`](/docs/cli/render#--disallow-parallel-encoding), set [`disallowParallelEncoding: true`](/docs/renderer/render-media#disallowparallelencoding), or call [`Config.setDisallowParallelEncoding(true)`](/docs/config#setdisallowparallelencoding).+## Controlling quality using the CRF setting_Applies only to `h264`, `h265`, `vp8`, `vp9` and `av1`._diff --git a/packages/docs/docs/renderer/render-media.mdx b/packages/docs/docs/renderer/render-media.mdxindex ba055aa2ed..0abd0492fb 100644--- a/packages/docs/docs/renderer/render-media.mdx+++ b/packages/docs/docs/renderer/render-media.mdx@@ -462,6 +462,8 @@ Before you use this hack, reach out to the Remotion team on [Discord](https://reDisallows the renderer from doing rendering frames and encoding at the same time. This makes the rendering process more memory-efficient, but possibly slower.+See [parallel encoding](/docs/encoding#parallel-encoding) for supported codecs and when it is enabled.+From <AvailableFrom v="4.0.533" inline />, parallel encoding is no longer disabled automatically based on the available memory. Set this option if the machine runs out of memory while rendering.### `mediaCacheSizeInBytes?`<AvailableFrom v="4.0.352"/>diff --git a/packages/docs/docs/shared-memory-chromium-patch.mdx b/packages/docs/docs/shared-memory-chromium-patch.mdxindex 5a807a657c..5ea3444e63 100644--- a/packages/docs/docs/shared-memory-chromium-patch.mdx+++ b/packages/docs/docs/shared-memory-chromium-patch.mdx@@ -17,8 +17,8 @@ From v4.0.534, Remotion uses a special version of Chromium to optimize renderingShared-memory capture is enabled automatically when all of these conditions are met:- You use Remotion v4.0.534 or later on one of the supported platforms below.-- You are rendering an H.264 or H.265 video, including H.264 renders on [Remotion Lambda](/docs/lambda).-- Parallel encoding is enabled: frames are rendered and encoded at the same time. This is the default for these codecs.+- You are rendering an H.264, H.265, VP8, VP9, AV1 or ProRes video. The codec must be [supported on your platform](/docs/encoding#choosing-a-codec).+- [Parallel encoding](/docs/encoding#parallel-encoding) is enabled: frames are rendered and encoded at the same time. This is the default for these codecs.| Platform | Requirements || --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |@@ -29,7 +29,7 @@ Shared-memory capture is enabled automatically when all of these conditions areThese requirements assume you use Remotion's [default browser](/docs/miscellaneous/chrome-headless-shell). On Windows, Intel Macs and older Linux systems, Remotion uses regular JPEG or PNG screenshots. Selecting [Chrome for Testing](/docs/miscellaneous/chrome-headless-shell#using-chrome-for-testing-instead) also uses regular screenshots.-Stills, image sequences and video codecs other than H.264 and H.265 continue to use screenshot capture. The patch does not apply to previews or [client-side rendering](/docs/client-side-rendering).+Stills, image sequences and GIFs continue to use screenshot capture. The patch does not apply to previews or [client-side rendering](/docs/client-side-rendering).## Image format and qualitydiff --git a/packages/docs/docs/troubleshooting/sigkill.mdx b/packages/docs/docs/troubleshooting/sigkill.mdxindex 9746fc137e..942ce8a1a6 100644--- a/packages/docs/docs/troubleshooting/sigkill.mdx+++ b/packages/docs/docs/troubleshooting/sigkill.mdx@@ -43,7 +43,7 @@ Set a lower [`concurrency`](/docs/terminology/concurrency) to open less browser## Disallow parallel encoding-H.264 and H.265 videos are encoded while frames are still being rendered, so the browser and FFmpeg need memory at the same time. Use [`--disallow-parallel-encoding`](/docs/cli/render#--disallow-parallel-encoding) or [`disallowParallelEncoding`](/docs/renderer/render-media#disallowparallelencoding) to only start encoding once all frames are rendered. This lowers the peak memory usage, but makes rendering slower.+[Parallel encoding](/docs/encoding#parallel-encoding) encodes video while frames are still being rendered, so the browser and FFmpeg need memory at the same time. It is enabled by default for H.264 and H.265, and from <AvailableFrom v="4.0.534" inline /> for VP8, VP9, AV1 and ProRes. Use [`--disallow-parallel-encoding`](/docs/cli/render#--disallow-parallel-encoding) or [`disallowParallelEncoding`](/docs/renderer/render-media#disallowparallelencoding) to only start encoding once all frames are rendered. This lowers the peak memory usage, but may make rendering slower.## Allocate more memory to your systemdiff --git a/packages/renderer/src/can-use-parallel-encoding.ts b/packages/renderer/src/can-use-parallel-encoding.tsindex 06634992ae..b2125595c9 100644--- a/packages/renderer/src/can-use-parallel-encoding.ts+++ b/packages/renderer/src/can-use-parallel-encoding.ts@@ -6,12 +6,15 @@ export const canUseParallelEncoding = (codec: Codec) => {return false;}- // h264-ts is the chunk codec for seamless H.264 renders on Lambda. Its- // pre-encoded MPEG-TS file is remuxed with the audio like the others.+ // GIF encoding uses a palette generated from the entire video.return (codec === 'h264' ||codec === 'h264-mkv' ||codec === 'h264-ts' ||- codec === 'h265'+ codec === 'h265' ||+ codec === 'vp8' ||+ codec === 'vp9' ||+ codec === 'av1' ||+ codec === 'prores');};