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 configure() method of the VideoEncoder interface changes the state of the encoder to "configured" and asynchronously prepares the encoder to accept VideoEncoders for encoding with the specified parameters. If the encoder doesn't support the specified parameters or can't be initialized for other reasons an error will be reported via the error callback provided to the VideoEncoder constructor.
If the VideoEncoder has been previously configured, the new configuration will not be applied until all previous tasks have completed.
configure(config)
configA dictionary object containing the following members:
codecA string containing a valid codec string. See "codecs" parameter for details on codec string construction.
width OptionalAn integer representing the width of each output EncodedVideoChunk in pixels, before any ratio adjustments.
height OptionalAn integer representing the height of each output EncodedVideoChunk in pixels, before any ratio adjustments.
displayWidth OptionalAn integer representing the intended display width of each output EncodedVideoChunk in pixels when displayed.
displayHeight OptionalAn integer representing the vertical dimension of each output EncodedVideoChunk in pixels when displayed.
hardwareAccelerationA hint that configures the hardware acceleration method of this codec. One of:
"no-preference""prefer-hardware""prefer-software"bitrateAn integer containing the average bitrate of the encoded video in units of bits per second.
framerateAn integer containing the expected frame rate in frames per second.
alphaA string indicating whether the alpha component of the VideoFrame inputs should be kept or discarded prior to encoding. One of:
"discard" (default)"keep"scalabilityModeA string containing an encoding scalability mode identifier as defined in WebRTC.
bitrateMode OptionalA string containing a bitrate mode. One of:
"constant"The encoder will target constant bitrate.
"variable" (default)The encoder will target a variable bitrate, allowing more space to be used for complex signals and less space for less complex signals.
"quantizer"The encoder will disregard the bitrate option and instead it will use codec-specific quantizer values specified for each frame in the options parameter to VideoEncoder.encode().
latencyMode OptionalA string containing a value that configures the latency behavior of this codec. One of:
"quality" (default)The encoder should optimize for encoding quality.
"realtime"The encoder should optimize for low latency and may even drop frames to honor framerate.
None (undefined).
TypeErrorThrown if the provided config is invalid.
InvalidStateError DOMException
Thrown if the state is "closed".
NotSupportedError DOMException
Thrown if the provided config is valid but the user agent cannot provide a codec that can decode this profile.
The following example creates a new VideoEncoder and configures it with some of the available options.
const init = {
output: handleChunk,
error(e) {
console.log(e.message);
},
};
let config = {
codec: "vp8",
width: 640,
height: 480,
bitrate: 2_000_000, // 2 Mbps
framerate: 30,
};
let encoder = new VideoEncoder(init);
encoder.configure(config);
| Specification |
|---|
| WebCodecs> # dom-videoencoder-configure> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
configure |
94 | 94 | 130 | 80 | 16.4 | 94 | No | 66 | 16.4 | 17.0 | 94 | 16.4 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/VideoEncoder/configure