Revert video to original from mirror in Android

460 views Asked by At

Currently, I am capturing video using surfaceview, Its working perfect for back camera. But, it shows mirror video output for front camera. Is there any way to prevent mirror video or Is there any way to convert mirror video in again mirror video using mp4parser so I can get original video. I dont want to use TextureView also there is no hard coding to prevent mirror video.

Below is piece of my code to set orientation of camera, which is working perfect in both face.

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);
    } 
1

There are 1 answers

0
Shailendra Yadav On

setDisplayOrientation(degrees) will change the orientation of the images/live video rendering on your screen

MediaRecorder -> setOrientationHint(degrees) will change the orientation of the video stored in file.