Implement MP3 muxer

This commit is contained in:
Vanilagy
2025-01-26 11:45:56 +01:00
parent 7205d9445b
commit d3566305df
11 changed files with 482 additions and 148 deletions
+33 -33
View File
@@ -179,39 +179,6 @@ export class WebMInputFormat extends MatroskaInputFormat {
}
}
/** @public */
export class WaveInputFormat extends InputFormat {
async _canReadInput(input: Input) {
const sourceSize = await input._mainReader.source._getSize();
if (sourceSize < 12) {
return false;
}
const riffReader = new RiffReader(input._mainReader);
const riffType = riffReader.readAscii(4);
if (riffType !== 'RIFF' && riffType !== 'RIFX') {
return false;
}
riffReader.pos = 8;
const format = riffReader.readAscii(4);
return format === 'WAVE';
}
/** @internal */
_createDemuxer(input: Input) {
return new WaveDemuxer(input);
}
getName() {
return 'WAVE';
}
getMimeType() {
return 'audio/wav';
}
}
/** @public */
export class Mp3InputFormat extends InputFormat {
async _canReadInput(input: Input) {
@@ -248,6 +215,39 @@ export class Mp3InputFormat extends InputFormat {
}
}
/** @public */
export class WaveInputFormat extends InputFormat {
async _canReadInput(input: Input) {
const sourceSize = await input._mainReader.source._getSize();
if (sourceSize < 12) {
return false;
}
const riffReader = new RiffReader(input._mainReader);
const riffType = riffReader.readAscii(4);
if (riffType !== 'RIFF' && riffType !== 'RIFX') {
return false;
}
riffReader.pos = 8;
const format = riffReader.readAscii(4);
return format === 'WAVE';
}
/** @internal */
_createDemuxer(input: Input) {
return new WaveDemuxer(input);
}
getName() {
return 'WAVE';
}
getMimeType() {
return 'audio/wav';
}
}
/** @public */
export const MP4 = new Mp4InputFormat();
/** @public */