mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-02 21:33:52 +02:00
Fix faulty MP3 bitrate and frame size calculation (fixes #134)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user