VideoFrame: allocationSize() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Note: This feature is available in Dedicated Web Workers.
The allocationSize() method of the VideoFrame interface returns the number of bytes required to hold the video as filtered by options passed into the method.
Syntax
allocationSize()
allocationSize(options)
Parameters
optionsOptional-
An object containing the following:
rectOptional-
The rectangle of pixels to copy from the
VideoFrame. If unspecified thevisibleRectwill be used. This is in the format of a dictionary object containing:x: The x-coordinate.y: The y-coordinate.width: The width of the frame.height: The height of the frame.
layoutOptional-
A list containing the following values for each plane in the
VideoFrame. Planes may not overlap. If unspecified the planes will be tightly packed:
Return value
An integer containing the number of bytes needed to hold the frame as specified by options.
Examples
In the following example the allocationSize is returned for the rectangle at top left with dimensions of 800 by 600.
const videoRect = {
x: 0,
y: 0,
width: 800,
height: 600,
};
let size = VideoFrame.allocationSize({ rect: videoRect });
Specifications
| Specification |
|---|
| WebCodecs # dom-videoframe-allocationsize |
Browser compatibility
BCD tables only load in the browser