你好堆栈溢出的朋友。我是安卓新手,有以下代码用于捕获视频。但这在手机上的质量很低(特别是在 android 版本 4.2 上质量非常低)。我需要更高质量的视频捕获,但我不知道其他属性。如何拥有高质量的录像机?
protected void startRecording() throws IOException
{
mCamera.stopPreview();
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.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mrec.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
mrec.setOutputFile(Videopath);
mrec.setPreviewDisplay(surfaceHolder.getSurface());
mrec.prepare();
isRecording=true;
mrec.start();
}
//-------------------------------------------------------------
protected void stopRecording()
{
releaseOnExit();
mCamera = Camera.open();
mCamera.lock();
surfaceView = (SurfaceView) findViewById(R.id.surface_camera);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
Parameters params = mCamera.getParameters();
mCamera.setParameters(params);
mCamera.setDisplayOrientation(90);
try {
mCamera .setPreviewDisplay(surfaceHolder);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
mCamera .startPreview();
btnlistToggle.setEnabled(true);
}
//-------------------------------------------------------------
@Override
public void surfaceCreated(SurfaceHolder holder)
{
if (mCamera != null)
{
Parameters params = mCamera.getParameters();
mCamera.setParameters(params);
mCamera.setDisplayOrientation(90);
try {
mCamera .setPreviewDisplay(holder);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
mCamera .startPreview();
}
else
{
Toast.makeText(getApplicationContext(), "Camera not available!", Toast.LENGTH_LONG).show();
VideoRecorderActivity.this.finish();
}
}
我还有一个录音机,它的质量也很低。 我也为高品质的空洞录音机做了什么?
public void Record() throws IOException
{
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(this.path);
try
{
recorder.prepare();
}
catch (IllegalStateException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
try
{
recorder.start();
}
catch (Exception e)
{
}
}
在stackoverflow上得到了很好的讨论请参阅此链接以了解个人资料
此链接也可能有所帮助。我希望它有所帮助,编码愉快!欢迎来到堆栈溢出社区!