🎥 Make videos programmatically with React
`@remotion/effects`: Address review feedback
Jonny Burgerf5c5be380364
diff --git a/bun.lock b/bun.lockindex 38bc42c694..46760501b1 100644--- a/bun.lock+++ b/bun.lock@@ -435,6 +435,7 @@"@remotion/cloudrun": "workspace:*","@remotion/design": "workspace:*","@remotion/docusaurus-plugin": "workspace:*",+ "@remotion/effects": "workspace:*","@remotion/elevenlabs": "workspace:*","@remotion/enable-scss": "workspace:*","@remotion/eslint-config-internal": "workspace:*",diff --git a/packages/docs/docs/effects/blur.mdx b/packages/docs/docs/effects/blur.mdxindex 16c46582e1..5a402ea37c 100644--- a/packages/docs/docs/effects/blur.mdx+++ b/packages/docs/docs/effects/blur.mdx@@ -16,16 +16,15 @@ Applies a separable Gaussian blur to a canvas-backed component using WebGL2.## Example```tsx twoslash title="MyComp.tsx"-import {AbsoluteFill, Solid} from 'remotion';+import {AbsoluteFill} from 'remotion';+import {Video} from '@remotion/media';import {blur} from '@remotion/effects/blur';export const MyComp: React.FC = () => {return (<AbsoluteFill>- <Solid- color="#3344ff"- width={1920}- height={1080}+ <Video+ src="https://remotion.media/video.mp4"effects={[blur({radius: 8})]}/></AbsoluteFill>@@ -33,12 +32,6 @@ export const MyComp: React.FC = () => {};```-You can also import from the package root:--```tsx-import {blur} from '@remotion/effects';-```-## APIPass an object with the following properties.@@ -63,20 +56,7 @@ effects={[blur({radius: 8, horizontal: true, vertical: false})]}### `disabled?`-When `true`, the effect is skipped. Defaults to `false`. This field is added automatically for all effects and can be toggled in the Remotion Studio timeline.--## Usage--Add the effect to the `effects` prop of a component that supports canvas effects, for example [`<Solid>`](/docs/solid), [`<Img>`](/docs/img), [`<Video>`](/docs/video), or [`<HtmlInCanvas>`](/docs/remotion/html-in-canvas).--```tsx-<Solid- color="red"- width={400}- height={400}- effects={[blur({radius: 12}), blur({radius: 4, horizontal: false})]}-/>-```+When `true`, the effect is skipped. Defaults to `false`.## Requirementsdiff --git a/packages/docs/docs/effects/index.mdx b/packages/docs/docs/effects/index.mdxindex d83c852912..f786d38d99 100644--- a/packages/docs/docs/effects/index.mdx+++ b/packages/docs/docs/effects/index.mdx@@ -7,7 +7,7 @@ title: '@remotion/effects'# @remotion/effects<AvailableFrom v="4.0.464" />-Built-in [canvas effects](/docs/html-in-canvas) for Remotion components such as [`<Solid>`](/docs/solid), [`<Img>`](/docs/img), and [`<Video>`](/docs/video).+Effects that can be applied to Remotion-based canvas components such as [`<Solid>`](/docs/solid), [`<Img>`](/docs/img), and [`<Video>`](/docs/video).import {TableOfContents} from './table-of-contents';diff --git a/packages/docs/docs/effects/table-of-contents.tsx b/packages/docs/docs/effects/table-of-contents.tsxindex 00f13a0625..571fcd14fd 100644--- a/packages/docs/docs/effects/table-of-contents.tsx+++ b/packages/docs/docs/effects/table-of-contents.tsx@@ -2,13 +2,38 @@ import React from 'react';import {Grid} from '../../components/TableOfContents/Grid';import {TOCItem} from '../../components/TableOfContents/TOCItem';+const row: React.CSSProperties = {+ display: 'flex',+ flexDirection: 'row',+ justifyContent: 'space-between',+};++const previewImage: React.CSSProperties = {+ width: 180,+ height: 120,+ objectFit: 'cover',+ borderRadius: 4,+ flexShrink: 0,+};+export const TableOfContents: React.FC = () => {return (<div><Grid><TOCItem link="/docs/effects/blur">- <strong>{'blur()'}</strong>- <div>Gaussian blur for canvas components</div>+ <div style={row}>+ <img+ src="/img/effects-blur-preview.jpg"+ alt="blur effect preview"+ style={previewImage}+ />+ <div style={{flex: 1, marginLeft: 10}}>+ <strong>+ <code>{'blur()'}</code>+ </strong>+ <div>Gaussian blur for canvas components</div>+ </div>+ </div></TOCItem></Grid></div>diff --git a/packages/docs/package.json b/packages/docs/package.jsonindex 2e77a8fc8a..af90af904f 100644--- a/packages/docs/package.json+++ b/packages/docs/package.json@@ -43,6 +43,7 @@"@remotion/cloudrun": "workspace:*","@remotion/design": "workspace:*","@remotion/docusaurus-plugin": "workspace:*",+ "@remotion/effects": "workspace:*","@remotion/elevenlabs": "workspace:*","@remotion/enable-scss": "workspace:*","@remotion/eslint-config-internal": "workspace:*",diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.tsindex 11c0401f05..3c3bd464e2 100644--- a/packages/docs/sidebars.ts+++ b/packages/docs/sidebars.ts@@ -259,15 +259,6 @@ const sidebars: SidebarsConfig = {'cloudrun/testpermissions',],},- {- type: 'category',- label: '@remotion/enable-scss',- link: {- type: 'doc',- id: 'enable-scss/overview',- },- items: ['enable-scss/enable-scss'],- },{type: 'category',label: '@remotion/effects',@@ -286,6 +277,15 @@ const sidebars: SidebarsConfig = {},items: ['elevenlabs/elevenlabs-transcript-to-captions'],},+ {+ type: 'category',+ label: '@remotion/enable-scss',+ link: {+ type: 'doc',+ id: 'enable-scss/overview',+ },+ items: ['enable-scss/enable-scss'],+ },{type: 'category',label: '@remotion/fonts',diff --git a/packages/docs/static/img/effects-blur-preview.jpg b/packages/docs/static/img/effects-blur-preview.jpgnew file mode 100644index 0000000000..b39f795752Binary files /dev/null and b/packages/docs/static/img/effects-blur-preview.jpg differdiff --git a/packages/docs/tsconfig.json b/packages/docs/tsconfig.jsonindex fc10fc5a08..602d0be9bb 100644--- a/packages/docs/tsconfig.json+++ b/packages/docs/tsconfig.json@@ -27,6 +27,7 @@{"path": "../core"},{"path": "../media-utils"},{"path": "../docusaurus-plugin"},+ {"path": "../effects"},{"path": "../babel-loader"},{"path": "../cloudrun"},{"path": "../create-video"},diff --git a/packages/effects/README.md b/packages/effects/README.mdindex 31aecf3b88..794e9df4f8 100644--- a/packages/effects/README.md+++ b/packages/effects/README.md@@ -1,14 +1,14 @@# @remotion/effects-Built-in effects for Remotion canvas components.+Effects that can be applied to Remotion-based canvas components.## Usage```tsx+import {Video} from '@remotion/media';import {blur} from '@remotion/effects/blur';-import {Solid} from 'remotion';-<Solid color="red" width={400} height={400} effects={[blur({radius: 8})]} />;+<Video src="https://remotion.media/video.mp4" effects={[blur({radius: 8})]} />;```See the [documentation](https://www.remotion.dev/docs/effects/api).diff --git a/packages/effects/package.json b/packages/effects/package.jsonindex 4b7899a502..3e266340c8 100644--- a/packages/effects/package.json+++ b/packages/effects/package.json@@ -1,7 +1,7 @@{"name": "@remotion/effects","version": "4.0.464",- "description": "Built-in effects for Remotion canvas components",+ "description": "Effects that can be applied to Remotion-based canvas components","main": "dist/index.js","types": "dist/index.d.ts","module": "dist/esm/index.mjs",@@ -39,7 +39,14 @@},"./package.json": "./package.json"},- "homepage": "https://www.remotion.dev/docs/effects",+ "typesVersions": {+ ">=1.0": {+ "blur": [+ "dist/blur.d.ts"+ ]+ }+ },+ "homepage": "https://www.remotion.dev/docs/effects/api","devDependencies": {"@remotion/eslint-config-internal": "workspace:*","eslint": "catalog:",diff --git a/packages/effects/src/blur/blur-runtime.ts b/packages/effects/src/blur/blur-runtime.tsindex db0634b711..170b3afc08 100644--- a/packages/effects/src/blur/blur-runtime.ts+++ b/packages/effects/src/blur/blur-runtime.ts@@ -332,6 +332,8 @@ export const applyBlur = ({gl.clearColor(0, 0, 0, 0);if (!horizontal && !vertical) {+ // Passthrough: relies on the `uRadius <= 0.0` early-out in+ // `blur-shaders.ts` to forward the source texture unchanged.gl.bindFramebuffer(gl.FRAMEBUFFER, null);gl.clear(gl.COLOR_BUFFER_BIT);gl.activeTexture(gl.TEXTURE0);diff --git a/packages/effects/src/blur/index.ts b/packages/effects/src/blur/index.tsindex bbd04e3da0..f9c70ac992 100644--- a/packages/effects/src/blur/index.ts+++ b/packages/effects/src/blur/index.ts@@ -40,17 +40,17 @@ const blurSchema = {max: 100,step: 1,default: undefined,- description: 'Blur radius',+ description: 'Blur',},horizontal: {type: 'boolean',default: true,- description: 'Blur horizontally',+ description: 'Horizontal',},vertical: {type: 'boolean',default: true,- description: 'Blur vertically',+ description: 'Vertical',},} as const satisfies SequenceSchema;diff --git a/packages/effects/src/index.ts b/packages/effects/src/index.tsindex aaf9b952f3..57abd00fc7 100644--- a/packages/effects/src/index.ts+++ b/packages/effects/src/index.ts@@ -1,4 +1,3 @@-export {blur, type BlurParams} from './blur/index.js';export {EffectInternals} from './effect-internals.js';export {halftoneSchema, type HalftoneParams} from './halftone.js';export {tintSchema, type TintParams} from './tint.js';diff --git a/packages/effects/src/test/effect-params.test.ts b/packages/effects/src/test/effect-params.test.tsindex de1dec8740..00d8065682 100644--- a/packages/effects/src/test/effect-params.test.ts+++ b/packages/effects/src/test/effect-params.test.ts@@ -39,3 +39,18 @@ test('blur() accepts both axes disabled', () => {blur({radius: 4, horizontal: false, vertical: false}),).not.toThrow();});++test('blur() axis flags produce distinct effect keys', () => {+ const both = blur({radius: 4});+ const horizontalOnly = blur({radius: 4, vertical: false});+ const verticalOnly = blur({radius: 4, horizontal: false});+ const neither = blur({radius: 4, horizontal: false, vertical: false});++ const keys = [+ both.effectKey,+ horizontalOnly.effectKey,+ verticalOnly.effectKey,+ neither.effectKey,+ ];+ expect(new Set(keys).size).toBe(keys.length);+});diff --git a/packages/studio-shared/src/package-info.ts b/packages/studio-shared/src/package-info.tsindex b31e30fda1..1d7937b9f1 100644--- a/packages/studio-shared/src/package-info.ts+++ b/packages/studio-shared/src/package-info.ts@@ -227,7 +227,7 @@ export const descriptions: {[key in Pkgs]: string | null} = {starburst: 'Starburst ray effect for Remotion',vercel: 'Render Remotion videos on Vercel Sandbox',sfx: 'Sound effect library',- effects: 'Experimental presets for Remotion canvas effect hooks',+ effects: 'Effects that can be applied to Remotion-based canvas components',};export const installableMap: {[key in Pkgs]: boolean} = {'svg-3d-engine': false,@@ -425,5 +425,5 @@ export const apiDocs: {[key in Pkgs]: string | null} = {starburst: 'https://www.remotion.dev/docs/starburst',vercel: 'https://www.remotion.dev/docs/vercel/api',sfx: 'https://www.remotion.dev/docs/sfx',- effects: null,+ effects: 'https://www.remotion.dev/docs/effects/api',};