我需要在我的 Android 项目中将视频旋转 90 度。经过一番谷歌搜索后,我停在了可以与 Android 集成的 mp4parser。视频存储在设备上,也将保存在那里(不确定是否使用不同的名称,但这并不重要)。这是我正在使用的代码(使用 isoviewer-1.0-RC-35 制作),但如果需要,我可以将库更改为 2.0 版:
try
{
String inputVideoName = "path_to_a_video";
IsoFile out = new IsoFile(inputVideoName);
out.getMovieBox().getMovieHeaderBox().setMatrix(Matrix.ROTATE_90);
File outputVideoName = new File("path_to_a_saved_processed_video");
if (!outputVideoName.exists())
outputVideoName.createNewFile();
FileOutputStream fos = new FileOutputStream(outputVideoName);
out.writeContainer(fos.getChannel());
fos.close();
out.close();
}
catch (IOException e) {
Log.e("test", "some exception", e);
}
代码编译、运行、保存视频,但使用原始旋转,因此没有对其进行任何更改。怎么了?