我有一个相机应用程序,可以拍摄照片和录制视频。但是,当使用设备的前置摄像头拍摄照片或录制视频时,结果会翻转,就像您在照镜子一样。我想再次翻转它,使其看起来正常。我通过使用
Matrix
将Bitmap
翻转来实现了图片翻转。 public Bitmap flip(Bitmap bitmap) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
Matrix matrix = new Matrix();
float[] mirrorY = {-1, 0, 0, 0, 1, 0, 0, 0, 1};
Matrix matrixMirrorY = new Matrix();
matrixMirrorY.setValues(mirrorY);
matrix.postConcat(matrixMirrorY);
matrix.postRotate(90);
return Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
}
我无法弄清如何翻转MediaRecorder
拍摄的视频,我知道可以运行ffmpeg
命令:
-i /pathtooriginalfile/originalfile.mp4 -vf hflip -c:a copy /pathtosave/flippedfile.mp4
但我不知道如何在代码中运行ffmpeg
命令,也找不到其他方法。有很多讨论这个问题的主题,但我找不到解决方法。注意:这是可能的,Snapchat 以某种方式使其工作。
谢谢。
P.S 对我的英语表示抱歉。