/** * Optional WebCodecs acceleration — `audiobox/webcodecs`. * * ## Why this is optional, and only an accelerator * * WebCodecs gives browsers hardware-accelerated access to codecs the platform * already ships — notably Opus and AAC, which audiobox does not implement. It * is tempting to build a library on top of it. That does not work for an * isomorphic package: **Node has no WebCodecs.** `AudioEncoder`, `AudioDecoder`, * and `AudioData` are all undefined there (verified on Node 23; still absent in * 24 and 25), and the popular "webcodecs for Node" packages are native FFmpeg * bindings — which would mean a dependency, and a heavy one. * * So the pure-TypeScript path is the real implementation everywhere, and this * module is a bonus that lights up when the host provides it. Everything here * feature-detects and degrades; nothing in core imports it. * * Codec availability also varies by browser and cannot be assumed — always check * {@link isCodecSupported} rather than trusting a support matrix. */ import { Audio } from '../audio.js'; /** True when this runtime exposes the WebCodecs audio interfaces at all. */ export declare function isWebCodecsAvailable(): boolean; /** * Asks the platform whether it can encode a given codec configuration. * * Returns `false` rather than throwing when WebCodecs is missing entirely, so * this can be used directly as a feature check. */ export declare function isCodecSupported(codec: string, sampleRate?: number, numberOfChannels?: number): Promise; /** Codec strings worth probing, in rough order of usefulness. */ export declare const COMMON_CODECS: Readonly<{ /** Opus in a WebM container — the best-supported lossy option on the web. */ opus: "opus"; /** AAC-LC. Widely supported for playback; encode support varies. */ aac: "mp4a.40.2"; /** FLAC via the platform, when you would rather not ship our encoder. */ flac: "flac"; /** G.711 companding, for telephony pipelines. */ alaw: "alaw"; ulaw: "ulaw"; }>; export interface WebCodecsEncodeOptions { /** Codec string, e.g. `'opus'`. See {@link COMMON_CODECS}. */ codec: string; /** Target bitrate in bits per second. */ bitrate?: number; /** Frames per encoded chunk. Defaults to 1024. */ chunkFrames?: number; } /** * Encodes audio using the platform's own codec implementation. * * Returns the raw encoded chunks. They are **not** wrapped in a container — a * WebM or MP4 muxer is a separate concern, and pretending otherwise would * produce files that do not play. * * @throws {UnsupportedRuntimeError} when WebCodecs or the codec is unavailable. */ export declare function encodeWithWebCodecs(audio: Audio, options: WebCodecsEncodeOptions): Promise<{ chunks: Uint8Array[]; totalBytes: number; }>;