Initial Commit
This commit is contained in:
20
packages/media/audio/audio-codecs/src/codecs/aac.ts
Normal file
20
packages/media/audio/audio-codecs/src/codecs/aac.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { createWasmCodec } from "./wasm-base.js";
|
||||
|
||||
function aacMagic(bytes: Uint8Array): boolean {
|
||||
if (bytes.byteLength < 2) return false;
|
||||
// ADTS sync word: 0xFFFx
|
||||
return bytes[0] === 0xff && (bytes[1]! & 0xf0) === 0xf0;
|
||||
}
|
||||
|
||||
/** Lazy AAC codec backed by `@audio/decode-aac`. Decode-only. */
|
||||
export const AacCodec = createWasmCodec({
|
||||
name: "aac",
|
||||
extensions: ["aac", "m4a"],
|
||||
mimeTypes: ["audio/aac", "audio/mp4"],
|
||||
module: "@audio/decode-aac",
|
||||
magic: aacMagic,
|
||||
supportsEncode: false,
|
||||
load: () =>
|
||||
// @ts-expect-error optional dependency resolved at runtime
|
||||
import("@audio/decode-aac"),
|
||||
});
|
||||
Reference in New Issue
Block a user