Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. VideoDecoder
  4. decode()

VideoDecoder: decode() method

Limited availability

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 insecure contexts (HTTPS), in some or allsupporting browsers.

Note: This feature is available inDedicated Web Workers.

Thedecode() method of theVideoDecoder interface enqueues a control message to decode a given chunk of video.

Syntax

js
decode(chunk)

Parameters

chunk

AnEncodedVideoChunk object representing a chunk of encoded video.

Return value

None (undefined).

Exceptions

InvalidStateErrorDOMException

Thrown if thestate is notconfigured.

DataErrorDOMException

Thrown if thechunk is unable to be decoded due to relying on other frames for decoding.

Examples

The following example demonstrates how to use thedecode() method to decodeEncodedVideoChunk objects created from encoded video data.

js
const responses = await downloadVideoChunksFromServer(timestamp);for (const response of responses) {  const chunk = new EncodedVideoChunk({    timestamp: response.timestamp,    type: response.key ? "key" : "delta",    data: new Uint8Array(response.body),  });  decoder.decode(chunk);}

Specifications

Specification
WebCodecs
# dom-videodecoder-decode

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp