Convert WEM files into WAV, OGG and MP3 audio
Some games like Age of Empires or Warhammer: 40,000 use WEM files to reproduce sound effects and voices.
As an example, I found WEM to be used in Age of Empires 4, so I wanted to understand how to make them playable. By default WEM can't be listened to.
Table of contents
Convert WEM into OGG
- Put WEM files inside a folder
- Download ww2ogg from Github, you need to download the last release
- As an example, I downloaded "ww2ogg024.zip"
- Extract the ww2ogg ZIP into the same folder with WEM files. There must be the file ww2ogg.exe
- Download reVorb from Github, the latest release available
- I downloaded "ReVorb.exe"
- Place the reVorb EXE file inside the folder with WEM files and with ww2ogg.exe
- Create a new text file in the same folder, the content will be the code you can find here below
- Save the text file with .bat extension, like "run.bat". This will make the file an executable.
- Run the file run.bat, you will see all the WEM files in the folder will be converted into OGG.
- Additionally, you can convert the OGG files into MP3, read below to find out how.
run.bat: (credits Pastebin)
for %%f in (*.wem) do "./ww2ogg.exe" %%f --pcb "./packed_codebooks_aoTuV_603.bin"
pause
for %%f in (*.ogg) do revorb.exe %%f
pause
Basically, this file run.bat scans the folder where it is placed in, it executes ww2ogg.exe on all WEM files, which will be converted into OGG files. Then, OGG files are adjusted one by one with reVorb.exe, so they will be playable.
If you want, you can edit the code of run.bat by opening it simply with any text editor. You might want to change the files folders in the script.
"./" is the current folder, while "./ww2ogg/ww2ogg.exe" means "run the ww2ogg.exe file inside the ww2ogg folder". The path of these folders refers to where the run.bat file is placed, that is why it is better keep it with the WEM and the other EXE files, it will be easier for you.
Now you can use a player like MPC-BE to listen to OGG files.
Errors with ww2ogg
If you get this error:
Parse error: expected 0x42 fmt if vorb missing
It means the WEM file cannot be converted with ww2ogg, at this point you can try using VGMSTREAM as indicated below.
Convert WEM into WAV with VGMSTREAM
We can also use vgmstream to obtain a similar or even better result than ww2ogg.
- Download the latest release of vgmstream from Github for your system, I have downloaded r1810 for Windows
- Extract the archive in the same folder where you have the WEM files
Now you can simply drag and drop the WEM files over the executable file (vgmstream-cli.exe, before version r1831 the filename was test.exe) and this will make a standard conversion into playable WAV files, in the same folder. By default the bitrate will be of 768kbps.
Otherwise you can make a .bat file as before, this time using the new executable, like this:
for %%f in (*.wem) do "./vgmstream-cli.exe" -o %%f.wav %%f
pause
This will conver the WEM files in the folder into WAV which can be played. You can of course convert the WAV into MP3 with ffmpeg if you want.
Convert OGG into MP3
- Download FFMPEG
- I downloaded the full version of ffmpeg for Windows, the EXE files are inside the "bin" folder
- 7z files can be opened as archives, you can use 7zip
- Open a command prompt (cmd.exe)
- Move inside the folder where ffmpeg.exe is, for a easier use you can move the OGG file inside the folder where ffmpeg.exe is.
- To do so, use the command "cd" which means change directory, example: "cd C:\Programs\ffmpeg"
- Execute the command below, the path of the OGG file could be different if the folder differs.
./ffmpeg.exe -i filename.ogg -acodec libmp3lame -b:a 192k filename.mp3
This way you can convert "filename.ogg" into "filename.mp3". You can now play the MP3.
UPDATE: I have made an important update on this code following the comment written by Alastor. I have now specified a bitrate of 192kbps because by default the output bitrate would otherwise be of 64kbps. This should now give you a higher quality audio. The added parameter is -b:a 192k but you can find more options in the ffmpeg documentation.
You can massively convert the OGG into MP3 file creating another BAT file with the following code:
for %%f in (*.ogg) do ffmpeg -i %%f -acodec libmp3lame -b:a 192k %%f.mp3
pause
Basically, I adapted the previous BAT file so that it scans all OGG files and automatically convert them with FFMPEG into MP3.
Convert WAV into MP3
In case you have used VGMSTREAM to convert WEM into WAV, you might want to convert the WAV into MP3.
So, from my tests, the WAV files you obtain will have a bitrate of 768kbps. By using ffmpeg we selected the libmp3lame codec, we can of course use different codecs that you can find in the ffmpeg documentation. For this codec we will set a bitrate of 192kbps.
Place the ffmpeg.exe file in the folder where you have WAV files, and then run this command:
./ffmpeg.exe -i filename.wav -acodec libmp3lame -b:a 192k filename.mp3
Again, you can also make another bat file for running the conversion massively:
for %%f in (*.wav) do "./ffmpeg.exe" -i %%f -acodec libmp3lame -b:a 192k %%f.mp3
pause
Also read
- How to make Gettext work with PHP on Windows 11
- How to merge multiple videos easily and fast with FFMPEG concatenate
Stay up to date!
In the future we will surely talk about other topics on this subject, so if this article was useful to you I invite you to follow us on Facebook and to subscribe our Youtube channel!
Let me know your feedback with a comment here below and tell me what other guides you'd like to read!