Skip to content

🎥 Make videos programmatically with React

Docs: Dealing with HDR

JonnyBurgerb8568e2f9d11
diff --git a/packages/docs/docs/contributing/docs.mdx b/packages/docs/docs/contributing/docs.mdx
index 9e44831b84..a10deae7ff 100644
--- a/packages/docs/docs/contributing/docs.mdx
+++ b/packages/docs/docs/contributing/docs.mdx
@@ -21,7 +21,7 @@ At the bottom of each page, the `Improve this page` button is the easiest way to
<Step>2</Step> Create a new <code>.mdx</code> document in the <code>packages/docs/docs</code> folder. <br/>
<Step>3</Step> Add the document to <code>packages/docs/sidebars.ts</code>.<br/>
<Step>4</Step> Write what you have to say!<br/>
-<Step>5</Step> Run <code>node render-cards.mjs</code> in <code>packages/docs</code> to generate preview cards that will show up if the documentation page is shared on social media.<br/>
+<Step>5</Step> Run <code>bun render-cards.ts</code> in <code>packages/docs</code> to generate preview cards that will show up if the documentation page is shared on social media.<br/>
## Language guidelines
diff --git a/packages/docs/docs/hdr.mdx b/packages/docs/docs/hdr.mdx
new file mode 100644
index 0000000000..c1fff2dc55
--- /dev/null
+++ b/packages/docs/docs/hdr.mdx
@@ -0,0 +1,50 @@
+---
+image: /generated/articles-docs-hdr.png
+title: High Dynamic Range and Remotion
+sidebar_label: HDR
+id: hdr
+crumb: 'How to deal with HDR'
+---
+
+High Dynamic Range (HDR) is a feature that allows for a wider range of colors and brightnesses than standard dynamic range (SDR).
+
+Remotion uses a headless Chrome browser to render, which does not support HDR.
+Frames are always rendered in sRGB, which is standard dynamic range.
+
+## Embedding HDR videos
+
+If a HDR video is embedded in your composition, it must be converted to SDR. This is a process which is inherently lossy and a slight color lost is unavoidable.
+
+### In `<Video />` and `<Html5Video />`
+
+In [`<Video />`](/docs/media/video) and [`<Html5Video />`](/docs/html5-video), color conversion is handled by the browser.
+However, the `--gl` flag is relevant and may influence the colors.
+
+Tip: **Setting the `--gl=angle` will result in much better colors when embedding an HDR video (tested on macOS).**
+We have not yet experimented with this enough to give a recommendation on which `--gl` flag to use.
+The Remotion team is keen to hear your experiences.
+
+### In `<OffthreadVideo />`
+
+By default, color conversion is applied automatically to HDR videos.
+Remotion tries to use FFmpeg and the `zscale` library to preserve the colors as well as possible when converting the video to SDR.
+
+There is no configuration, but it is possible to disable this feature:
+
+```tsx twoslash title="Disabling color conversion"
+import {OffthreadVideo} from 'remotion';
+
+export const MyComp = () => {
+ return <OffthreadVideo src="https://example.com/hdr.mp4" toneMapped={false} />;
+};
+```
+
+## Outputting HDR videos
+
+Because all frames are rendered in SDR, **it doesn't make sense to output an HDR video with Remotion.**
+
+It is better to accept the loss and output an SDR video, rather than trying to convert the frames to HDR again, which would lead to more loss.
+
+That being said, there is an option [`--color-space`](/docs/lambda/cli/render#--color-space) which can be set to `bt2020-ncl` or `bt2020-cl` to output an HDR video.
+**This was a mistake and is not recommended.**
+This option will lead to the video being tagged as being HDR, but the content inside the video is not actually HDR. You will experience the picture to be overly bright and overexposed.
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index a70f0ae491..a9e2e7167c 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -902,6 +902,7 @@ const sidebars: SidebarsConfig = {
'artifacts',
'metadata',
'hardware-acceleration',
+ 'hdr',
],
},
{
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index e986881410..cce3a94913 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -1763,6 +1763,15 @@ export const articles = [
noAi: false,
slug: 'hardware-acceleration',
},
+ {
+ id: 'hdr',
+ title: 'High Dynamic Range and Remotion',
+ relativePath: 'docs/hdr.mdx',
+ compId: 'articles-docs-hdr',
+ crumb: 'How to deal with HDR',
+ noAi: false,
+ slug: 'hdr',
+ },
{
id: 'props-resolution',
title: 'How props get resolved',
diff --git a/packages/docs/static/generated/articles-docs-hdr.png b/packages/docs/static/generated/articles-docs-hdr.png
new file mode 100644
index 0000000000..1d322cf126
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-hdr.png differ