Skip to content
Abstract class

CustomVideoDecoder

Base class for custom video decoders. To add your own custom video decoder, extend this class, implement the abstract methods and static supports method, and register the decoder using registerDecoder.

Used by

Static methods

supports()

ts
static supports(
	codec: VideoCodec,
	config: VideoDecoderConfig,
): boolean;

Returns true if and only if the decoder can decode the given codec configuration.

See VideoCodec.

Properties

codec

ts
readonly codec: VideoCodec;

The input video's codec.

See VideoCodec.

config

ts
readonly config: VideoDecoderConfig;

The input video's decoder config.

Events

onSample

ts
readonly onSample: (sample: VideoSample) => unknown;

The callback to call when a decoded VideoSample is available.

See VideoSample.

Methods

init()

ts
init(): MaybePromise<void>;

Called after decoder creation; can be used for custom initialization logic.

See MaybePromise.

decode()

ts
decode(
	packet: EncodedPacket,
): MaybePromise<void>;

Decodes the provided encoded packet.

See EncodedPacket and MaybePromise.

flush()

ts
flush(): MaybePromise<void>;

Decodes all remaining packets and then resolves.

See MaybePromise.

close()

ts
close(): MaybePromise<void>;

Called when the decoder is no longer needed and its resources can be freed.

See MaybePromise.

Released under the Mozilla Public License 2.0.