【问题标题】:Revert video to original from mirror in Android将视频从 Android 中的镜像还原为原始视频
【发布时间】:2015-06-15 06:11:40
【问题描述】:

目前,我正在使用 surfaceview 捕捉视频,它非常适合后置摄像头。但是,它显示前置摄像头的镜像视频输出。有什么方法可以防止镜像视频,或者有什么方法可以使用 mp4parser 将镜像视频转换为镜像视频,这样我就可以获得原始视频。我不想使用 TextureView 也没有硬编码来防止镜像视频。

下面是我设置相机方向的一段代码,它在两面都很好用。

public static void setCameraDisplayOrientation(Activity activity, int cameraId, android.hardware.Camera camera) {
        android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
        android.hardware.Camera.getCameraInfo(cameraId, info);
        int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
        int degrees = 0;
        switch (rotation) {
        case Surface.ROTATION_0:
            degrees = 0;
            break;
        case Surface.ROTATION_90:
            degrees = 90;

            break;
        case Surface.ROTATION_180:
            degrees = 180;
            break;
        case Surface.ROTATION_270:
            degrees = 270;
            break;
        }

        if (info.facing == 1)
        {
            degrees = (360 - (info.orientation + degrees) % 360) % 360;
        } else
        {
            degrees = ((info.orientation - degrees) + 360) % 360;
        }

        camera.setDisplayOrientation(degrees);
    } 

【问题讨论】:

    标签: android video orientation android-mediarecorder mirror


    【解决方案1】:

    setDisplayOrientation(degrees) 将改变屏幕上图像/实时视频渲染的方向

    MediaRecorder -> setOrientationHint(degrees) 将改变存储在文件中的视频的方向。

    【讨论】:

      猜你喜欢
      • 2022-11-02
      • 1970-01-01
      • 2011-07-10
      • 1970-01-01
      • 2012-08-21
      • 1970-01-01
      • 2019-12-28
      • 1970-01-01
      • 2020-08-30
      相关资源
      最近更新 更多