Unsupported format in WAV file: ff
Hi !
I'm extracting audio for a video using ffmpeg with the command:
ffmpeg -i input_video.mp4 -c copy -map a -f segment -segment_time 0.50 audio_frame-%d.wav
And when I try to decode one of the wav files like so:
let buffer = fs.readFileSync('audio_frame-%d.wav');
let result = wav.decode(buffer);
return JSON.stringify({ data: result.channelData });
I get a decoder error on the second line(the decode function) saying:
TypeError: Unsupported format in WAV file: ff
at Object.decode (/root/myProject/node_modules/node-wav/index.js:204:15)
Any idea why and how to fix it?
I have similar issues.
I'm split audio ussing ffmpeg with the command:
ffmpeg -i .\audio.wav -f segment -segment_time 0.05 -c copy out%04d.wav
And I try to decode part of wav file like this:
let buffer = fs.readFileSync('out0148.wav');
let result = wav.decode(buffer);
and I get error on decode line:
TypeError: Unsupported format in WAV file: fffe
at Object.decode (C:\Users\bass9030\Documents\REAPER Media\split test\node_modules\node-wav\index.js:204:15)
at Object.<anonymous> (C:\Users\bass9030\Documents\REAPER Media\split test\index.js:2:18)
I think this issue occurs when try to load too short a wav file.
The temporary solution is to modify some of the phrases in node-wav/index.js:204
...
while (pos < end) {
let type = string(4);
let size = u32();
let next = pos + size;
switch (type) {
case 'fmt ':
let formatId = u16();
// comment the conditional statements
/*if (formatId !== 0x0001 && formatId !== 0x0003)
throw new TypeError('Unsupported format in WAV file: ' + formatId.toString(16));*/
fmt = {
format: 'lpcm',
floatingPoint: formatId === 0x0003,
channels: u16(),
sampleRate: u32(),
byteRate: u32(),
blockSize: u16(),
bitDepth: u16(),
};
...
#4 should fix this issue