Skip to content
Type

VideoSampleTransformationDescription ​

A fully-resolved description of a video sample transformation, with all defaults and constraints baked in.

The order of operations must be:

  1. Pixel aspect ratio normalization (always applied)
  2. Rotation
  3. Flip
  4. Crop
  5. Resize using fit
ts
type VideoSampleTransformationDescription = {
	width: number;
	height: number;
	fit: 'fill' | 'contain' | 'cover';
	rotation: 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.

height ​

ts
height: number;

The height in pixels to resize the frames to.

fit ​

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

The fitting algorithm.

  • '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.

rotation ​

ts
rotation: Rotation;

The clockwise rotation by which to rotate the frames. Rotation is applied before flipping.

See Rotation.

flip ​

ts
flip: boolean;

Whether to flip the frames horizontally (about the vertical axis). The flip is applied after rotation.

crop ​

ts
crop: CropRectangle;

The rectangular region of the frames to crop to, 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.

Released under the Mozilla Public License 2.0.