我在一个应用程序中有一个功能是使用前置摄像头录制一定长度的视频。
录音很好,但是方向不正确。我搜索了很多时间,但很多问题只在图片上提到
下面提供与 Camera 和 MediaRecorder 相关的部分
public void onCreate(Bundle savedInstanceState) {
// Some of the codes are not shown
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
recorder = new MediaRecorder();
holder = cameraView.getHolder();
}
private void initRecorder() {
recorder.setCamera(camera);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
CamcorderProfile cpLow = CamcorderProfile.get(1,
CamcorderProfile.QUALITY_LOW);
recorder.setProfile(cpLow);
mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
mFileName += "/youraudiofile.mp4";
recorder.setOutputFile(mFileName);
recorder.setMaxDuration(50000);
recorder.setMaxFileSize(5000000);
}
private void prepareRecorder() {
recorder.setPreviewDisplay(holder.getSurface());
try {
recorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
finish();
} catch (IOException e) {
e.printStackTrace();
finish();
}
}
public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open(findFrontFacingCamera());
camera.unlock();
initRecorder();
prepareRecorder();
}
我该如何纠正?