AudioEncodingConfig
Configuration object that controls audio encoding. Can be used to set codec, quality, and more.
type AudioEncodingConfig = {
codec: AudioCodec;
quality?: Quality;
bitrate?: number | Quality;
transform?: AudioTransformOptions;
onEncodedPacket?: (packet: EncodedPacket, meta: EncodedAudioChunkMetadata | undefined) => unknown;
onEncoderConfig?: (config: AudioEncoderConfig) => unknown;
onEncodedSample?: (sample: AudioSample) => unknown;
} & AudioEncodingAdditionalOptions;See AudioCodec, Quality, AudioTransformOptions, EncodedPacket, AudioSample, and AudioEncodingAdditionalOptions.
Used by
Properties
codec
codec: AudioCodec;The audio codec that should be used for encoding the audio samples.
See AudioCodec.
quality
quality?: Quality;The desired quality of the encoded audio. Required for compressed audio codecs, unused for PCM codecs.
See Quality.
bitrate
bitrate?: number | Quality;The target bitrate for the encoded audio, in bits per second. Alternatively, a Quality can be provided.
See Quality.
transform
transform?: AudioTransformOptions;Optional transformations to apply to the audio samples before they are passed to the encoder.
bitrateMode
bitrateMode?: 'constant' | 'variable';Configures the bitrate mode. A bitrate mode set directly on a Quality takes precedence over this field.
fullCodecString
fullCodecString?: string;The full codec string as specified in the Mediabunny Codec Registry. This string must match the codec specified in codec. When not set, a fitting codec string will be constructed automatically by the library.
Events
onEncodedPacket
onEncodedPacket?: (packet: EncodedPacket, meta: EncodedAudioChunkMetadata | undefined) => unknown;Called for each successfully encoded packet. Both the packet and the encoding metadata are passed.
See EncodedPacket.
onEncoderConfig
onEncoderConfig?: (config: AudioEncoderConfig) => unknown;Called when the internal encoder config, as used by the WebCodecs API, is created.
onEncodedSample
onEncodedSample?: (sample: AudioSample) => unknown;Called right before a sample is passed to the encoder.
See AudioSample.