VideoSampleTransformOptions
Options for transforming a VideoSample. The order of operations are:
- Pixel aspect ratio normalization (always applied)
- Rotation
- Crop
- Resize using fit
type VideoSampleTransformOptions = {
width?: number;
height?: number;
roundDimensionsTo?: number;
fit?: 'fill' | 'contain' | 'cover';
rotate?: Rotation;
crop?: CropRectangle;
alpha?: 'keep' | 'discard';
};See Rotation and CropRectangle.
Used by
Properties
width
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
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
roundDimensionsTo?: number;A positive integer. When provided, both the width and height will be rounded to the nearest multiple of this number.
fit
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
rotate?: Rotation;The clockwise rotation by which to rotate the frames. Rotation is applied before resizing.
See Rotation.
crop
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 but before resizing.
See CropRectangle.
alpha
alpha?: 'discard' | 'keep';Whether to discard or keep the transparency information of the video sample. The default is 'keep'.