I'm trying to get the rotation information in the MP4 video, I'm trying to use mp4parser for this but I'm not sure how can I get it, I'm doing this,
IsoFile isoFile = null;
try {
isoFile = new IsoFile(filePath);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
List<Box> boxes = isoFile.getBoxes();
for (Box box : boxes) {
System.out.println(box);
}
and the output is this
I/System.out(23548): FileTypeBox[majorBrand=isom;minorVersion=0;compatibleBrand=isom;compatibleBrand=3gp4]
I/System.out(23548): MovieBox[]
I/System.out(23548): com.coremedia.iso.boxes.FreeBox@0
I/System.out(23548): MediaDataBox{size=7913167}
Any idea how can I get the rotation tag value?
Update 1 The working code
import java.io.File;
import java.io.FileInputStream;
import android.app.Activity;
import android.os.Bundle;
import com.coremedia.iso.IsoFile;
import com.coremedia.iso.IsoTypeReader;
import com.coremedia.iso.boxes.Box;
import com.coremedia.iso.boxes.MovieBox;
import com.coremedia.iso.boxes.UserDataBox;
import com.googlecode.mp4parser.authoring.Movie;
import com.googlecode.mp4parser.authoring.container.mp4.MovieCreator;
import com.googlecode.mp4parser.util.Matrix;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String filePath = "/storage/emulated/0/test/test.mp4";
Activity activity = (Activity) MainActivity.this;
movie = MovieCreator.build(filePath);
Matrix matrix = movie.getMatrix();
}
}
You need to get Movie
object from the IsoFile
or read it with MovieCreator.build()
, then with movie.getMatrix()
obtain what is the type of matrix: Matrix.ROTATE_O
, Matrix.ROTATE_90
, Matrix.ROTATE_180
, Matrix.ROTATE_270
String filePath = "/path/to/movie/file.mp4"
Movie movie = MovieCreator.build(new FileInputStream(new File(filePath)).getChannel());
Matrix matrix = movie.getMatrix();