开发者

Need a code for record a video with high quality in android 2.1 using Media recorder?

i try to record the video with high quality , i record the video using media recorder class the sample code is shown below,

 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);

but the quality is not as good as video captured using defaul开发者_JAVA百科t camera. I can`t even set Camcorderprofile here because the version is 2.1. The video is looking poor quality some what distorted.

sample video... http://videoxplode.com/player.php?id=808490

I need a way to capture the video using media recorder in android 2.1.

if any one knows means help me out.

Thanks.


Finally i found the code to record high quality video in android 2.1 by setting videEncodingBitRate , AudioEncodingBitRate, AudioSamplingRate ...etc. Using this method you can set the properties for video whatever you want to provide high quality video.

For setting high quality and low quality parameter refer this page,

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

The code i used with base version android 2.1 to produce high quality video is shown below,`recorder = new 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);

`

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜