Basically I would like to rotate video, depending on which camera was used to take it.
Front camera is mirrored with 90 degrees, whereas back camera is displayed properly. Currently it will set Matrix according to the first clip. If the first clip was made with front camera, it will rotate all clips to 270 degrees and vice a versa.
Here is a sample code (rotations
is an ArrayList which contains clip rotations):
for (TrackBox trackBox : trackBoxes) {
Log.d("TRACKBOX", String.valueOf(rotations.get(i)));
//trackBox.getTrackHeaderBox().setMatrix(Matrix.ROTATE_90);
if (rotations.get(i) == 90) { //if clip was made with back camera
trackBox.getTrackHeaderBox().setMatrix(Matrix.ROTATE_90);
Log.d("Rotating to:", "90 degrees");
} else if (rotations.get(i) == 270) { // if clip was made with front camera
trackBox.getTrackHeaderBox().setMatrix(Matrix.ROTATE_270);
Log.d("Rotating to:", "270 degrees");
}
m.addTrack(new Mp4TrackImpl(trackBox));
}
inMovies[i] = m;