VideoEncoder Class
Encodes video (https://w3c.github.io/webcodecs/#videoencoder-interface): the VideoFrame objects given to VideoEncoder.Encode are encoded by the codecs of BrowsingContextOptions.MediaCodecs, and the EncodedVideoChunk objects are given to the output callback with the configuration of their decoder.
public sealed class VideoEncoder : EventTarget- Inheritance
EventTargetVideoEncoder
Constructors
| Name | Description |
|---|---|
| VideoEncoder(VideoEncoderInit) | Creates an encoder (https://w3c.github.io/webcodecs/#dom-videoencoder-videoencoder). |
VideoEncoder(VideoEncoderInit)
Codecs.csCreates an encoder (https://w3c.github.io/webcodecs/#dom-videoencoder-videoencoder).
public VideoEncoder(VideoEncoderInit init)Properties
| Name | Description |
|---|---|
| EncodeQueueSize | Gets the number of pending encode requests. |
| OnDequeue | Gets or sets the event handler of the dequeue event (the queue size decreased). |
| State | Gets the state of the encoder. |
EncodeQueueSize
Codecs.csGets the number of pending encode requests.
public uint EncodeQueueSize { get; }OnDequeue
Codecs.csGets or sets the event handler of the dequeue event (the queue size decreased).
State
Codecs.csGets the state of the encoder.
public CodecState State { get; }Methods
| Name | Description |
|---|---|
| Close() | Closes the encoder (https://w3c.github.io/webcodecs/#dom-videoencoder-close). |
| Configure(VideoEncoderConfig) | Configures the encoder (https://w3c.github.io/webcodecs/#dom-videoencoder-configure): a configuration that the codecs do not support closes it with a NotSupportedError. |
| Encode(VideoFrame, VideoEncoderEncodeOptions?) | Encodes a frame (https://w3c.github.io/webcodecs/#dom-videoencoder-encode): a clone of the frame is encoded. |
| Flush() | Encodes the pending frames (https://w3c.github.io/webcodecs/#dom-videoencoder-flush): the promise resolves once the chunks are delivered. |
| IsConfigSupported(VideoEncoderConfig) | Returns whether the codecs support a configuration (https://w3c.github.io/webcodecs/#dom-videoencoder-isconfigsupported). |
| Reset() | Discards the pending frames and the configuration (https://w3c.github.io/webcodecs/#dom-videoencoder-reset). |
Close()
Codecs.csCloses the encoder (https://w3c.github.io/webcodecs/#dom-videoencoder-close).
public void Close()Configure(VideoEncoderConfig)
Codecs.csConfigures the encoder (https://w3c.github.io/webcodecs/#dom-videoencoder-configure): a configuration that the codecs do not support closes it with a NotSupportedError.
public void Configure(VideoEncoderConfig config)Parameters
configVideoEncoderConfig- The configuration.
Exceptions
TypeErrorException- The configuration is invalid.
DomException- An
InvalidStateErrorwhen the encoder is closed.
See also
Encode(VideoFrame, VideoEncoderEncodeOptions?)
Codecs.csEncodes a frame (https://w3c.github.io/webcodecs/#dom-videoencoder-encode): a clone of the frame is encoded.
public void Encode(VideoFrame frame, VideoEncoderEncodeOptions? options = null)Parameters
frameVideoFrame- The frame.
optionsVideoEncoderEncodeOptions?- The options of the encoding of the frame.
Exceptions
TypeErrorException- The frame is closed.
DomException- An
InvalidStateErrorwhen the encoder is not configured, aDataErrorwhen the orientation of the frame is not the one of the first frame.
See also
Flush()
Codecs.csEncodes the pending frames (https://w3c.github.io/webcodecs/#dom-videoencoder-flush): the promise resolves once the chunks are delivered.
public Task Flush()IsConfigSupported(VideoEncoderConfig)
Codecs.csReturns whether the codecs support a configuration (https://w3c.github.io/webcodecs/#dom-videoencoder-isconfigsupported).
public static Task<VideoEncoderSupport> IsConfigSupported(VideoEncoderConfig config)Parameters
configVideoEncoderConfig- The configuration.
Returns
Task<VideoEncoderSupport> A task that completes with the support and the configuration with the recognized members, or fails with a TypeErrorException for an invalid configuration.
See also
Reset()
Codecs.csDiscards the pending frames and the configuration (https://w3c.github.io/webcodecs/#dom-videoencoder-reset).
public void Reset()