i am developing an app to merge the n number of videos using mp4parser.The videos which are to be merged are taken in both front camera and back camera. if i merge these videos into single , it is merging all videos fine, but the alternative videos which are taken via front camera are merged as inverted. what can i do. please any one help me.
this is my code to merge videos:
try {
String f1,f2,f3;
f1 = Environment.getExternalStorageDirectory() + "/DCIM/testvideo1.mp4";// video took via back camera
f2 = Environment.getExternalStorageDirectory() + "/DCIM/testvideo2.mp4";// video took via front camera
f3 = Environment.getExternalStorageDirectory() + "/DCIM/testvideo3.mp4";// video took via front camera
Movie[] inMovies = new Movie[] {
MovieCreator.build(f1),
MovieCreator.build(f2),
MovieCreator.build(f3)
};
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()])));
}
BasicContainer out = (BasicContainer) new DefaultMp4Builder().build(result);
WritableByteChannel fc = new RandomAccessFile(
String.format(Environment.getExternalStorageDirectory()+ "/DCIM/CombinedVideo.mp4"), "rw").getChannel();
out.writeContainer(fc);
fc.close();
} catch (Exception e) {
Log.d("Rvg", "exeption" + e);
Toast.makeText(getApplicationContext(), "" + e, Toast.LENGTH_LONG)
.show();
}