VideoEncoder.VideoEncoder()

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The VideoEncoder() constructor creates a new VideoEncoder object with the provided init.output callback assigned as the output callback, the provided init.error callback as the error callback, and the VideoEncoder.state set to "unconfigured".

Syntax

new VideoEncoder(init);

Parameters

init

An object containing two required callbacks.

output

A callback which takes a VideoFrame object as its only argument.

error

A callback which takes an Error object as its only argument.

Examples

In the following example a VideoEncoder is created with the two required callback functions, one to deal with the decoded frame and the other to handle errors.

const videoEncoder = new VideoEncoder({
  output: processVideo,
  error: onEncoderError,
});

Specifications

Specification
WebCodecs
# dom-videoencoder-videoencoder

Browser compatibility

BCD tables only load in the browser