Merge two audio mp4 file ?
See original GitHub issueI try to merge one audio mp4 file to another audio mp4 file.
Code:
String audio1 = path + “audio1.mp4”; String audio2 = path + “audio2.mp4”; String outputVideo = path + “audio_output.mp4”;
Movie[] inMovies = new Movie[]{
MovieCreator.build(audio1),
MovieCreator.build(audio2),
};
List<Track> audioTracks = new LinkedList<Track>();
for (Movie m : inMovies) {
for (Track t : m.getTracks()) {
if (t.getHandler().equals("soun")) {
audioTracks.add(t);
}
}
}
Movie result = new Movie();
if (audioTracks.size() > 0) {
result.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()])));
}
Container out = new DefaultMp4Builder().build(result);
out.writeContainer(new FileOutputStream(outputVideo).getChannel());
Exception:
java.io.IOException: Cannot merge AudioSampleEntry{bytesPerSample=0, bytesPerFrame=0, bytesPerPacket=0, samplesPerPacket=0, packetSize=0, compressionId=0, soundVersion=0, sampleRate=44100, sampleSize=16, channelCount=2, boxes=[com.googlecode.mp4parser.boxes.mp4.ESDescriptorBox@0]} and AudioSampleEntry{bytesPerSample=0, bytesPerFrame=0, bytesPerPacket=0, samplesPerPacket=0, packetSize=0, compressionId=0, soundVersion=0, sampleRate=8000, sampleSize=16, channelCount=1, boxes=[com.googlecode.mp4parser.boxes.mp4.ESDescriptorBox@0]}
Is there any solution ?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
So codec settings need to be the same: Same sample rate, same number of channels and so on. In the first mail I can see that Durim is trying to append 44.1KHz Stereo with 8KHz Mono. That cannot work. The basic properties
2016-01-28 8:54 GMT+02:00 yanchengdeng notifications@github.com:
Can you suggest i want to merge audio at middle of first file (for example after 5 second of first audio) Audio 1 = 1111111111 Audio 2 = 0000000000 Output= 11111 000000000011111