I have some problem with concatenation mp3 files. For example, I have 5 mp3 files. And I want concatenate them to one file.
I try this:
try {
InputStream in = new FileInputStream("C:/a.mp3");
byte[] buffer = new byte[1024];
OutputStream os = new FileOutputStream(new File("C:/output.mp3",
true));
int count;
while ((count = in.read(buffer)) != -1) {
os.write(buffer, 0, count);
os.flush();
}
in.close();
in = new FileInputStream("C:/b.mp3");// second mp3
while ((count = in.read(buffer)) != -1) {
os.write(buffer, 0, count);
os.flush();
}
in.close();
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
But this do not working. I get one mp3 file on the finish of this process, it contains all music data from source mp3 files, but in Options I see time of fihish mp3 only from first source mp3 file. And, when I try use this final mp3 file when I use Xuggle library for adding this mp3 audio to mp4 video I get error.
I'm sure, problem in bytes from every mp3 source file, where recordered meta infromation. Maybe exist some library for correct concatenation mp3?