VideoFrame Class
A frame of video or a decoded image (https://w3c.github.io/webcodecs/#videoframe): the frames created by an ImageDecoder. Its pixels are RGBA (8 bits per sample, not premultiplied, in the sRGB color space, or Display P3 for an image whose colors are outside of sRGB); its rotation and flip are the EXIF orientation of the image. A frame can be drawn on a canvas and used by createImageBitmap(); the frames cannot be constructed by the scripts (the decoders and the encoders of audio and video are not implemented).
public sealed class VideoFrameProperties
| Name | Description |
|---|---|
| CodedHeight | Gets the height of the pixels (before the rotation). |
| CodedRect | Gets the rectangle of the pixels at (0, 0), or null when the frame is closed. |
| CodedWidth | Gets the width of the pixels (before the rotation). |
| ColorSpace | Gets the color space of the pixels. |
| DisplayHeight | Gets the height of the rendered frame (after the rotation). |
| DisplayWidth | Gets the width of the rendered frame (after the rotation). |
| Duration | Gets the presentation duration in microseconds, or null (e.g. a still image). |
| Flip | Gets whether the frame is flipped horizontally when it is rendered, after the rotation. |
| Format | Gets the format of the pixels, or null when the frame is closed. |
| Rotation | Gets the clockwise rotation in degrees applied when the frame is rendered, before the flip. |
| Timestamp | Gets the presentation timestamp in microseconds. |
| VisibleRect | Gets the rectangle of the visible pixels (all the pixels of a decoded image), or null when the frame is closed. |
CodedHeight
VideoFrame.csGets the height of the pixels (before the rotation).
public uint CodedHeight { get; }CodedRect
VideoFrame.csGets the rectangle of the pixels at (0, 0), or null when the frame is closed.
public DomRectReadOnly? CodedRect { get; }CodedWidth
VideoFrame.csGets the width of the pixels (before the rotation).
public uint CodedWidth { get; }ColorSpace
VideoFrame.csGets the color space of the pixels.
public VideoColorSpace ColorSpace { get; }DisplayHeight
VideoFrame.csGets the height of the rendered frame (after the rotation).
public uint DisplayHeight { get; }DisplayWidth
VideoFrame.csGets the width of the rendered frame (after the rotation).
public uint DisplayWidth { get; }Duration
VideoFrame.csGets the presentation duration in microseconds, or null (e.g. a still image).
public ulong? Duration { get; }Flip
VideoFrame.csGets whether the frame is flipped horizontally when it is rendered, after the rotation.
public bool Flip { get; }Format
VideoFrame.csGets the format of the pixels, or null when the frame is closed.
public VideoPixelFormat? Format { get; }Rotation
VideoFrame.csGets the clockwise rotation in degrees applied when the frame is rendered, before the flip.
public double Rotation { get; }Timestamp
VideoFrame.csGets the presentation timestamp in microseconds.
public long Timestamp { get; }VisibleRect
VideoFrame.csGets the rectangle of the visible pixels (all the pixels of a decoded image), or null when the frame is closed.
public DomRectReadOnly? VisibleRect { get; }Methods
| Name | Description |
|---|---|
| AllocationSize(VideoFrameCopyToOptions?) | Returns the number of bytes VideoFrame.CopyTo writes with the options (https://w3c.github.io/webcodecs/#dom-videoframe-allocationsize). |
| Clone() | Creates a frame that references the same pixels (https://w3c.github.io/webcodecs/#dom-videoframe-clone). |
| Close() | Releases the reference to the pixels (https://w3c.github.io/webcodecs/#close-videoframe): the frame cannot be used anymore. |
| CopyTo(Memory<byte>, VideoFrameCopyToOptions?) | Copies the pixels of the frame into a buffer (https://w3c.github.io/webcodecs/#dom-videoframe-copyto), converted to the format and the color space of the options when they are given. |
| Metadata() | Returns a copy of the metadata of the frame (https://w3c.github.io/webcodecs/#dom-videoframe-metadata). |
AllocationSize(VideoFrameCopyToOptions?)
VideoFrame.csReturns the number of bytes VideoFrame.CopyTo writes with the options (https://w3c.github.io/webcodecs/#dom-videoframe-allocationsize).
public uint AllocationSize(VideoFrameCopyToOptions? options = null)Parameters
optionsVideoFrameCopyToOptions?
Returns
Exceptions
DomException- An
InvalidStateErrorwhen the frame is closed, aNotSupportedErrorfor a format other than RGBA, RGBX, BGRA and BGRX. TypeErrorException- The rectangle or the layout is invalid.
See also
Clone()
VideoFrame.csCreates a frame that references the same pixels (https://w3c.github.io/webcodecs/#dom-videoframe-clone).
public VideoFrame Clone()Close()
VideoFrame.csReleases the reference to the pixels (https://w3c.github.io/webcodecs/#close-videoframe): the frame cannot be used anymore.
public void Close()CopyTo(Memory<byte>, VideoFrameCopyToOptions?)
VideoFrame.csCopies the pixels of the frame into a buffer (https://w3c.github.io/webcodecs/#dom-videoframe-copyto), converted to the format and the color space of the options when they are given.
public Task<IReadOnlyList<PlaneLayout>> CopyTo(Memory<byte> destination, VideoFrameCopyToOptions? options = null)Parameters
destinationMemory<byte>optionsVideoFrameCopyToOptions?
Returns
Task<IReadOnlyList<PlaneLayout>> A task that completes with the layout of the planes in the buffer (in a task of the event loop).
See also
Metadata()
VideoFrame.csReturns a copy of the metadata of the frame (https://w3c.github.io/webcodecs/#dom-videoframe-metadata).
public VideoFrameMetadata Metadata()