下面的代码在许多设备上成功运行(即使在三星Galaxy Note3上),但它不能在三星Galaxy Note 4上运行,我开始预览然后如果用户按下方法运行下面的保存按钮。 如果我删除setVideSize line eveything在Note 4中正常工作,但如果我添加它,屏幕堆栈。
感谢您的关注。
try {
mCamera.setDisplayOrientation(90);
} catch (Exception e1) {
e1.printStackTrace();
}
List<Camera.Size> sizes = mCamera.getParameters().getSupportedVideoSizes();
mCamera.unlock();
if(mediaRecorder == null)
mediaRecorder = new MediaRecorder();
mediaRecorder.setPreviewDisplay(this.getHolder().getSurface());
if (mCameraId != CameraInfo.CAMERA_FACING_FRONT) {
mediaRecorder.setOrientationHint(90);
}
mediaRecorder.setCamera(mCamera);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
Log.e("W = ",""+sizes.get(0).width);
Log.e("H = ",""+sizes.get(0).height);
mediaRecorder.setVideoSize(sizes.get(0).width, sizes.get(0).height);
mediaRecorder.setOutputFile(fileName);
mediaRecorder.setVideoFrameRate(20);
mediaRecorder.setVideoEncodingBitRate(2000000);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
try {
mediaRecorder.prepare();
mediaRecorder.start();
} catch (Exception e) {
e.printStackTrace();
releaseMediaRecorder();
relaseCamera();
return false;
}
return true;
解
try {
mCamera.setDisplayOrientation(90);
} catch (Exception e1) {
e1.printStackTrace();
}
mCamera.unlock();
mediaRecorder = new MediaRecorder();
mediaRecorder.setCamera(mCamera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
mediaRecorder.setOutputFile(fileName);
mediaRecorder.setVideoSize(1280,720);
mediaRecorder.setVideoFrameRate(20);
mediaRecorder.setVideoEncodingBitRate(2000000);
if(mediaRecorder == null)
mediaRecorder = new MediaRecorder();
mediaRecorder.setPreviewDisplay(this.getHolder().getSurface());
if (mCameraId != CameraInfo.CAMERA_FACING_FRONT) {
mediaRecorder.setOrientationHint(90);
}
try {
mediaRecorder.prepare();
mediaRecorder.start();
} catch (Exception e) {
e.printStackTrace();
releaseMediaRecorder();
relaseCamera();
return false;
}
return true;