我有这个用于在Android上捕获视频的代码。但是这段代码抛出RuntimeException
。我搜索了那个,但我无法得到答复。记录是:
errorrrrrrrrr runtime44444444444!!!
什么行有错误???
private void startRecording()
{
mCamera.unlock();
mrec = new MediaRecorder();
mrec.setCamera(mCamera);
mrec.setAudioSource(MediaRecorder.AudioSource.MIC);
mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mrec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mrec.setVideoFrameRate(24);
mrec.setVideoSize(720, 480);
Method[] methods = mrec.getClass().getMethods();
for (Method method: methods){
try
{
if(method.getName().equals("setAudioEncodingBitRate"))
{
method.invoke(mrec,12200);
}
else if(method.getName().equals("setVideoEncodingBitRate"))
{
method.invoke(mrec, 3000000);
}
else if(method.getName().equals("setAudioSamplingRate"))
{
method.invoke(mrec,8000);
}
else if(method.getName().equals("setVideoFrameRate"))
{
method.invoke(mrec,24);
}
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
catch (InvocationTargetException e)
{
e.printStackTrace();
}
catch (RuntimeException e)
{
Log.d("errorrrrrrrrr runtime111111111", "okkkkkkkkkk");
e.printStackTrace();
}
}
mrec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mrec.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mrec.setPreviewDisplay(surfaceHolder.getSurface());
mrec.setOrientationHint(90);
mrec.setOutputFile(Videopath);
try
{
mrec.prepare();
}
catch (IllegalStateException e)
{
// releaseRecorder();
// return false;
}
catch (IOException e)
{
// releaseRecorder();
// return false;
}
catch (RuntimeException e)
{
e.printStackTrace();
}
catch(Exception e)
{
// return false;
}
try
{
mrec.start();
}
catch (RuntimeException e)
{
Log.d("errorrrrrrrrr runtime44444444444", "okkkkkkkkkk");
e.printStackTrace();
}
catch(Exception e)
{
// return false;
Log.d("errorrrrrrrrr 33333333333", "okkkkkkkkkk");
}
isRecording=true;
// return true;
}