Get to know MDN better
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Dedicated Web Workers.
The VideoEncoder() constructor creates a new VideoEncoder object with the provided options.output callback assigned as the output callback, the provided options.error callback as the error callback, and sets the VideoEncoder.state to "unconfigured".
An object containing two required callbacks.
outputA callback which takes an EncodedVideoChunk object as the first argument, and an optional metadata object as the second. The metadata object has three members:
decoderConfig OptionalAn object containing:
codecA string containing a valid codec string.
description OptionalAn ArrayBuffer, a TypedArray, or a DataView containing a sequence of codec-specific bytes, commonly known as "extradata".
codedWidth OptionalAn integer representing the width of the VideoFrame in pixels, potentially including non-visible padding, and prior to considering potential ratio adjustments.
codedHeight OptionalAn integer representing the height of the VideoFrame in pixels, potentially including non-visible padding, and prior to considering potential ratio adjustments.
displayAspectWidth OptionalAn integer representing the horizontal dimension of the VideoFrame's aspect ratio when displayed.
displayAspectHeight OptionalAn integer representing the vertical dimension of the VideoFrame's aspect ratio when displayed.
colorSpace OptionalAn object you pass to the VideoColorSpace constructor as the init argument, configuring the VideoFrame.colorSpace for VideoFrames associated with this decoderConfig object. If colorSpace exists, the provided values will override any in-band values from the bitstream.
hardwareAcceleration OptionalA string that configures hardware acceleration for this codec. Defaults to "no-preference". Options are:
A boolean representing whether the selected decoder should be configured to minimize the number of EncodedVideoChunks that have to be decoded before a VideoFrame is output.
svc OptionalAn optional object with only one member: temporalLayerId, which is a number that identifies the temporal layer for the associated EncodedVideoChunk.
alphaSideData OptionalAn ArrayBuffer, a TypedArray, or a DataView that contains the EncodedVideoChunk's extra alpha channel data.
errorA callback which takes an Error object as its only argument.
In the following example a VideoEncoder is created with the two required callback functions, one to deal with the encoded frame and the other to handle errors.
| WebCodecs # dom-videoencoder-videoencoder |
Enable JavaScript to view this browser compatibility table.
This page was last modified on May 28, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.