mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-02-14 10:20:47 +01:00
fix some video orientation issues
This commit is contained in:
parent
4a542be54d
commit
5ad1e2ad71
@ -85,7 +85,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
|||||||
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
||||||
|
|
||||||
camera.setParameters(parameters);
|
camera.setParameters(parameters);
|
||||||
setCameraDisplayOrientation(cameraId, camera);
|
camera.setDisplayOrientation(getCameraRotation(cameraId));
|
||||||
|
|
||||||
if (canTakePicture) {
|
if (canTakePicture) {
|
||||||
try {
|
try {
|
||||||
@ -101,7 +101,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
|||||||
initRecorder();
|
initRecorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCameraDisplayOrientation(int cameraId, android.hardware.Camera camera) {
|
public static int getCameraRotation(int cameraId) {
|
||||||
final Camera.CameraInfo info = Utils.getCameraInfo(cameraId);
|
final Camera.CameraInfo info = Utils.getCameraInfo(cameraId);
|
||||||
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
|
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
|
||||||
int degrees = 0;
|
int degrees = 0;
|
||||||
@ -127,7 +127,7 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
|||||||
} else {
|
} else {
|
||||||
result = (info.orientation - degrees + 360) % 360;
|
result = (info.orientation - degrees + 360) % 360;
|
||||||
}
|
}
|
||||||
camera.setDisplayOrientation(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void takePicture() {
|
public void takePicture() {
|
||||||
@ -359,7 +359,12 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
|||||||
recorder.setProfile(cpHigh);
|
recorder.setProfile(cpHigh);
|
||||||
recorder.setOutputFile(curVideoPath);
|
recorder.setOutputFile(curVideoPath);
|
||||||
recorder.setPreviewDisplay(surfaceHolder.getSurface());
|
recorder.setPreviewDisplay(surfaceHolder.getSurface());
|
||||||
recorder.setOrientationHint(90);
|
|
||||||
|
if (currCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
||||||
|
recorder.setOrientationHint(270);
|
||||||
|
} else {
|
||||||
|
recorder.setOrientationHint(getCameraRotation(currCameraId));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
recorder.prepare();
|
recorder.prepare();
|
||||||
@ -387,9 +392,9 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
|
|||||||
if (recorder != null && isRecording) {
|
if (recorder != null && isRecording) {
|
||||||
recorder.stop();
|
recorder.stop();
|
||||||
recorder = null;
|
recorder = null;
|
||||||
|
Utils.scanFile(curVideoPath, getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
isRecording = false;
|
isRecording = false;
|
||||||
Utils.scanFile(curVideoPath, getContext());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user