mCamera.stopPreview();
mCamera.unlock();
mediarecorder = new MediaRecorder();
mediarecorder.setCamera(mCamera);
mediarecorder.setOrientationHint(0); // 录像文件翻转
mediarecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediarecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
// CamcorderProfile profile = CamcorderProfile
// .get(CamcorderProfile.QUALITY_QCIF);
// mediarecorder.setProfile(profile);
// 设置录制完成后视频的封装格式THREE_GPP为3gp.MPEG_4为mp4
mediarecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
// 设置录制的视频编码h263 h264
mediarecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediarecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mediarecorder.setVideoEncodingBitRate(bitRate);
// 设置视频录制的分辨率。必须放在设置编码和格式的后面,否则报错
mediarecorder.setVideoSize(psize.width, psize.height);
// 设置录制的视频帧率。必须放在设置编码和格式的后面,否则报错
mediarecorder.setVideoFrameRate(24);
Log.i(TAG, "测试1");
mediarecorder.setOutputFile(PathHelper.getVideoPath(context));
Log.i(TAG, "测试2");
mediarecorder.setPreviewDisplay(surfaceHolder.getSurface());
try{
// 准备录制
mediarecorder.prepare();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try{
mediarecorder.start();
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
错误就是在这句,其它手机没出现这个错误,原因不明,删除就OK了:
mediarecorder.setVideoFrameRate(24);