Skip to content
Abstract class

VideoSampleResource

Abstract base class for custom video sample resources. Implement this class to provide custom backing for VideoSample instances.

Subclasses

Used by

Methods

close()

ts
close(): void;

Closes this resource, releasing held resources. Called automatically when the last VideoSample using this resource is closed.

getCodedHeight()

ts
getCodedHeight(): number;

Returns the height of the frame in pixels.

getCodedWidth()

ts
getCodedWidth(): number;

Returns the width of the frame in pixels.

getColorSpace()

ts
getColorSpace(): VideoSampleColorSpace;

Returns the color space of the frame.

See VideoSampleColorSpace.

getDataPlanes()

ts
getDataPlanes(): MaybePromise<VideoDataPlane[]>;

Returns the data planes that hold the video data for this sample. The returned planes and data must be in the format returned by getFormat().

See MaybePromise and VideoDataPlane.

getFormat()

ts
getFormat(): "I420" | "I420P10" | "I420P12" | "I420A" | "I420AP10" | "I420AP12" | "I422" | "I422P10" | "I422P12" | "I422A" | "I422AP10" | "I422AP12" | "I444" | "I444P10" | "I444P12" | "I444A" | ... 7 more ... | null;

Returns the internal pixel format in which the frame is stored. See pixel formats

getSquarePixelHeight()

ts
getSquarePixelHeight(): number;

Returns the height of the frame in square pixels, respecting pixel aspect ratio.

getSquarePixelWidth()

ts
getSquarePixelWidth(): number;

Returns the width of the frame in square pixels, respecting pixel aspect ratio.

toRgbSample()

ts
toRgbSample(
	init: SetRequired<VideoSampleInit, 'timestamp'>,
	colorSpace: PredefinedColorSpace,
): MaybePromise<VideoSample>;

Returns a new RGB VideoSample that contains the same content as this sample. The provided init object must be used to set the metadata of this new video sample. When converting from a non-RGB format to RGB, the conversion must respect colorSpace.

See SetRequired, VideoSampleInit, and MaybePromise.

Released under the Mozilla Public License 2.0.