@audio/decode-mp4 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/decode-mp4.js +5 -3
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -31,8 +31,9 @@ dec.free()
|
|
|
31
31
|
| `ulaw`, `alaw` | G.711 | built in |
|
|
32
32
|
| `ac-3`, `mp4a` (0xA5) | AC-3 | [@audio/decode-ac3](../decode-ac3) |
|
|
33
33
|
| `dtsc`, `dtsh`, `dtsl`, `dtse`, `mp4a` (0xA9) | DTS (core) | [@audio/decode-dts](../decode-dts) |
|
|
34
|
+
| `ec-3`, `mp4a` (0xA6) | E-AC-3 (Dolby Digital Plus) | [@audio/decode-eac3](../decode-eac3) |
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
TrueHD tracks throw an error naming the codec. Fragmented MP4 (`moof`) is not supported. 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.
|
|
36
37
|
|
|
37
38
|
Codec packages are imported dynamically, which is unavailable inside an AudioWorklet — decode in the main thread or a Worker.
|
|
38
39
|
|
package/decode-mp4.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MP4 / MOV / M4A / M4V / 3GP audio decoder — ISO BMFF demuxer that routes the audio track to a codec:
|
|
3
3
|
* AAC, ALAC → @audio/decode-aac · MP3 → @audio/decode-mp3 · FLAC → @audio/decode-flac
|
|
4
|
-
* Opus → @audio/decode-opus/core · AMR → @audio/decode-amr · AC-3 → @audio/decode-ac3 ·
|
|
5
|
-
* PCM / µ-law / A-law inline.
|
|
4
|
+
* Opus → @audio/decode-opus/core · AMR → @audio/decode-amr · AC-3 → @audio/decode-ac3 · E-AC-3 → @audio/decode-eac3
|
|
5
|
+
* DTS → @audio/decode-dts · PCM / µ-law / A-law inline.
|
|
6
6
|
*
|
|
7
7
|
* let { channelData, sampleRate } = await decode(mp4buf)
|
|
8
8
|
* let dec = await decoder(); let result = await dec.decode(chunk)
|
|
@@ -249,7 +249,7 @@ function advance(st) {
|
|
|
249
249
|
// ===== codec routing =====
|
|
250
250
|
|
|
251
251
|
const MP3_OTI = new Set([0x69, 0x6B]), AAC_OTI = new Set([0x40, 0x66, 0x67, 0x68])
|
|
252
|
-
const UNSUPPORTED = {
|
|
252
|
+
const UNSUPPORTED = { 0xE1: 'QCELP' }
|
|
253
253
|
const DTS_TYPES = new Set(['dtsc', 'dtsh', 'dtsl', 'dtse']) // DTS-HD variants carry a decodable core
|
|
254
254
|
|
|
255
255
|
async function createCodec({ entry, children }) {
|
|
@@ -259,6 +259,7 @@ async function createCodec({ entry, children }) {
|
|
|
259
259
|
if (MP3_OTI.has(oti)) return frames(import('@audio/decode-mp3'))
|
|
260
260
|
if (oti === 0xA5) return frames(import('@audio/decode-ac3'))
|
|
261
261
|
if (oti === 0xA9) return frames(import('@audio/decode-dts'))
|
|
262
|
+
if (oti === 0xA6) return frames(import('@audio/decode-eac3'))
|
|
262
263
|
if (!oti || AAC_OTI.has(oti)) {
|
|
263
264
|
if (!dsi) throw Error('MP4 AAC track has no AudioSpecificConfig')
|
|
264
265
|
return aac({ asc: dsi })
|
|
@@ -280,6 +281,7 @@ async function createCodec({ entry, children }) {
|
|
|
280
281
|
}
|
|
281
282
|
if (type === 'samr' || type === 'sawb') return amr(type === 'sawb')
|
|
282
283
|
if (type === 'ac-3') return frames(import('@audio/decode-ac3'))
|
|
284
|
+
if (type === 'ec-3') return frames(import('@audio/decode-eac3'))
|
|
283
285
|
if (DTS_TYPES.has(type)) return frames(import('@audio/decode-dts'))
|
|
284
286
|
let fmt = pcmFormat(entry, children)
|
|
285
287
|
if (fmt) return pcm(fmt)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/decode-mp4",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Decode the audio track of MP4, MOV, M4A, M4V and 3GP files (AAC, ALAC, MP3, FLAC, Opus, AMR, PCM) to PCM samples",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "decode-mp4.js",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"@audio/decode-dts": "^1.0.0",
|
|
34
34
|
"@audio/decode-flac": "^1.3.0",
|
|
35
35
|
"@audio/decode-mp3": "^1.3.0",
|
|
36
|
-
"@audio/decode-opus": "^1.3.0"
|
|
36
|
+
"@audio/decode-opus": "^1.3.0",
|
|
37
|
+
"@audio/decode-eac3": "^1.0.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"tst": "^9.2.2"
|