Play and Convert Tracker Music Using FFmpeg
FFmpeg provides powerful support for rendering, playing, and
converting classic tracker music modules like MOD, S3M, XM, and IT into
modern audio formats. By leveraging integrated external libraries such
as libopenmpt (the OpenMPT engine) and libgme
(Game Music Emu), you can accurately process legacy chiptunes directly
from the command line. This guide covers how to check your FFmpeg build
for the required decoders, play modules natively using
ffplay, and convert files to modern formats like WAV, FLAC,
or MP3 with custom audio settings.
1. Verify Decoder Support
Before attempting playback or conversion, ensure your FFmpeg build
was compiled with support for libopenmpt or
libgme. Run the following command in your terminal:
ffmpeg -decoders | grep -E "openmpt|gme"If enabled, you will see libopenmpt and/or
libgme listed among the available audio decoders. For
standard tracker formats (MOD, S3M, XM, IT), libopenmpt
offers the highest playback accuracy and widest compatibility.
2. Playing Modules with FFplay
You can audition tracker files instantly without rendering them to
disk using ffplay.
Using libopenmpt (Recommended)
Force the libopenmpt decoder using the -c:a
flag:
ffplay -c:a libopenmpt input.xmUsing libgme
If the module format is supported by Game Music Emu, specify
libgme:
ffplay -c:a libgme input.mod3. Converting Tracker Modules to Standard Audio
To convert tracker modules into lossless or compressed audio formats,
invoke ffmpeg with your chosen decoder.
Convert to Lossless FLAC
To retain maximum audio fidelity:
ffmpeg -c:a libopenmpt -i input.it output.flacConvert to High-Bitrate MP3
To create an MP3 file with a fixed 320 kbps bitrate:
ffmpeg -c:a libopenmpt -i input.s3m -b:a 320k output.mp3Convert to Uncompressed WAV
For audio production or sample extraction:
ffmpeg -c:a libopenmpt -i input.mod output.wav4. Advanced libopenmpt Configuration Options
The libopenmpt decoder accepts specific parameters to
customize how the module renders.
Subsong Selection (
-subsong): Some modules contain multiple tracks or variations. Select a specific subsong index (starting at 0) or useallto render all songs sequentially:ffmpeg -subsong 0 -c:a libopenmpt -i input.mod output.flacStereo Separation (
-stereo_separation): Classic Amiga MOD files use hard-panned left and right channels. You can adjust the stereo width from0(mono) to100(full stereo panning):ffmpeg -stereo_separation 70 -c:a libopenmpt -i input.mod output.flacLoop Count (
-loop_count): Specify how many times a looping tracker song should repeat before ending (default is0for no loop, while-1loops infinitely):ffmpeg -loop_count 2 -c:a libopenmpt -i input.xm output.flac