1

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();

    }



}
Adroid Freak
  • 329
  • 3
  • 18

1 Answers1

0

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();
Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
  • Thanks, I'm getting this "The method build(String) in the type MovieCreator is not applicable for the arguments (FileChannel)", any idea why? – Adroid Freak Sep 19 '14 at 03:38
  • Maybe the overloaded method accepts String, probably the filepath. – Nikola Despotoski Sep 19 '14 at 03:40
  • Tried many things, nothing is working, I updated question by adding the code with its imports, what do you think is going on? – Adroid Freak Sep 19 '14 at 03:47
  • Hmm, seems the loading of file fine. Here are the possible overloadings of `build()` method https://code.google.com/p/mp4parser/source/browse/trunk/isoparser/src/main/java/com/googlecode/mp4parser/authoring/container/mp4/MovieCreator.java?r=790 – Nikola Despotoski Sep 19 '14 at 03:52
  • Hi Nikola, the getMatrix function is always returning "Rotate 0". – Adroid Freak Sep 19 '14 at 14:26