我正在尝试开始录制视频,但程序会在“recorder.start();”行中粉碎。 该计划在华为D1 (8 Mpx)稳定,但在 HTC Desure C (5 Mpx)程序开始出错时
错误:
W/dalvikvm(18833): threadid=1: thread exiting with uncaught exception (group=0x40a8b228)
E/AndroidRuntime(18833): FATAL EXCEPTION: main
E/AndroidRuntime(18833): java.lang.RuntimeException: start failed.
代码:
public void startRec(SurfaceHolder surfaceHolder, String VideoName) {
camera.stopPreview();
camera.unlock();
recorder.setCamera(camera);
setRecorderParams();
recorder.setPreviewDisplay(surfaceHolder.getSurface());
recorder.setOutputFile(VideoName);
try {
recorder.prepare();
recorder.start();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void setRecorderParams() {
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
recorder.setVideoEncodingBitRate(30000);
recorder.setVideoSize(640, 480);
}