Skip to main content

EncodedVideoChunk

The EncodedVideoChunk class represents a single chunk of encoded video data. Each chunk is either a keyframe (can be decoded independently) or a delta frame (requires previous frames to decode).

Quick Example


Constructor

Creates a new EncodedVideoChunk from initialization data.
init
EncodedVideoChunkInit
required
Configuration object for the encoded chunk.
The type must be exactly 'key' or 'delta'. Any other value will throw a TypeError.

Properties

All properties are readonly after construction.
type
'key' | 'delta'
required
The chunk type indicating whether this is a keyframe or delta frame.
  • 'key' - Keyframe (I-frame) that can be decoded without any other frames
  • 'delta' - Delta frame (P/B-frame) that requires previous frames
timestamp
number
required
Presentation timestamp in microseconds. Determines when this frame should be displayed relative to the start of the video.
duration
number | null
required
Duration of this frame in microseconds, or null if not specified during construction.
byteLength
number
required
Size of the encoded data in bytes. Use this to allocate a buffer for copyTo().

Methods

copyTo()

Copies the encoded video data to a destination buffer.
destination
BufferSource
required
An ArrayBuffer or TypedArray to copy the data into. Must have at least byteLength bytes available.
Throws: TypeError if the destination buffer is smaller than byteLength.

Type Definitions

EncodedVideoChunkType

EncodedVideoChunkInit


Usage with VideoEncoder

EncodedVideoChunk objects are typically created by VideoEncoder and passed to your output callback:

Usage with VideoDecoder

Pass EncodedVideoChunk objects to VideoDecoder.decode():

See Also

EncodedAudioChunk

The audio equivalent for encoded audio data

VideoEncoder

Encodes VideoFrames into EncodedVideoChunks

VideoDecoder

Decodes EncodedVideoChunks into VideoFrames

VideoFrame

Raw video frame data