VideoFrame: copyTo() 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 copyTo() method of the VideoFrame interface copies the contents of the VideoFrame to an ArrayBuffer.
Syntax
js
copyTo(destination)
copyTo(destination, options)
Parameters
destination-
An
ArrayBuffer, aTypedArray, or aDataViewto copy to. 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:
Return value
A Promise that resolves to the layout of the copy when the copy has completed.
Examples
The following example copies the entire contents of videoFrame.
js
let buffer = new Uint8Array(videoFrame.allocationSize());
let layout = await videoFrame.copyTo(buffer);
Specifications
| Specification |
|---|
| WebCodecs # dom-videoframe-copyto |
Browser compatibility
BCD tables only load in the browser