WAVE文件扩展了fmt chunk的一部分

时间:2017-07-07 17:43:22

标签: javascript firefox encoding web-audio wave

我有一个WAVE文件,wFormatTag为3(WAVE_FORMAT_IEEE_FLOAT)。 Firefox会将WAVE_FORMAT_IEEE_FLOAT文件视为WAVE_FORMAT_EXTENSIBLE,这意味着它希望WAVE_FORMAT_IEEE_FLOAT文件包含fmt块的扩展部分。

我的文件不包含fmt块的扩展部分,这会在Firefox中解码文件时导致错误:The buffer passed to decodeAudioData contains invalid content which cannot be decoded successfully.

这意味着我必须在字节38添加wValidBitsPerSample,在字节40添加dwChannelMask,在字节44添加SubFormat我应该为这三个头字段添加哪些信息?这些信息的含义是什么?如何以8-16-32bits整数的形式添加它们?

感谢您的帮助:)。

以下是我的文件的标题信息:

console.log('ckID', String.fromCharCode(dataView.getUint8(0))); // R
console.log('ckID', String.fromCharCode(dataView.getUint8(1))); // I
console.log('ckID', String.fromCharCode(dataView.getUint8(2))); // F
console.log('ckID', String.fromCharCode(dataView.getUint8(3))); // F

console.log('cksize', dataView.getUint32(4, true)); // 65623058

console.log('WAVEID', String.fromCharCode(dataView.getUint8(8))); // W
console.log('WAVEID', String.fromCharCode(dataView.getUint8(9))); // A
console.log('WAVEID', String.fromCharCode(dataView.getUint8(10))); // V
console.log('WAVEID', String.fromCharCode(dataView.getUint8(11))); // E

console.log('ckID', String.fromCharCode(dataView.getUint8(12))); // f
console.log('ckID', String.fromCharCode(dataView.getUint8(13))); // m
console.log('ckID', String.fromCharCode(dataView.getUint8(14))); // t
console.log('ckID', String.fromCharCode(dataView.getUint8(15))); //

console.log('cksize', (dataView.getUint32(16, true))); // 16

console.log('wFormatTag', (dataView.getUint16(20, true))); // 3

console.log('nChannels', (dataView.getUint16(22, true))); // 2

console.log('nSamplesPerSec', (dataView.getUint32(24, true))); // 44100

console.log('nAvgBytesPerSec', (dataView.getUint32(28, true))); // 352800

console.log('nBlockAlign', (dataView.getUint16(32, true))); // 8

console.log('wBitsPerSample', (dataView.getUint16(34, true))); // 32

console.log('cbSize', (dataView.getUint16(36, true))); // 0

console.log('ckID', String.fromCharCode(dataView.getUint8(38))); // f
console.log('ckID', String.fromCharCode(dataView.getUint8(39))); // a
console.log('ckID', String.fromCharCode(dataView.getUint8(40))); // c
console.log('ckID', String.fromCharCode(dataView.getUint8(41))); // t

console.log('cksize', (dataView.getUint16(42, true))); // 4

console.log('dwSampleLength', (dataView.getUint16(46, true))); // 10876

console.log('ckID', String.fromCharCode(dataView.getUint8(50))); // d
console.log('ckID', String.fromCharCode(dataView.getUint8(51))); // a
console.log('ckID', String.fromCharCode(dataView.getUint8(52))); // t
console.log('ckID', String.fromCharCode(dataView.getUint8(53))); // a

1 个答案:

答案 0 :(得分:0)

根据https://bugzilla.mozilla.org/show_bug.cgi?id=1349658,Firefox不支持float32 WAV文件。