1

I have a job that is rotating and trimming video files. I do trimming the video but couldn't rotate it. I use following code snippet to rotate but the result video is the same with the source video .Also there isn't any error messeage.

videoPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/download/cvbenim/islenecek.mp4";
try {
  String rotatedPath = videoPath.replace(".mp4", "cvbenim_is_ilanı_rotated.mp4");
  Movie result = MovieCreator.build(videoPath);
  File file = new File(rotatedPath);
  if (file.exists()) {
    file.delete();
  }
  Container out = new DefaultMp4Builder().build(result);
  MovieHeaderBox mvhd = Path.getPath(out, "moov/mvhd");
  mvhd.setMatrix(Matrix.ROTATE_90);
  out.writeContainer(new FileOutputStream(rotatedPath).getChannel());
  playVideoFromPath(rotatedPath);
} catch (Exception e) {
  e.printStackTrace();
}

I appriciate any help.

Metin Ilhan
  • 231
  • 7
  • 16

1 Answers1

0

You don't state how you present your video in playVideoFromPath but as https://stackoverflow.com/a/17395134/3233251 says.

When you playback the video on Android with the help of the VideoView you might notice that the matrix is not taken into account. I'm not entirely sure if this is done on purpose or not but the workaround is to use a TextureView that applies the transformation.

So you should try to use the TextureView as recommended if you are not already doing so.

Community
  • 1
  • 1
Slamper
  • 445
  • 3
  • 10