How do I merge/join MP3 files with C#?

后端 未结 4 700
既然无缘
既然无缘 2020-12-03 13:22

I have a library of different words/phrases, and in order to build sentences at present I add a combination of these phrases into a playlist to make a sentence. Unfortunate

4条回答
  •  無奈伤痛
    2020-12-03 13:53

    here's how you can concatenate MP3 files using NAudio:

    public static void Combine(string[] inputFiles, Stream output)
    {
        foreach (string file in inputFiles)
        {
            Mp3FileReader reader = new Mp3FileReader(file);
            if ((output.Position == 0) && (reader.Id3v2Tag != null))
            {
                output.Write(reader.Id3v2Tag.RawData, 0, reader.Id3v2Tag.RawData.Length);
            }
            Mp3Frame frame;
            while ((frame = reader.ReadNextFrame()) != null)
            {
                output.Write(frame.RawData, 0, frame.RawData.Length);
            }
        }
    }
    

    see here for more info

提交回复
热议问题