Fix incomplete parsing and generation of AacAudioSpecificConfig (fixes #471)

This commit is contained in:
Vanilagy
2026-08-26 13:40:14 +02:00
parent c10f93ab8c
commit d44253c7d3
8 changed files with 162 additions and 53 deletions
+21
View File
@@ -14,6 +14,7 @@ import {
Mp4OutputFormat,
Output,
} from '../../src/index.js';
import { assert, toUint8Array } from '../../src/misc.js';
const __dirname = new URL('.', import.meta.url).pathname;
@@ -160,3 +161,23 @@ test('Annex B', async () => {
const firstPacket = (await sink.getFirstPacket())!;
expect([...firstPacket.data.slice(0, 4)]).toEqual([0, 0, 0, 1]);
});
test('HE-AAC v2 audio config is parsed correctly', async () => {
const filePath = path.join(__dirname, '..', 'public/he-aac-v2.mp4');
using input = new Input({
source: new FilePathSource(filePath),
formats: ALL_FORMATS,
});
const track = await input.getPrimaryAudioTrack();
assert(track);
expect(await track.getSampleRate()).toBe(44100);
expect(await track.getNumberOfChannels()).toBe(2);
const decoderConfig = (await track.getDecoderConfig())!;
expect(decoderConfig.codec).toBe('mp4a.40.29');
expect(decoderConfig.sampleRate).toBe(44100);
expect(decoderConfig.numberOfChannels).toBe(2);
expect([...toUint8Array(decoderConfig.description!)]).toEqual([0xeb, 0x8a, 0x08, 0x00]);
});