0

I have script to say many mp3 files together. But before I join the file, the software will remove 5ms before and after each mp3 file and then merge the file. I have searched a lot of information but no one has done this.

    public static bool Mp3Merge(string[] inputFiles, Stream output)
    {
        bool result = false;
        try
        {
            Mp3FileReader reader = null;
            Mp3Frame frame;
            foreach (string file in inputFiles)
            {
                reader = new Mp3FileReader(file);
                if ((output.Position == 0) && (reader.Id3v2Tag != null))
                {
                    output.Write(reader.Id3v2Tag.RawData, 0, reader.Id3v2Tag.RawData.Length);
                }

                while ((frame = reader.ReadNextFrame()) != null)
                {
                    output.Write(frame.RawData, 0, frame.RawData.Length);
                }
            }
            output.Close();
            output.Dispose();
            if (reader != null)
            {                    
                reader.Close();
                reader.Dispose();
                reader = null;
            }
            result = true;
        }
        catch (Exception ex)
        {
            throw ex;
        }
        return result;
    }
halfer
  • 19,824
  • 17
  • 99
  • 186

0 Answers0