I am using Sebastian Annies example for the mp4parser where I append 3 videos. The result should be one video that plays all the three videos simultaneously. However, I get one video that plays the last video three times. Here is my code...
// int i = number of videos....
try {
String[] f = new String[i];
for (int count = 0; count < i; count++) {
f[count] = "/sdcard/vid" + i + ".mp4";
}
Movie[] inMovies = new Movie[i];
for (int count = 0; count < i; count++) {
inMovies[count] = MovieCreator.build(f[count]);
}
List<Track> videoTracks = new LinkedList<Track>();
List<Track> audioTracks = new LinkedList<Track>();
for (Movie m : inMovies) {
for (Track t : m.getTracks()) {
if (t.getHandler().equals("soun")) {
audioTracks.add(t);
}
if (t.getHandler().equals("vide")) {
videoTracks.add(t);
}
}
}
Movie result = new Movie();
if (audioTracks.size() > 0) {
result.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()])));
}
if (videoTracks.size() > 0) {
result.addTrack(new AppendTrack(videoTracks.toArray(new Track[videoTracks.size()])));
}
Container out = new DefaultMp4Builder().build(result);
FileChannel fc = new RandomAccessFile(String.format
("/sdcard/output.mp4"),
"rw").getChannel();
out.writeContainer(fc);
fc.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
VideoView v = (VideoView) findViewById(R.id.videoView1);
// v.setVideoPath("/sdcard/aaa" + i + ".mp4");
v.setVideoPath("/sdcard/output.mp4");
v.setMediaController(new MediaController(this));
v.start();
I dont know why it isn't doing what it's supposed to do. Please help me. Thanks