{"_id":"@audio/decode-mp4","_rev":"4-eb154cf6aebcdff1d08c5d621e68b7ab","name":"@audio/decode-mp4","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"@audio/decode-mp4","version":"1.0.0","keywords":["mp4","mov","m4a","m4v","3gp","quicktime","isobmff","demux","video","audio","decode","decoder","aac","alac","pcm"],"author":{"name":"audiojs"},"license":"MIT","_id":"@audio/decode-mp4@1.0.0","maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"homepage":"https://github.com/audiojs/decode/tree/main/packages/decode-mp4","bugs":{"url":"https://github.com/audiojs/decode/issues"},"dist":{"shasum":"e97123fb75b75bb12ea0dbca100724b54cadad0d","tarball":"https://registry.npmjs.org/@audio/decode-mp4/-/decode-mp4-1.0.0.tgz","fileCount":7,"integrity":"sha512-xx6IgZdSIuCke8LRlGNvJ3hLo1DlVrX4wP23Zx/Plljs8AoJGKjZiZRRLLcbNSv33UsYahFjVi+HI6K9SNkCbA==","signatures":[{"sig":"MEUCIQCAdqaDMxHGk6m0NHF2ym3FeuAEWUaugKHgZjUfYDLJxQIgb0C+45jZaMvXAPa2hyxT8qrz7rVvVUdDgR8IoQLCVhs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24098},"main":"decode-mp4.js","type":"module","audio":"./audio.js","types":"decode-mp4.d.ts","engines":{"node":">=18"},"exports":{".":"./decode-mp4.js","./audio":{"types":"./audio.d.ts","default":"./audio.js"},"./package.json":"./package.json"},"funding":"https://github.com/sponsors/audiojs","gitHead":"6dbdbc0c63037395ce6574a318121a0f4682279a","scripts":{"test":"node test.js"},"_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/audiojs/decode.git","type":"git","directory":"packages/decode-mp4"},"_npmVersion":"11.12.1","description":"Decode the audio track of MP4, MOV, M4A, M4V and 3GP files (AAC, ALAC, MP3, FLAC, Opus, AMR, PCM) to PCM samples","directories":{},"sideEffects":false,"_nodeVersion":"25.9.0","dependencies":{"@audio/decode-aac":"^1.5.0","@audio/decode-amr":"^1.3.0","@audio/decode-mp3":"^1.3.0","@audio/decode-flac":"^1.3.0","@audio/decode-opus":"^1.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tst":"^9.2.2"},"_npmOperationalInternal":{"tmp":"tmp/decode-mp4_1.0.0_1787857241636_0.14934414620969783","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@audio/decode-mp4","version":"1.1.0","keywords":["mp4","mov","m4a","m4v","3gp","quicktime","isobmff","demux","video","audio","decode","decoder","aac","alac","pcm"],"author":{"name":"audiojs"},"license":"MIT","_id":"@audio/decode-mp4@1.1.0","maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"homepage":"https://github.com/audiojs/decode/tree/main/packages/decode-mp4","bugs":{"url":"https://github.com/audiojs/decode/issues"},"dist":{"shasum":"4a4d2899009df1d6aa14d01ca1d1e1ab81cf5eeb","tarball":"https://registry.npmjs.org/@audio/decode-mp4/-/decode-mp4-1.1.0.tgz","fileCount":7,"integrity":"sha512-zCopwi2ypL9JtM9PwE+r8viDbQfpcJu5Fq7rKdqhxhmsC4ZaLnjqpXwYwAYaMVaB/XAMzZXDzLJjpFuMA1FSvw==","signatures":[{"sig":"MEQCIHtzfG9zuZwKZ5scENMSfyTVu93E10pt0mDgZQwIFpDRAiB3BMymovFBgWgu5RtHw4KxagHTYoBoEdV82GlV0r9fKA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24882},"main":"decode-mp4.js","type":"module","audio":"./audio.js","types":"decode-mp4.d.ts","engines":{"node":">=18"},"exports":{".":"./decode-mp4.js","./audio":{"types":"./audio.d.ts","default":"./audio.js"},"./package.json":"./package.json"},"funding":"https://github.com/sponsors/audiojs","gitHead":"ee48dd74dd2dc5d3ed14de3757a295a1087e14dc","scripts":{"test":"node test.js"},"_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/audiojs/decode.git","type":"git","directory":"packages/decode-mp4"},"_npmVersion":"11.12.1","description":"Decode the audio track of MP4, MOV, M4A, M4V and 3GP files (AAC, ALAC, MP3, FLAC, Opus, AMR, PCM) to PCM samples","directories":{},"sideEffects":false,"_nodeVersion":"25.9.0","dependencies":{"@audio/decode-aac":"^1.5.0","@audio/decode-ac3":"^1.0.0","@audio/decode-amr":"^1.3.0","@audio/decode-dts":"^1.0.0","@audio/decode-mp3":"^1.3.0","@audio/decode-flac":"^1.3.0","@audio/decode-opus":"^1.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tst":"^9.2.2"},"_npmOperationalInternal":{"tmp":"tmp/decode-mp4_1.1.0_1787864367736_0.4847110542060993","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@audio/decode-mp4","version":"1.1.1","keywords":["mp4","mov","m4a","m4v","3gp","quicktime","isobmff","demux","video","audio","decode","decoder","aac","alac","pcm"],"author":{"name":"audiojs"},"license":"MIT","_id":"@audio/decode-mp4@1.1.1","maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"homepage":"https://github.com/audiojs/decode/tree/main/packages/decode-mp4","bugs":{"url":"https://github.com/audiojs/decode/issues"},"dist":{"shasum":"4c39c39642750335055af20ddb81dc9031dd415e","tarball":"https://registry.npmjs.org/@audio/decode-mp4/-/decode-mp4-1.1.1.tgz","fileCount":7,"integrity":"sha512-K7bAJslbTAXQd6W2t9VlePTrP5ePqIUI1kHKLXdroFRkyDmf861FYow2ICMNEo2Yh+Lyrx13vfk2pAFo6DXWFQ==","signatures":[{"sig":"MEQCIDg89xaCgsUhpwJTIjKcvzHvogIbSO6WPof7TldAg7gkAiAax3IbNji3Hv/Jmua1qgZZJIhHckqST2uds7bWXUIlng==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":25142},"main":"decode-mp4.js","type":"module","audio":"./audio.js","types":"decode-mp4.d.ts","engines":{"node":">=18"},"exports":{".":"./decode-mp4.js","./audio":{"types":"./audio.d.ts","default":"./audio.js"},"./package.json":"./package.json"},"funding":"https://github.com/sponsors/audiojs","gitHead":"c227363046dc3a0308c95ee112f22795c0ac04ca","scripts":{"test":"node test.js"},"_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"repository":{"url":"git+https://github.com/audiojs/decode.git","type":"git","directory":"packages/decode-mp4"},"_npmVersion":"11.12.1","description":"Decode the audio track of MP4, MOV, M4A, M4V and 3GP files (AAC, ALAC, MP3, FLAC, Opus, AMR, PCM) to PCM samples","directories":{},"sideEffects":false,"_nodeVersion":"25.9.0","dependencies":{"@audio/decode-aac":"^1.5.0","@audio/decode-ac3":"^1.0.0","@audio/decode-amr":"^1.3.0","@audio/decode-dts":"^1.0.0","@audio/decode-mp3":"^1.3.0","@audio/decode-eac3":"^1.0.0","@audio/decode-flac":"^1.3.0","@audio/decode-opus":"^1.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tst":"^9.2.2"},"_npmOperationalInternal":{"tmp":"tmp/decode-mp4_1.1.1_1787966903774_0.17746724497512512","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"_id":"@audio/decode-mp4@1.2.0","bugs":{"url":"https://github.com/audiojs/decode/issues"},"dist":{"shasum":"1c455dfd96842fef768509e91d54155b1ed4bcd6","tarball":"https://registry.npmjs.org/@audio/decode-mp4/-/decode-mp4-1.2.0.tgz","fileCount":7,"integrity":"sha512-/i8D/0DNxISr3JmNtofrNs1LMi2yxbw2patVHzaZSe0Kq+yNKyM7C9hHi02hbv4uCr+BgBZ37ZodwykGbQYSlw==","signatures":[{"sig":"MEYCIQCBUKK14nGlnH6nOYY6gAQaZNHiGQlnDyeTGnXhXSRVUQIhAIdd/tMi/bKCSCK7mM/6rD3dA6YlbwCKMbXL7qPQCwFk","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICcwzv375PfRudnq4qfUJOLSGkU07a9otZ/Gley4aFVWAiAR1trwu+U3ENzdcmdzY6FfwGNA4BnMzmu4UXZYpJLdUg=="}],"unpackedSize":28601},"main":"decode-mp4.js","name":"@audio/decode-mp4","type":"module","audio":"./audio.js","types":"decode-mp4.d.ts","author":{"name":"audiojs"},"engines":{"node":">=18"},"exports":{".":"./decode-mp4.js","./audio":{"types":"./audio.d.ts","default":"./audio.js"},"./package.json":"./package.json"},"funding":"https://github.com/sponsors/audiojs","gitHead":"1bc87a1f6e3cd43eeaeb658056a70cc8c69e9fbf","license":"MIT","scripts":{"test":"node test.js"},"version":"1.2.0","_npmUser":{"name":"dy","email":"df.creative@gmail.com"},"homepage":"https://github.com/audiojs/decode/tree/main/packages/decode-mp4","keywords":["mp4","mov","m4a","m4v","3gp","quicktime","isobmff","demux","video","audio","decode","decoder","aac","alac","pcm"],"repository":{"url":"git+https://github.com/audiojs/decode.git","type":"git","directory":"packages/decode-mp4"},"_npmVersion":"11.12.1","description":"Decode the audio track of MP4, MOV, M4A, M4V and 3GP files (AAC, ALAC, MP3, FLAC, Opus, AMR, PCM) to PCM samples","directories":{},"maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"sideEffects":false,"_nodeVersion":"25.9.0","dependencies":{"@audio/decode-aac":"^1.5.0","@audio/decode-ac3":"^1.0.0","@audio/decode-amr":"^1.3.0","@audio/decode-dts":"^1.0.0","@audio/decode-mp3":"^1.3.0","@audio/decode-eac3":"^1.0.0","@audio/decode-flac":"^1.3.0","@audio/decode-opus":"^1.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tst":"^9.2.2"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/decode-mp4_1.2.0_1790374770313_0.6591928820722459"}}},"time":{"created":"2026-08-27T19:00:41.471Z","modified":"2026-09-25T22:19:30.574Z","1.0.0":"2026-08-27T19:00:41.769Z","1.1.0":"2026-08-27T20:59:27.866Z","1.1.1":"2026-08-29T01:28:23.909Z","1.2.0":"2026-09-25T22:19:30.387Z"},"bugs":{"url":"https://github.com/audiojs/decode/issues"},"author":{"name":"audiojs"},"license":"MIT","homepage":"https://github.com/audiojs/decode/tree/main/packages/decode-mp4","keywords":["mp4","mov","m4a","m4v","3gp","quicktime","isobmff","demux","video","audio","decode","decoder","aac","alac","pcm"],"repository":{"url":"git+https://github.com/audiojs/decode.git","type":"git","directory":"packages/decode-mp4"},"description":"Decode the audio track of MP4, MOV, M4A, M4V and 3GP files (AAC, ALAC, MP3, FLAC, Opus, AMR, PCM) to PCM samples","maintainers":[{"name":"jamen","email":"jamenmarz@gmail.com"},{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"dy","email":"df.creative@gmail.com"}],"readme":"# @audio/decode-mp4\n\nDecode the audio track of MP4, MOV, M4A, M4V and 3GP files to PCM float samples.<br>\nA pure-JS ISO BMFF demuxer that skips the video track and routes the audio (AAC, ALAC, MP3, FLAC, Opus, AC-3, DTS, AMR, PCM) to the matching codec package, loaded on demand.\n\n[![npm install @audio/decode-mp4](https://nodei.co/npm/@audio/decode-mp4.png?mini=true)](https://npmjs.org/package/@audio/decode-mp4/)\n\n```js\nimport decode, { decoder } from '@audio/decode-mp4'\n\nlet { channelData, sampleRate } = await decode(mp4Bytes)\n\nlet dec = await decoder()\nlet head = await dec.decode(chunk1)   // Promise on the chunk that completes the track header\nlet more = dec.decode(chunk2)         // synchronous from then on\nlet tail = await dec.flush()\ndec.free()\n```\n\n## Codecs\n\n| Sample entry | Codec | Decoded by |\n|---|---|---|\n| `mp4a` (esds object type 0x40, 0x66–0x68) | AAC-LC, HE-AAC v1/v2 | [@audio/decode-aac](../decode-aac) |\n| `alac` | Apple Lossless | [@audio/decode-aac](../decode-aac) (pure JS) |\n| `mp4a` (0x69, 0x6B), `.mp3` | MP3 | [@audio/decode-mp3](../decode-mp3) |\n| `fLaC` | FLAC | [@audio/decode-flac](../decode-flac) |\n| `Opus` | Opus | [@audio/decode-opus](../decode-opus) |\n| `samr`, `sawb` | AMR-NB, AMR-WB | [@audio/decode-amr](../decode-amr) |\n| `sowt`, `twos`, `in24`, `in32`, `fl32`, `fl64`, `lpcm`, `ipcm`, `fpcm`, `raw `, `NONE` | PCM 8–32 bit int, 32/64 bit float, either endianness | built in |\n| `ulaw`, `alaw` | G.711 | built in |\n| `ac-3`, `mp4a` (0xA5) | AC-3 | [@audio/decode-ac3](../decode-ac3) |\n| `dtsc`, `dtsh`, `dtsl`, `dtse`, `mp4a` (0xA9) | DTS (core) | [@audio/decode-dts](../decode-dts) |\n| `ec-3`, `mp4a` (0xA6) | E-AC-3 (Dolby Digital Plus) | [@audio/decode-eac3](../decode-eac3) |\n\nTrueHD tracks throw an error naming the codec. Fragmented MP4 (ISO/IEC 14496-12 §8.8, `moof`+`mdat` after an empty-table `moov`) streams fragment by fragment, holding only the bytes not yet read. QuickTime sound descriptions v0, v1 and v2 are handled, including `wave`-wrapped configs and `enda` endianness flags. When `moov` follows `mdat` (typical of camera and QuickTime output) the file is buffered until the header arrives.\n\nCodec packages are imported dynamically, which is unavailable inside an AudioWorklet — decode in the main thread or a Worker.\n\n## API\n\n### `decode(src: Uint8Array | ArrayBuffer): Promise<AudioData>`\n\nDecode a complete file.\n\n### `decoder(): Promise<MP4Decoder>`\n\nStreaming decoder. `decode(chunk)` returns `AudioData`, or a Promise of it on the chunk that completes the track header while the codec module loads. `flush()` returns remaining samples and throws if no audio track was found. `free()` releases codec resources.\n\n### `AudioData`\n\n```ts\n{ channelData: Float32Array[], sampleRate: number }\n```\n\n## License\n\n[ॐ](https://github.com/krishnized/license/) · [MIT](./LICENSE). Codec packages carry their own licenses.\n","readmeFilename":"README.md"}