🎥 Make videos programmatically with React
document resize modes
Jonny Burger9ef468e42a07
diff --git a/packages/docs/docs/webcodecs/convert-media.mdx b/packages/docs/docs/webcodecs/convert-media.mdxindex 340eea3b95..299518ca20 100644--- a/packages/docs/docs/webcodecs/convert-media.mdx+++ b/packages/docs/docs/webcodecs/convert-media.mdx@@ -77,6 +77,12 @@ _number_The number of degrees to rotate the video. See [Rotate a video](/docs/webcodecs/rotate-a-video) for more information.+### `resize?`++_object_ <TsType type="ResizeOperation" source="@remotion/webcodecs"/>++Resize the video. See [Resize a video](/docs/webcodecs/resize-a-video) for more information.+### `apiKey?`If you are a customer of a [Remotion Company License](https://remotion.pro/license), you can provide an API key from your dashboard to track your conversions.diff --git a/packages/docs/docs/webcodecs/resizing.mdx b/packages/docs/docs/webcodecs/resizing.mdxindex f949c08d35..e68f812035 100644--- a/packages/docs/docs/webcodecs/resizing.mdx+++ b/packages/docs/docs/webcodecs/resizing.mdx@@ -5,7 +5,7 @@ slug: /webcodecs/resize-a-videocrumb: '@remotion/webcodecs'----You can resize a video in the browser using the [`@remotion/webcodecs`](/docs/webcodecs) package.+You can resize a video in the browser using [`convertMedia()`](/docs/webcodecs/convert-media) function from the [`@remotion/webcodecs`](/docs/webcodecs) package.import {LicenseDisclaimer} from './LicenseDisclaimer';import {UnstableDisclaimer} from './UnstableDisclaimer';@@ -37,6 +37,90 @@ await convertMedia({});```+## Resize modes++For the [`resize`](/docs/webcodecs/convert-media#resize) value, you can specify the following modes:++### `max-height`++```tsx twoslash title="Scale a video down to 480p"+import {ResizeOperation} from '@remotion/webcodecs';++const resize: ResizeOperation = {+ mode: 'max-height',+ maxHeight: 480,+};+```++Scales a video down so it is at most `maxHeight` pixels tall.++### `max-width`++```tsx twoslash title="Scale a video down to 640 pixels wide"+import {ResizeOperation} from '@remotion/webcodecs';++const resize: ResizeOperation = {+ mode: 'max-width',+ maxWidth: 640,+};+```++Scales a video down so it is at most `maxWidth` pixels wide.++### `width`++```tsx twoslash title="Scale a video to 640 pixels wide"+import {ResizeOperation} from '@remotion/webcodecs';++const resize: ResizeOperation = {+ mode: 'width',+ width: 640,+};+```++Scales a video to exactly `width` pixels wide.++### `height`++```tsx twoslash title="Scale a video to 480 pixels tall"+import {ResizeOperation} from '@remotion/webcodecs';++const resize: ResizeOperation = {+ mode: 'height',+ height: 480,+};+```++Scales a video to exactly `height` pixels tall.++### `max-height-width`++```tsx twoslash title="Scale a video down to 480px height or 640 pixels width"+import {ResizeOperation} from '@remotion/webcodecs';++const resize: ResizeOperation = {+ mode: 'max-height-width',+ maxHeight: 480,+ maxWidth: 640,+};+```++Scales a video down so it is at most `maxHeight` pixels tall or `maxWidth` pixels wide.+The video will be scaled down to the biggest size that fits both constraints.++### `scale`++```tsx twoslash title="Scale a video to 50%"+import {ResizeOperation} from '@remotion/webcodecs';++const resize: ResizeOperation = {+ mode: 'scale',+ scale: 0.5,+};+```++Scales a video by a factor of `scale`. Factor must be greater than `0`.+## Order of operationsIf you apply both a [`rotate`](/docs/webcodecs/rotate-a-video) and a `resize` operation, the `rotate` operation will be applied first.