Skip to content

Commit 137dd93

Browse files
committed
fix: handle mp4a in quicktime mode
fixes #505
1 parent 60a4bdd commit 137dd93

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/boxes/sampleentries/base.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,34 @@ export class VisualSampleEntry extends SampleEntry {
235235
}
236236

237237
export class AudioSampleEntry extends SampleEntry {
238+
version: number;
238239
channel_count: number;
239240
samplesize: number;
240241
samplerate: number;
241242

243+
// Quicktime only
244+
extensions: Uint8Array;
245+
242246
parse(stream: MultiBufferStream) {
243247
this.parseHeader(stream);
244-
stream.readUint32Array(2);
248+
this.version = stream.readUint16();
249+
stream.readUint16(); // revision
250+
stream.readUint32(); // vendor
245251
this.channel_count = stream.readUint16();
246252
this.samplesize = stream.readUint16();
247253
stream.readUint16();
248254
stream.readUint16();
249255
this.samplerate = stream.readUint32() / (1 << 16);
256+
257+
const isQT = stream.isofile?.ftyp?.major_brand.includes('qt');
258+
if (isQT) {
259+
if (this.version === 1) {
260+
this.extensions = stream.readUint8Array(16);
261+
} else if (this.version === 2) {
262+
this.extensions = stream.readUint8Array(36);
263+
}
264+
}
265+
250266
this.parseFooter(stream);
251267
}
252268

0 commit comments

Comments
 (0)