Skip to content

Commit 99c90f0

Browse files
committed
fix: compatible with incomplete audio codec string mp4a.40
1 parent 226ba8e commit 99c90f0

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

packages/av-cliper/src/clips/__tests__/mp4-clip.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,14 @@ test('decode incorrectFrameTypeMp4', async () => {
191191
const { state } = await clip.tick(clip.meta.duration - 30e3);
192192
expect(state).toBe('success');
193193
});
194+
195+
const mp4_webav1 = `//${location.host}/video/webav1.mp4`;
196+
test('compatible with incomplete audio codec string mp4a.40', async () => {
197+
const clip = new MP4Clip((await fetch(mp4_webav1)).body!);
198+
await clip.ready;
199+
const spy = vi.spyOn(console, 'error').mockImplementation(() => {});
200+
201+
await clip.tick(1e6);
202+
expect(spy).not.toHaveBeenCalled();
203+
spy.mockRestore();
204+
});

packages/av-cliper/src/mp4-utils/mp4box-utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ function parseAudioInfoFromESDSBox(esds: ESDSBoxParser): {
110110
codec += '.' + decConfDesc.oti.toString(16);
111111

112112
const decSpecInfo = decConfDesc.descs[0];
113-
if (decSpecInfo == null) return { codec };
113+
if (decSpecInfo == null) {
114+
if (codec.endsWith('40')) codec += '.2';
115+
return { codec };
116+
}
114117

115118
// ref: https://wiki.multimedia.cx/index.php/MPEG-4_Audio#Audio_Specific_Config
116119
const audioObjectType = (decSpecInfo.data[0] & 0xf8) >> 3;

0 commit comments

Comments
 (0)