files/en-us/web/api/videodecoder/configure/index.md
{{APIRef("WebCodecs API")}}{{SecureContext_Header}}{{AvailableInWorkers("window_and_dedicated")}}
The configure() method of the {{domxref("VideoDecoder")}} interface enqueues a control message to configure the video decoder for decoding chunks.
configure(config)
config
codec
description {{optional_inline}}
codedWidth {{optional_inline}}
codedHeight {{optional_inline}}
displayAspectWidth {{optional_inline}}
displayAspectHeight {{optional_inline}}
colorSpace {{optional_inline}}
primaries
"bt709""bt470bg""smpte170m"transfer
"bt709""smpte170m""iec61966-2-1"matrix
"rgb""bt709""bt470bg""smpte170m"hardwareAcceleration {{optional_inline}}
"no-preference""prefer-hardware""prefer-software"optimizeForLatency {{optional_inline}}
true this is a hint that the selected decoder should be optimized to minimize the number of {{domxref("EncodedVideoChunk")}} objects that have to be decoded before a {{domxref("VideoFrame")}} is output.flip {{optional_inline}}
true, horizontal mirroring is applied. Defaults to false.rotation {{optional_inline}}
0. Arbitrary numbers (including negatives) are rounded to the next quarter turn.[!NOTE] The registrations in the WebCodecs Codec Registry link to a specification detailing whether and how to populate the optional
descriptionmember.
None ({{jsxref("undefined")}}).
config is invalid.InvalidStateError {{domxref("DOMException")}}
"closed".NotSupportedError {{domxref("DOMException")}}
config is valid but the user agent cannot provide a codec that can decode this profile.The following example creates a new {{domxref("VideoDecoder")}} and configures it with the "vp8" codec, a codedWidth of 640 pixels and a codedHeight of 480 pixels.
const init = {
output: handleFrame,
error(e) {
console.log(e.message);
},
};
const config = {
codec: "vp8",
codedWidth: 640,
codedHeight: 480,
};
let decoder = new VideoDecoder(init);
decoder.configure(config);
{{Specifications}}
{{Compat}}