diff --git a/src/output-format.ts b/src/output-format.ts index f759896..4e64946 100644 --- a/src/output-format.ts +++ b/src/output-format.ts @@ -799,7 +799,7 @@ export class WavOutputFormat extends OutputFormat { getSupportedCodecs(): MediaCodec[] { return [ ...PCM_AUDIO_CODECS.filter(codec => - ['pcm-s16', 'pcm-s24', 'pcm-s32', 'pcm-f32', 'pcm-u8', 'ulaw', 'alaw'].includes(codec), + ['pcm-s16', 'pcm-s24', 'pcm-s32', 'pcm-f32', 'pcm-f64', 'pcm-u8', 'ulaw', 'alaw'].includes(codec), ), ]; } diff --git a/src/wave/wave-demuxer.ts b/src/wave/wave-demuxer.ts index 1324c6f..ddf750a 100644 --- a/src/wave/wave-demuxer.ts +++ b/src/wave/wave-demuxer.ts @@ -173,6 +173,28 @@ export class WaveDemuxer extends Demuxer { bitsPerSample = 8; } + if ( + formatTag !== WaveFormat.PCM + && formatTag !== WaveFormat.IEEE_FLOAT + && formatTag !== WaveFormat.ALAW + && formatTag !== WaveFormat.MULAW + ) { + throw new Error( + `Unsupported WAVE codec (format tag ${formatTag}). Only integer/float PCM, A-law, and μ-law are` + + ` supported.`, + ); + } + if (formatTag === WaveFormat.PCM && ![8, 16, 24, 32].includes(bitsPerSample)) { + throw new Error( + `Unsupported WAVE PCM bit depth (${bitsPerSample}). Only 8, 16, 24, and 32 bits are supported.`, + ); + } + if (formatTag === WaveFormat.IEEE_FLOAT && ![32, 64].includes(bitsPerSample)) { + throw new Error( + `Unsupported WAVE float bit depth (${bitsPerSample}). Only 32 and 64 bits are supported.`, + ); + } + this.audioInfo = { format: formatTag, numberOfChannels: numChannels, @@ -322,10 +344,12 @@ export class WaveDemuxer extends Demuxer { if (this.audioInfo.format === WaveFormat.IEEE_FLOAT) { if (this.audioInfo.sampleSizeInBytes === 4) { return 'pcm-f32'; + } else if (this.audioInfo.sampleSizeInBytes === 8) { + return 'pcm-f64'; } } - return null; + assert(false); } async getMimeType() {