Skip to content
Type

VideoSampleTransformOptions ​

Options for transforming a VideoSample. The order of operations are:

  1. Pixel aspect ratio normalization (always applied)
  2. Rotation
  3. Flip
  4. Crop
  5. Resize using fit
ts
type VideoSampleTransformOptions = {
	width?: number;
	height?: number;
	roundDimensionsTo?: number;
	fit?: 'fill' | 'contain' | 'cover';
	rotate?: Rotation;
	flip?: boolean;
	crop?: CropRectangle;
	alpha?: 'keep' | 'discard';
};

See Rotation and CropRectangle.

Used by ​

Properties ​

width ​

ts
width?: number;

The width in pixels to resize the frames to. If height is not set, it will be deduced automatically based on aspect ratio.

height ​

ts
height?: number;

The height in pixels to resize the frames to. If width is not set, it will be deduced automatically based on aspect ratio.

roundDimensionsTo ​

ts
roundDimensionsTo?: number;

A positive integer. When provided, both the width and height will be rounded to the nearest multiple of this number.

fit ​

ts
fit?: 'fill' | 'contain' | 'cover';

The fitting algorithm in case both width and height are set.

  • 'fill' will stretch the image to fill the entire box, potentially altering aspect ratio.
  • 'contain' will contain the entire image within the box while preserving aspect ratio. This may lead to letterboxing.
  • 'cover' will scale the image until the entire box is filled, while preserving aspect ratio.

rotate ​

ts
rotate?: Rotation;

The clockwise rotation by which to rotate the frames, in addition to the sample's own rotation. Rotation is applied before flipping.

See Rotation.

flip ​

ts
flip?: boolean;

Whether to flip the frames horizontally (about the vertical axis), in addition to the sample's own flip. The flip is applied after rotation but before cropping and resizing.

crop ​

ts
crop?: CropRectangle;

Specifies the rectangular region of the frames to crop to. The crop region will automatically be clamped to the dimensions of the frame. Cropping is performed after rotation and flip but before resizing.

See CropRectangle.

alpha ​

ts
alpha?: 'keep' | 'discard';

Whether to discard or keep the transparency information of the video sample. The default is 'keep'.

Released under the Mozilla Public License 2.0.