Skip to content

🎥 Make videos programmatically with React

Lead motion blur docs with HTML-in-canvas

JonnyBurger5dac3b471008
diff --git a/packages/docs/docs/motion-blur-guide.mdx b/packages/docs/docs/motion-blur-guide.mdx
index e05470e046..5e469a57a7 100644
--- a/packages/docs/docs/motion-blur-guide.mdx
+++ b/packages/docs/docs/motion-blur-guide.mdx
@@ -7,25 +7,27 @@ crumb: 'Designing visuals'
# Motion blur
-Motion blur shows where an object moved during a frame. [`@remotion/motion-blur`](/docs/motion-blur) offers three ways to make it, from a visible trail to a sampled exposure.
+Motion blur shows where an object moved during a frame. For the best result, start with [`<HtmlInCanvasMotionBlur>`](/docs/motion-blur/html-in-canvas-motion-blur) when you can preview in Chrome with HTML-in-canvas enabled. [`@remotion/motion-blur`](/docs/motion-blur) also offers two effects that work in regular browsers.
<Installation pkg="@remotion/motion-blur" />
| Component | Appearance | Preview |
| -------------------------------------------------------------------------- | ----------------------------------------------- | ----------------------- |
-| [`<Trail>`](/docs/motion-blur/trail) | Echoes of earlier positions | No special setup |
-| [`<CameraMotionBlur>`](/docs/motion-blur/camera-motion-blur) | Blended layers across part of a frame | No special setup |
| [`<HtmlInCanvasMotionBlur>`](/docs/motion-blur/html-in-canvas-motion-blur) | Captured pixels averaged across part of a frame | Chrome 149+ with a flag |
+| [`<CameraMotionBlur>`](/docs/motion-blur/camera-motion-blur) | Blended layers across part of a frame | No special setup |
+| [`<Trail>`](/docs/motion-blur/trail) | Echoes of earlier positions | No special setup |
Animate the content inside the component with [`useCurrentFrame()`](/docs/use-current-frame). The component samples that animation at different times within a frame. See the [common mistake](/docs/motion-blur/common-mistake) if the blur does not follow your animation.
-## Trail
+## HTML-in-canvas motion blur<AvailableFrom v="4.0.528" />
-[`<Trail>`](/docs/motion-blur/trail) repeats earlier positions behind the current one. Choose it for a stylized echo or a long streak. It does not aim to reproduce a camera exposure.
+[`<HtmlInCanvasMotionBlur>`](/docs/motion-blur/html-in-canvas-motion-blur) captures the HTML at multiple fractional frames and averages the pixels in a canvas. This is the state of the art for motion blur in Remotion: it preserves the appearance of the sampled content better than stacking translucent DOM copies.
-<Demo type="motion-blur-trail" />
+<Demo type="motion-blur-html-in-canvas" />
-Set `layers`, `lagInFrames`, and `trailOpacity` to control the number, spacing, and visibility of the echoes.
+Live preview requires Chrome 149 or later with `chrome://flags/#canvas-draw-element` enabled. See the [HTML-in-canvas setup](/docs/html-in-canvas#enabling-the-flag-in-chrome). Other browsers show a rendered video of the demo. Remotion's bundled Chrome supports rendering without manual flag setup. [Nested HTML-in-canvas components](/docs/html-in-canvas#nested-html-in-canvas) are not supported yet.
+
+Set `width` and `height` to the canvas size, `shutterAngle` to the exposure length, and `samples` to the smoothness. See the [component reference](/docs/motion-blur/html-in-canvas-motion-blur) for defaults and ranges.
## Camera motion blur
@@ -35,15 +37,13 @@ Set `layers`, `lagInFrames`, and `trailOpacity` to control the number, spacing,
Set `shutterAngle` to control the exposure length and `samples` to control smoothness.
-## HTML-in-canvas motion blur<AvailableFrom v="4.0.528" />
-
-[`<HtmlInCanvasMotionBlur>`](/docs/motion-blur/html-in-canvas-motion-blur) captures the HTML at multiple fractional frames and averages the pixels in a canvas. This is the state of the art for motion blur in Remotion: it preserves the appearance of the sampled content better than stacking translucent DOM copies.
+## Trail
-<Demo type="motion-blur-html-in-canvas" />
+[`<Trail>`](/docs/motion-blur/trail) repeats earlier positions behind the current one. Choose it for a stylized echo or a long streak. It does not aim to reproduce a camera exposure.
-Live preview requires Chrome 149 or later with `chrome://flags/#canvas-draw-element` enabled. See the [HTML-in-canvas setup](/docs/html-in-canvas#enabling-the-flag-in-chrome). Other browsers show a rendered video of the demo. Remotion's bundled Chrome supports rendering without manual flag setup. [Nested HTML-in-canvas components](/docs/html-in-canvas#nested-html-in-canvas) are not supported yet.
+<Demo type="motion-blur-trail" />
-Set `width` and `height` to the canvas size. Like the camera variant, `shutterAngle` controls exposure length and `samples` controls smoothness. See the [component reference](/docs/motion-blur/html-in-canvas-motion-blur) for defaults and ranges.
+Set `layers`, `lagInFrames`, and `trailOpacity` to control the number, spacing, and visibility of the echoes.
## See also
diff --git a/packages/docs/docs/motion-blur/table-of-contents.tsx b/packages/docs/docs/motion-blur/table-of-contents.tsx
index 5ca775d6ab..e8536a6ec8 100644
--- a/packages/docs/docs/motion-blur/table-of-contents.tsx
+++ b/packages/docs/docs/motion-blur/table-of-contents.tsx
@@ -6,17 +6,17 @@ export const TableOfContents: React.FC = () => {
return (
<div>
<Grid>
- <TOCItem link="/docs/motion-blur/trail">
- <strong>{'<Trail>'}</strong>
- <div>Add a trail effect to children</div>
+ <TOCItem link="/docs/motion-blur/html-in-canvas-motion-blur">
+ <strong>{'<HtmlInCanvasMotionBlur>'}</strong>
+ <div>Sample HTML across a frame for the best motion blur result</div>
</TOCItem>
<TOCItem link="/docs/motion-blur/camera-motion-blur">
<strong>{'<CameraMotionBlur>'}</strong>
<div>Add a natural camera motion blur effect to children</div>
</TOCItem>
- <TOCItem link="/docs/motion-blur/html-in-canvas-motion-blur">
- <strong>{'<HtmlInCanvasMotionBlur>'}</strong>
- <div>Sample HTML across a frame for motion blur</div>
+ <TOCItem link="/docs/motion-blur/trail">
+ <strong>{'<Trail>'}</strong>
+ <div>Add a trail effect to children</div>
</TOCItem>
</Grid>
</div>
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index 99302eced4..c4663fc1c9 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -563,9 +563,9 @@ const sidebars: SidebarsConfig = {
id: 'motion-blur/index',
},
items: [
- 'motion-blur/trail',
- 'motion-blur/camera-motion-blur',
'motion-blur/html-in-canvas-motion-blur',
+ 'motion-blur/camera-motion-blur',
+ 'motion-blur/trail',
'motion-blur/common-mistake',
],
},
diff --git a/packages/skills/skills/remotion-markup/motion-blur.md b/packages/skills/skills/remotion-markup/motion-blur.md
index b233930931..7a54ba58f2 100644
--- a/packages/skills/skills/remotion-markup/motion-blur.md
+++ b/packages/skills/skills/remotion-markup/motion-blur.md
@@ -6,21 +6,21 @@ Use `@remotion/motion-blur` for frame-driven motion blur. Install it with `npx r
| Component | Use when | Tradeoff |
| -------------------------- | ----------------------------------------------------- | ------------------------------------------------ |
-| `<Trail>` | You want visible echoes or a stylized streak | It is a trail, not a camera exposure |
+| `<HtmlInCanvasMotionBlur>` | You want the best result from sampled HTML pixels | Experimental Chrome support; more work per frame |
| `<CameraMotionBlur>` | You need camera-like blur in regular browser previews | Translucent layers can change colors and opacity |
-| `<HtmlInCanvasMotionBlur>` | You want the most faithful sampled HTML blur | Experimental Chrome support; more work per frame |
+| `<Trail>` | You want visible echoes or a stylized streak | It is a trail, not a camera exposure |
`<HtmlInCanvasMotionBlur>` is the state of the art in Remotion for blurring animated HTML. It captures the content at fractional frames and averages its pixels in a canvas. Prefer it when the preview browser supports HTML-in-canvas; use `<CameraMotionBlur>` when broader browser preview support matters.
All three components render multiple versions of their children at different times. Put the animation and its `useCurrentFrame()` call **inside** the blur component. Do not calculate the animated position in a parent and pass an already computed style into it. Use frame-driven animation, not CSS `animation` or `transition`.
-## `<Trail>`
+## `<HtmlInCanvasMotionBlur>`
-`layers` is the number of past copies, `lagInFrames` is the delay between copies and `trailOpacity` controls their strength. Absolutely position the content so copies do not affect each other's layout.
+Available from Remotion 4.0.528. Supply the canvas `width` and `height`, usually from `useVideoConfig()`. `shutterAngle` defaults to `180` and accepts `0` to `360`; `0` disables blur. `samples` defaults to `8` and must be an integer from `1` to `64`. More samples can smooth the blur but increase preview and render cost.
```tsx
-import {Trail} from '@remotion/motion-blur';
-import {useCurrentFrame} from 'remotion';
+import {HtmlInCanvasMotionBlur} from '@remotion/motion-blur';
+import {useCurrentFrame, useVideoConfig} from 'remotion';
const MovingBox = () => {
const frame = useCurrentFrame();
@@ -38,13 +38,19 @@ const MovingBox = () => {
);
};
-export const MyComposition = () => (
- <Trail layers={12} lagInFrames={0.15} trailOpacity={0.8}>
- <MovingBox />
- </Trail>
-);
+export const HtmlInCanvasBlur = () => {
+ const {width, height} = useVideoConfig();
+
+ return (
+ <HtmlInCanvasMotionBlur width={width} height={height} samples={8} shutterAngle={180}>
+ <MovingBox />
+ </HtmlInCanvasMotionBlur>
+ );
+};
```
+For live preview, use Chrome 149 or later and enable `chrome://flags/#canvas-draw-element`. Remotion's bundled Chrome enables the feature during rendering. Do not nest this component with another `<HtmlInCanvas>` component; nested HTML-in-canvas is unsupported. Tell the user about the preview requirement when choosing this variant.
+
The next examples reuse `MovingBox` from above.
## `<CameraMotionBlur>`
@@ -61,25 +67,18 @@ export const CameraBlur = () => (
);
```
-## `<HtmlInCanvasMotionBlur>`
+## `<Trail>`
-Available from Remotion 4.0.528. Supply the canvas `width` and `height`, usually from `useVideoConfig()`. `shutterAngle` defaults to `180` and accepts `0` to `360`; `0` disables blur. `samples` defaults to `8` and must be an integer from `1` to `64`. More samples can smooth the blur but increase preview and render cost.
+`layers` is the number of past copies, `lagInFrames` is the delay between copies and `trailOpacity` controls their strength. Absolutely position the content so copies do not affect each other's layout.
```tsx
-import {HtmlInCanvasMotionBlur} from '@remotion/motion-blur';
-import {useVideoConfig} from 'remotion';
-
-export const HtmlInCanvasBlur = () => {
- const {width, height} = useVideoConfig();
+import {Trail} from '@remotion/motion-blur';
- return (
- <HtmlInCanvasMotionBlur width={width} height={height} samples={8} shutterAngle={180}>
- <MovingBox />
- </HtmlInCanvasMotionBlur>
- );
-};
+export const MyComposition = () => (
+ <Trail layers={12} lagInFrames={0.15} trailOpacity={0.8}>
+ <MovingBox />
+ </Trail>
+);
```
-For live preview, use Chrome 149 or later and enable `chrome://flags/#canvas-draw-element`. Remotion's bundled Chrome enables the feature during rendering. Do not nest this component with another `<HtmlInCanvas>` component; nested HTML-in-canvas is unsupported. Tell the user about the preview requirement when choosing this variant.
-
See the [motion blur guide](https://www.remotion.dev/docs/motion-blur-guide) and the [`<HtmlInCanvasMotionBlur>` reference](https://www.remotion.dev/docs/motion-blur/html-in-canvas-motion-blur).