Resize a video
You can resize a video in the browser using convertMedia() function from the @remotion/webcodecs package.
💼 Important License Disclaimer
This package is licensed under the Remotion License.
We consider a team of 4 or more people a "company".
We consider a team of 4 or more people a "company".
For "companies": A Remotion Company license needs to be obtained to use this package.
In a future version of
In a future version of
@remotion/webcodecs, this package will also require the purchase of a newly created "WebCodecs Conversion Seat". Get in touch with us if you are planning to use this package.For individuals and teams up to 3: You can use this package for free.
This is a short, non-binding explanation of our license. See the License itself for more details.
Simple Example​
Scale a video down to 480pimport {convertMedia } from '@remotion/webcodecs'; awaitconvertMedia ({src : 'https://remotion.media/BigBuckBunny.mp4',container : 'mp4',resize : {mode : 'max-height',maxHeight : 480, }, });
Resize modes​
For the resize value, you can specify the following modes:
max-height​
Scale a video down to 480pimport {ResizeOperation } from '@remotion/webcodecs'; constresize :ResizeOperation = {mode : 'max-height',maxHeight : 480, };
Scales a video down so it is at most maxHeight pixels tall.
max-width​
Scale a video down to 640 pixels wideimport {ResizeOperation } from '@remotion/webcodecs'; constresize :ResizeOperation = {mode : 'max-width',maxWidth : 640, };
Scales a video down so it is at most maxWidth pixels wide.
width​
Scale a video to 640 pixels wideimport {ResizeOperation } from '@remotion/webcodecs'; constresize :ResizeOperation = {mode : 'width',width : 640, };
Scales a video to exactly width pixels wide.
height​
Scale a video to 480 pixels tallimport {ResizeOperation } from '@remotion/webcodecs'; constresize :ResizeOperation = {mode : 'height',height : 480, };
Scales a video to exactly height pixels tall.
max-height-width​
Scale a video down to 480px height or 640 pixels widthimport {ResizeOperation } from '@remotion/webcodecs'; constresize :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​
Scale a video to 50%import {ResizeOperation } from '@remotion/webcodecs'; constresize :ResizeOperation = {mode : 'scale',scale : 0.5, };
Scales a video by a factor of scale. Factor must be greater than 0.
Order of operations​
If you apply both a rotate and a resize operation, the rotate operation will be applied first.