Play and Convert Tracker Music with FFmpeg
This article explains how to play and convert classic tracker music
modules—specifically MOD, S3M, XM, and IT formats—using FFmpeg with the
libgme and libopenmpt external libraries. You
will learn how to verify your FFmpeg installation, play these files
directly from the command line, and convert them into standard audio
formats like WAV, FLAC, and MP3.
Step 1: Verify Decoder Support
Before proceeding, you must ensure that your FFmpeg build includes support for the necessary decoders. Run the following command in your terminal to check:
ffmpeg -decoders | grep -E "gme|openmpt"If the libraries are enabled, you will see libopenmpt
and/or libgme listed in the output. If they do not appear,
you must install or compile an FFmpeg build configured with the
--enable-libopenmpt and --enable-libgme
flags.
Note: libopenmpt is the preferred engine for classic PC tracker formats (MOD, S3M, XM, IT), while libgme (Game Music Emulators) is best suited for console-specific formats like SPC, NSF, and GBS.
Step 2: Playing Tracker Files with ffplay
You can listen to tracker files directly in your terminal using
ffplay, FFmpeg’s companion media player.
To play a file using the OpenMPT engine:
ffplay -f libopenmpt input.xmTo play a video game music file (such as an SNES .spc
file) using the GME engine:
ffplay -f libgme input.spcStep 3: Converting Tracker Files to Modern Audio Formats
To transcode tracker modules into standard audio files, define the
input format explicitly using the -f flag so FFmpeg routes
the file to the correct decoder.
Convert to WAV (Lossless Uncompressed)
ffmpeg -f libopenmpt -i input.it output.wavConvert to FLAC (Lossless Compressed)
ffmpeg -f libopenmpt -i input.s3m output.flacConvert to MP3 (Lossy)
ffmpeg -f libopenmpt -i input.mod -b:a 320k output.mp3Step 4: Customizing Output Quality
Tracker files are rendered in real-time by the decoders. You can adjust the sample rate and audio channels during the conversion process to ensure the highest output quality.
To render a tracker file at 48kHz, 2-channel stereo:
ffmpeg -f libopenmpt -ar 48000 -ac 2 -i input.xm output.flac