Fix faulty MP3 bitrate and frame size calculation (fixes #134)

This commit is contained in:
Vanilagy
2025-09-19 13:20:36 +02:00
parent e88bc15b0e
commit eb1ce86187
10 changed files with 151 additions and 129 deletions
+9 -2
View File
@@ -117,9 +117,16 @@ export class Mp3Demuxer extends Demuxer {
this.firstFrameHeader = header;
}
const sampleDuration = header.audioSamplesInFrame / header.sampleRate;
if (header.sampleRate !== this.firstFrameHeader.sampleRate) {
console.warn(
`MP3 changed sample rate mid-file: ${this.firstFrameHeader.sampleRate} Hz to ${header.sampleRate} Hz.`
+ ` Might be a bug, so please report this file.`,
);
}
const sampleDuration = header.audioSamplesInFrame / this.firstFrameHeader.sampleRate;
const sample: Sample = {
timestamp: this.nextTimestampInSamples / header.sampleRate,
timestamp: this.nextTimestampInSamples / this.firstFrameHeader.sampleRate,
duration: sampleDuration,
dataStart: result.startPos,
dataSize: header.totalSize,