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.
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.
allocationSize() allocationSize(options)
options
Optional
An object containing the following:
rect
Optional
The rectangle of pixels to copy from the VideoFrame
. If unspecified the visibleRect
will 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.layout
Optional
A list containing the following values for each plane in the VideoFrame
. Planes may not overlap. If unspecified the planes will be tightly packed:
format
Optional
A pixel format for the pixel data in the destination
. Can be set to "RGBA"
, "RGBX"
, "BGRA"
, "BGRX"
. If unspecified, the format
will be used.
colorSpace
Optional
Specifies the color space of the pixel data in the destination
. Can be set to "srgb"
for the sRGB color space or "display-p3"
for the display-p3 color space. Only applicable for RGB pixel formats. If unspecified, "srgb
will be used.
An integer containing the number of bytes needed to hold the frame as specified by options
.
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 });
Specification |
---|
WebCodecs # dom-videoframe-allocationsize |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | ||
allocationSize |
94 | 94 | previewOnly supported on Linux, see bug 1749047. |
80 | 16.4 | 94 | NoOnly supported on Linux, see bug 1749047. |
66 | 16.4 | 17.0 | 94 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/VideoFrame/allocationSize