mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-09 16:53:47 +02:00
Add xingHeader option to Mp3OutputFormat
This commit is contained in:
@@ -50,7 +50,9 @@ export class Mp3Muxer extends Muxer {
|
||||
const release = await this.mutex.acquire();
|
||||
|
||||
try {
|
||||
if (!this.xingFrameData) {
|
||||
const writeXingHeader = this.format._options.xingHeader !== false;
|
||||
|
||||
if (!this.xingFrameData && writeXingHeader) {
|
||||
const view = toDataView(packet.data);
|
||||
if (view.byteLength < 4) {
|
||||
throw new Error('Invalid MP3 header in sample.');
|
||||
@@ -97,11 +99,14 @@ export class Mp3Muxer extends Muxer {
|
||||
|
||||
this.validateAndNormalizeTimestamp(track, packet.timestamp, packet.type === 'key');
|
||||
|
||||
this.framePositions.push(this.writer.getPos());
|
||||
this.writer.write(packet.data);
|
||||
this.frameCount++;
|
||||
|
||||
await this.writer.flush();
|
||||
|
||||
if (writeXingHeader) {
|
||||
this.framePositions.push(this.writer.getPos());
|
||||
}
|
||||
} finally {
|
||||
release();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user