[FFmpeg-user] ffmpeg producing invalid wav headers when merging two wav files

Tobias Rapp t.rapp at noa-archive.com
Tue Sep 14 12:21:35 EEST 2021

On 13.09.2021 20:13, Jim McMaster via ffmpeg-user wrote:
> We are using ffmpeg to merge two mono wav files into a single two-channel file.  When we do, we get a wav file that has an invalid header, and some of our other software cannot process it.    In particular, the AudioFormat at offset 20 has a value of ‘0700’ (little-endian) instead of ‘0100’.  The Subchunk2ID is ‘00006461’ instead of ‘74616461’ (“data”).  The Subchink2Size is a huge number (1937924468 or 0X73826174) which is much larger than the size of the audio file.
> We are using the command:
> /usr/bin/ffmpeg -ac 1 -ar 8000 -acodec pcm_s16le -f s16le -i  <inFile1>  -ac 1 -ar 8000 -acodec pcm_s16le -f s16le -i  <inFile2>  -filter_complex "[1:a][2:a] amerge=inputs=2[a]" -map "[a]" <outFile>
> This is generated in Java, so I hope I got it right.
> So, what are we doing wrong?  How do we get ffmpeg to generate a valid wav header?

Please add the log output of the command, it is difficult to give an 
advice here without knowing what version of FFmpeg you are using and 
what type of input and output format is detected.

 From your description is seems that you are using fixed file offsets to 
parse the WAVE headers. This seems to be very fragile as the size and 
order of chunks can vary between files. I would recommend to check the 
generated files also with third-party tools like ffprobe/ffplay, VLC, or 
MediaInfo to verify if it causes problems there.


More information about the ffmpeg-user mailing list