How to convert WEM files into playable audio WAV, OGG and MP3

How to convert WEM files into playable audio WAV, OGG and MP3

Published 11/14/2021
Updated 01/29/2023
Categories
Tags

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.

Convert WEM into OGG

  1. Put WEM files inside a folder
  2. 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
  3. 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
  4. Create a new text file in the same folder, the content will be the code you can find here below
  5. Save the text file with .bat extension, like "run.bat". This will make the file an executable.
  6. Run the file run.bat, you will see all the WEM files in the folder will be converted into OGG.
  7. 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.

  1. Download the latest release of vgmstream from Github for your system, I have downloaded r1810 for Windows
  2. 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 (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 "./test.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

  1. 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
  2. Open a command prompt (cmd.exe)
  3. 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"
  4. 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

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!

Leave a comment

All comments will be subject to approval after being sent. They might be published after several hours.

Fields marked with * are mandatory. Email is optional and will not be published in any case.

*
  • 2023-01-29 15:30:33

    Author: eartahhj

    Comment: @Alastor I have just updated the guide to include options to get a better audio quality. Also, I have added instructions on how to use VGMSTREAM to convert WEM into WAV, and also on how to convert WAV into MP3 with ffmpeg. Please let me know if this works better for you and gives you a higher quality.

  • 2023-01-29 10:55:21

    Author: eartahhj

    Comment: @Alastor well there are of course a lot of options for ffmpeg that you can apply, for the quality you could try with adding -b:a 192k but that depends on the codec used, in this case libmp3lame, which can be also changed with something else. I will update the article later anyway to add some more information about this. Please remember that the content that you find in this website is all for free. It is fine if you ask to improve the guide of course, but not really to say to go read another guide, that's not really kind of you.

  • 2023-01-29 03:57:02

    Author: Alastor

    Comment: I made a comment earlier saying this is helped me a lot, but on closer look in to the mp3 files it looks like they were encoded in 64kbps which really low quality. i'm sure there is a way to fix this in ffmpeg and make a bat file to batch process all the audio clips but in the meantime i suggest the anyone find a different guid on how to do this if you want good quality audio.

  • 2023-01-29 00:13:40

    Author: eartahhj

    Comment: @Alastor I am glad this helped you! Good to know that this article is useful! Enjoy your OST and follow us on facebook and youtube, the links are in the footer below!

  • 2023-01-28 06:04:37

    Author: Alastor

    Comment: Great article, helped me get the losses Version of Fields of Ard Skellige straight from the Witcher 3 file.

  • 2023-01-02 16:52:37

    Author: eartahhj

    Comment: @Brill: You are welcome! Enjoy your new OST. If you can, support us by following our facebook or youtube pages, or by making a donation!

  • 2023-01-02 15:21:16

    Author: Brill

    Comment: Thanks for the great explanation! It helped me to extract the wonderful OST of the game AGOS - A Game of Space .

  • 2022-07-03 15:00:59

    Author: eartahhj

    Comment: Well, for the error "Parse error: expected 0x42 fmt if vorb missing", you can try what is indicated here: https://github.com/hcs64/ww2ogg/issues/14. Otherwise you can try this: https://forum.xentax.com/viewtopic.php?p=110795#p110795

  • 2022-06-10 18:41:35

    Author: I got error

    Comment: It didn't work. I got this error: Input: credits01.wem Parse error: expected 0x42 fmt if vorb missing

  • 2022-05-26 21:47:18

    Author: f

    Comment: i dont have time for math clas