How to convert a MIDI file to WAV using Headless VLC Player (with the CLI) in Windows 10

How to convert a MIDI file to WAV using Headless VLC Player (with the CLI) in Windows 10

As a new module of a project that has a huge collection of Guitar Pro tabs, a visitor of the project should be able to play a preview of the tab in the browser. However, the entire tab and player shouldn't be loaded every time the user decides to play a single song, instead, it would be better to load something lighter, like a MIDI file. The MIDI file by itself is quite small, however, the player to play a MIDI isn't small but quite bigger. So the last option is to simply create a compressed audio (MP3) version of the synthesized MIDI file. I searched a while looking for the best option to do this and ended up using my favorite media player VLC, which allows transcoding multiple videos/songs to different formats graphically and from the binary using the command line.

In this article, I'll explain to you how to easily convert a MIDI file to WAV using VLC in the command line/batch.

1. Install VLC Player

The VLC player allows the user to do this (transcode) graphically as well, however as this is a programming blog, we are interested in how to do this with the command line so we can use it in our own applications. You can download the VLC Player installed on the official website here.

Once the application has been installed in your system, proceed with the next step to confirm that you have a FluidSynth MIDI synthesizer.

2. Configure FluidSynth MIDI Synthesizer

VLC Player needs to be able to play the MIDI file before transcoding. By default, VLC Media Player can't play MIDI files without specifying a SoundFont file that is used to play the MIDI file as audio. If you don't have a MIDI Synthesizer configured in your VLC Player, please follow this tutorial in order to complete this step.

Now that you know that the synthesizer has been configured, you can finally transcode MIDI to WAV with the final step.


If you try to convert the MIDI file to WAV in the next step, without having a configured MIDI Synthesizer, the generated WAV files will be corrupt and therefore won't be playable.

3. Converting the MIDI file to WAV

Transcoding is the process of taking a video file and changing it to a different format or bitrate. In VLC media player, it will copy the movie/audio to a new file in a different format, so you end up with both the original and new files. This means you need to have enough space on your hard drive to store this extra file.

The transcode instruction to convert a MIDI file to WAV using the command line is the following one:


So you may simply add this instruction as the value of the --sout parameter when running VLC from the command line. You will find 2 examples of how to do it here:

Preview transcode progress in the application

If you want the VLC interface to appear, you only need to provide the path of the input file as a positional argument and then add the parameter --sout to initialize the transcoding:

"C:\Program Files\VideoLAN\VLC\vlc.exe" "C:\Users\sdkca\Desktop\input-file.mid" --sout "#transcode{acodec=s16l,channels=2}:std{access=file,mux=wav,dst=C:\Users\sdkca\Desktop\output-file.wav}"

In this case, the input file is located at C:\Users\sdkca\Desktop\input-file.mid and the generated output file will be located at C:\Users\sdkca\Desktop\output-file.wav.

Headless mode

If you decide to transcode in the headless mode (without any progress), running everything under the hood, you will need to tweak a little bit the command to transcode the MIDI file to WAV:

"C:\Program Files\VideoLAN\VLC\vlc.exe" "C:\Users\sdkca\Desktop\input-file.mid" -I dummy --no-sout-video --sout-audio --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep --sout "#transcode{acodec=s16l,channels=2}:std{access=file,mux=wav,dst=C:\Users\sdkca\Desktop\output-file.wav}"

Happy coding ❤️!

This could interest you

Become a more social person