MediaRecorder以低速录制音频

时间:2014-12-28 18:05:21

标签: android android-mediarecorder

如果我使用MediaRecorder.AudioSource.MIC声音正常录制。如果MediaRecorder.AudioSource.VOICE_DOWNLINK声音播放速度很慢。我需要它VOICE_DOWNLINK。怎么解决?我找到了几个提示:

myAudioRecorder.setAudioSamplingRate(44100);

myAudioRecorder.setAudioSamplingRate(8000);

但它没有帮助

AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL) - 1, 0);
        audioManager.setStreamSolo(AudioManager.STREAM_VOICE_CALL, true);
        myAudioRecorder = new MediaRecorder();

        myAudioRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_DOWNLINK);
        myAudioRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        myAudioRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
        myAudioRecorder.setAudioEncodingBitRate(16);
        myAudioRecorder.setAudioSamplingRate(96000);

1 个答案:

答案 0 :(得分:1)

几天前我在MediaRecorder上工作,我遇到了同样的问题。我通过选择以下选项解决了这个问题,你可以试试这个代码。这个代码适用于MotoE和Samsung Grand 2。

recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
            recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
            recorder.setOutputFile(audiofile.getAbsolutePath());
            recorder.setAudioEncodingBitRate(16);
            recorder.setAudioSamplingRate(16000);`