2011-08-02 37 views
0

我试图记录高品质的视频,我用记录媒体记录器类的示例代码如下所示的视频,需要使用Media recorder在Android 2.1中录制高品质视频的代码?

recorder = new MediaRecorder(); 

    recorder.setAudioSource(MediaRecorder.AudioSource.MIC); 
    recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); 
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 
    recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); 

但质量不如使用默认的摄像头拍摄的视频为好。 因为版本是2.1,我甚至不能在这里设置Camcorderprofile。该视频看起来很差,质量有些扭曲。

样品视频...... http://videoxplode.com/player.php?id=808490

我需要一种方法来捕获使用介质记录在Android 2.1的视频。

如果有人知道意味着帮助我。

谢谢。

+0

从视频中这是很难说,但你想捕捉什么分辨率对不起? –

+0

720,480分辨率.. – Karthi

回答

2

最后,我发现了通过设置videEncodingBitRate,AudioEncodingBitRate,AudioSamplingRate等等来在android 2.1中记录高质量视频的代码。使用这种方法,您可以为视频设置任何想要提供高质量视频的属性。

为了设定高的品质和低的质量参数是指当前页,

http://www.andgps.com/20110410/camcorderprofile-predefined-camcorder-profile-settings-for-camcorder-applications

我用碱Android 2.1版本,以产生高品质的视频中使用的代码如下所示,`录音机=新MediaRecorder() ; Method [] methods = recorder.getClass()。getMethods();

recorder.setAudioSource(MediaRecorder.AudioSource.MIC); 
    recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); 
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 
    recorder.setVideoFrameRate(24); 
    recorder.setVideoSize(720, 480); 

    for (Method method: methods){ 
    try{ 
     if (method.getName().equals("setAudioChannels")){ 
       method.invoke(recorder, String.format("audio-param-number-of-channels=%d", 1)); 
     } 
     else if(method.getName().equals("setAudioEncodingBitRate")){ 
       method.invoke(recorder,12200); 
      } 
     else if(method.getName().equals("setVideoEncodingBitRate")){ 
      method.invoke(recorder, 3000000); 
     } 
     else if(method.getName().equals("setAudioSamplingRate")){ 
      method.invoke(recorder,8000); 
     } 
     else if(method.getName().equals("setVideoFrameRate")){ 
      method.invoke(recorder,24); 
     } 
    }catch (IllegalArgumentException e) { 

     e.printStackTrace(); 
    } catch (IllegalAccessException e) { 

     e.printStackTrace(); 
    } catch (InvocationTargetException e) { 

     e.printStackTrace(); 
    } 
    } 

    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 
    recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); 

`