Hi,
I am basically trying to write a small utility to join MP3 files. I found some samples on Stackoverflow showing how to do it using NAudio:
http://stackoverflow.com/questions/1160888/how-do-i-merge-join-mp3-files-with-c
This is the code from my application doing the job:
var path = Path.Combine(Path.GetDirectoryName(Files[0]) ?? "", "joined.mp3"); using (var output = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read)) { foreach (string file in Files) { using (var 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); } } } }
It runs fine and I get a file with the expected file name and size, and tags taken from the first file. However when I play the joined file in Windows Media Player, the length seems to be roughly doubled (a littlebit less than double actually). If I jump to a position in the second half it just stops and jumps back to start. Up until then the file plays just fine. I tried a lot of different files and it seems to apply to all, so I don't believe this is related to the specific files.
I found this discussion leading me to think it might be related to CBR vs. VBR:
http://naudio.codeplex.com/discussions/76928
However I don't know if this still applies since the discussion on Stackoverflow is from 2010.
Best regards,
Hendrik