CustomVideoEncoder
Base class for custom video encoders. To add your own custom video encoder, extend this class, implement the abstract methods and static supports
method, and register the encoder using registerEncoder
.
Used by
Static methods
supports()
static supports(
codec: VideoCodec,
config: VideoEncoderConfig,
): boolean;
Returns true if and only if the encoder can encode the given codec configuration.
See VideoCodec
.
Properties
codec
readonly codec: VideoCodec;
The codec with which to encode the video.
See VideoCodec
.
config
readonly config: VideoEncoderConfig;
Config for the encoder.
Events
onPacket
readonly onPacket: (packet: EncodedPacket, meta?: EncodedVideoChunkMetadata) => unknown;
The callback to call when an EncodedPacket is available.
See EncodedPacket
.
Methods
init()
init(): MaybePromise<void>;
Called after encoder creation; can be used for custom initialization logic.
See MaybePromise
.
encode()
encode(
videoSample: VideoSample,
options: VideoEncoderEncodeOptions,
): MaybePromise<void>;
Encodes the provided video sample.
See VideoSample
and MaybePromise
.
flush()
flush(): MaybePromise<void>;
Encodes all remaining video samples and then resolves.
See MaybePromise
.
close()
close(): MaybePromise<void>;
Called when the encoder is no longer needed and its resources can be freed.
See MaybePromise
.