VideoEncoder

The VideoEncoder interface of the WebCodecs API encodes VideoFrame objects into EncodedVideoChunks. Available only in secure contexts.

MDN Reference

Constructors

Link copied to clipboard
constructor(init: VideoEncoderInit)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
external val encodeQueueSize: Int

The encodeQueueSize read-only property of the VideoEncoder interface returns the number of pending encode requests in the queue.

Link copied to clipboard
Link copied to clipboard
external val state: CodecState

The state read-only property of the VideoEncoder interface returns the current state of the underlying codec.

Functions

Link copied to clipboard
open external override fun close()

The close() method of the VideoEncoder interface ends all pending work and releases system resources.

Link copied to clipboard
external fun configure(config: VideoEncoderConfig)

The configure() method of the VideoEncoder interface changes the state of the encoder to "configured" and asynchronously prepares the encoder to accept VideoEncoders for encoding with the specified parameters. If the encoder doesn't support the specified parameters or can't be initialized for other reasons an error will be reported via the error callback provided to the VideoEncoder constructor.

Link copied to clipboard
open external fun dispatchEvent(event: Event): Boolean
Link copied to clipboard
external fun encode(frame: VideoFrame, options: VideoEncoderEncodeOptions = definedExternally)

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.

Link copied to clipboard
inline suspend fun VideoEncoder.flush()

The flush() method of the VideoEncoder interface forces all pending encodes to complete.

Link copied to clipboard
external fun flushAsync(): Promise<Void>

The flush() method of the VideoEncoder interface forces all pending encodes to complete.

Link copied to clipboard
external fun reset()

The reset() method of the VideoEncoder interface synchronously cancels all pending encodes and callbacks, frees all underlying resources and sets the state to "unconfigured". After calling reset(), configure() must be called before resuming encode() calls.

Link copied to clipboard
external fun <T : Event> when(type: EventType<T>, options: ObservableEventListenerOptions?): Observable<T>