Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg - Making a Clean WAV file

I'm looking to batch convert a number of files to audio files using ffmpeg for a game called Star Wars: Jedi Knight: Dark Forces II. The problem I'm having is that ffmpeg seems to be doing something that does so that Jedi Knight can't play the sound file.

Jedi Knight accepts plain old PCM WAV files of various ranges, from 5khz to 96khz, 8 and 16 bit, mono and stereo. This sounds plain and simple. Except for that if one were to create a WAV file using MS Sound Recorder, Jedi Knight could not play it. Speculation was that it added something extra to header or something. But it can play a WAV file created by Audacity, GoldWave or ModPlug Tracker to name a few.

So why not ffmpeg? Am I using the wrong codec or params? I took an original sound file from the game and performed the following:

ffmpeg -i "orig_thrmlpu2.wav" -f wav -acodec pcm_s16le -ar 22050 -ac 1 "ffmpeg_thrmlpu2.wav"

The ffmpeg version does not play in the game. ffprobe shows that the ffmpeg version has some Metadata which the original doesn't have. What params should I use to try and get the same WAV format as the original? Mind you, -ar, -ac and bits aren't the important parts.

Here are the files for you to examine: http://www.edwardleuf.org/Games/JK/thrmlpu2.zip

like image 702
Edward Avatar asked Sep 23 '16 19:09

Edward


People also ask

Does FFmpeg support WAV?

FFmpeg can be used to convert a huge WAV file into a tiny MP3 file that allows the user to listen to the same song but downloading just a portion of the original size of the WAV file. In this article, I will explain to you how to easily convert a WAV file to MP3 using FFmpeg from the command line.


2 Answers

FFMpeg by default is adding a LIST-INFO chunk to the WAV output. Adding -bitexact suppresses it.

So,

ffmpeg -i "orig.wav" -f wav -bitexact -acodec pcm_s16le -ar 22050 -ac 1 "ffmpeg.wav"
like image 180
Gyan Avatar answered Oct 15 '22 00:10

Gyan


According to this feature request for ffmpeg to change its wav header files, the problem is 2 optional bytes. cbSize which are only supposed to be used for non-pcm data.

https://ffmpeg.org/pipermail/ffmpeg-devel/2013-April/142576.html

The header ffmpeg was writing as of 2013 was "80 bytes or 46 if you manage to suppress the LIST-INFO chunk."

The solution written there is to used these arguments when using ffmpeg.

> I must use ffmpeg -i ... -f s16le tmp.dat and then mplayer -demuxer rawaudio -rawaudio rate=44100:channels=2:samplesize=2 -ao pcm tmp.dat to get "normal" wav file, many program can't read ffmpeg's wav file, they read 44 bytes of header, and others data use as sound, sometimes it caused broken byteorder, or they say that file is broken and can't read file at all. So I want get "correct" wav from ffmpeg directly. Sorry for my bad english :)

The method listed there might work if -bitexact is not applicable. For example when converting wav to wav in order to fix the header.

like image 3
Audo Voice Avatar answered Oct 15 '22 00:10

Audo Voice