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 encode() method of the VideoEncoder interface asynchronously encodes a VideoFrame. Encoded data (EncodedVideoChunk) or an error will eventually be returned via the callbacks provided to the VideoEncoder constructor.
A VideoFrame object.
options OptionalAn object containing the following members:
keyFrame OptionalA boolean, defaulting to false giving the user agent flexibility to decide if this frame should be encoded as a key frame. If true this indicates that the given frame must be encoded as a key frame.
vp9 OptionalEncode options for the VP9 codec.
quantizerFrame quantizer value 0 to 63. Only effective if VideoEncoder was configured with quantizer bitrate mode.
av1 OptionalEncode options for the AV1 codec.
quantizerFrame quantizer value 0 to 63. Only effective if VideoEncoder was configured with quantizer bitrate mode.
avc OptionalEncode options for the AVC (H.264) codec.
quantizerFrame quantizer value 0 to 51. Only effective if VideoEncoder was configured with quantizer bitrate mode.
hevc OptionalEncode options for the HEVC (H.265) codec.
quantizerFrame quantizer value 0 to 51. Only effective if VideoEncoder was configured with quantizer bitrate mode.
None (undefined).
Thrown if the state is not "configured".
DataError DOMExceptionThrown if the given frame object's rotation and flip do not match the rotation and flip of the first VideoFrame passed to encode() (the "active orientation").
In the following example encode is passed a VideoFrame, and the options parameter indicating that this frame should be considered a keyframe.
Setting per-frame QP value for encoding individual frames.
| WebCodecs # dom-videoencoder-encode |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 30, 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.