Skip to content
Function

registerFlacEncoder

ts
registerFlacEncoder(): void;

Registers the FLAC encoder, which Mediabunny will then use automatically when applicable. Make sure to call this function before starting any encoding task. The FLAC encoder will automatically determine the output bit depth (16 or 24) based on the sample format of incoming AudioSample instances.

Preferably, wrap the call in a condition to avoid overriding any native FLAC encoder:

ts
import { canEncodeAudio } from 'mediabunny';
import { registerFlacEncoder } from '@mediabunny/flac-encoder';

if (!(await canEncodeAudio('flac'))) {
    registerFlacEncoder();
}

Released under the Mozilla Public License 2.0.