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.

Force the libopenmpt decoder using the -c:a flag:

ffplay -c:a libopenmpt input.xm

Using libgme

If the module format is supported by Game Music Emu, specify libgme:

ffplay -c:a libgme input.mod

3. 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.flac

Convert 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.mp3

Convert to Uncompressed WAV

For audio production or sample extraction:

ffmpeg -c:a libopenmpt -i input.mod output.wav

4. 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 use all to render all songs sequentially:

    ffmpeg -subsong 0 -c:a libopenmpt -i input.mod output.flac
  • Stereo Separation (-stereo_separation): Classic Amiga MOD files use hard-panned left and right channels. You can adjust the stereo width from 0 (mono) to 100 (full stereo panning):

    ffmpeg -stereo_separation 70 -c:a libopenmpt -i input.mod output.flac
  • Loop Count (-loop_count): Specify how many times a looping tracker song should repeat before ending (default is 0 for no loop, while -1 loops infinitely):

    ffmpeg -loop_count 2 -c:a libopenmpt -i input.xm output.flac