How to merge MP3 files using C#

MP3 Merger .NET API

GroupDocs.Merger allows developers to combine multiple MP3 audio files in the preferred order and save them as a single file.

About MP3 File Format

The MP3 (MPEG-1 Audio Layer 3) file format is a widely used audio compression format known for its ability to significantly reduce the file size of audio recordings while maintaining reasonably good sound quality. MP3 is a lossy audio compression format, which means that it achieves smaller file sizes by removing some of the audio data that is less perceptible to the human ear.

MP3 is one of the most universally supported audio formats. It is compatible with a wide range of devices, software, and platforms, making it suitable for sharing and playback across different systems.

Download and Configure

Use the downloads section to obtain the API DLLs, MSI installer, or NuGet package:

PM> Install-Package GroupDocs.Merger

Source Audio Files

How To Merge Several MP3 Files Into A Single File

The following example demonstrates how to merge multiple audio files with several lines of C# code:

  • Create an instance of the Merger class and pass the source audio file path as a constructor parameter. You may specify absolute or relative file paths as per your requirements.
  • Add another audio file to merge with the Join method. Repeat this step for other audio files you want to merge.
  • Call the Save method and specify the filename for the resulting audio file as a parameter.
// Load the source MP3 file
using (var merger = new GroupDocs.Merger.Merger(@"c:\sample1.mp3"))
{
    // Add another MP3 file to merge
    merger.Join(@"c:\sample2.mp3");
    // Merge MP3 files and save result
    merger.Save(@"c:\merged.mp3");
}

Result Of Joining MP3 Files

Code Examples

Explore C# source code of our backend and frontend examples and use-cases. You can experiment with them at no cost!

Merge MP3 Live Demo

GroupDocs.Merger for .NET offers an online MP3 Merger App that enables you to test it without charge, assessing its quality and precision.