
this.mediaRecorder = new MediaRecorder();this.mediaRecorder.setAudioChannels(1);this.mediaRecorder.setAudioSamplingRate(8000);this.mediaRecorder.setAudioEnCodingBitRate(16);this.mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);this.mediaRecorder.setoutputFormat(MediaRecorder.OutputFormat.RAW_AMR);this.mediaRecorder.setoutputfile(this.file.getabsolutePath());this.mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
我用过.mediaRecorder.setAudioEnCodingBitRate(16),有些设备还可以
mediaRecorder.setAudioEnCodingBitRate(12500),有些设备没问题
但是我删除了mediaRecorder.setAudioEnCodingBitRate,有些设备还可以
所以我的问题是如何获得默认的AudioEnCodingBitRate.
我需要使用哪个参数?
这似乎有效:
MediaRecorder recorder = new MediaRecorder();recorder.setAudioSource(MediaRecorder.AudioSource.MIC);if (Build.VERSION.SDK_INT >= 10) { recorder.setAudioSamplingRate(44100); recorder.setAudioEnCodingBitRate(96000); recorder.setoutputFormat(MediaRecorder.OutputFormat.MPEG_4); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);} else { // older version of AndroID,use crappy sounding voice codec recorder.setAudioSamplingRate(8000); recorder.setAudioEnCodingBitRate(12200); recorder.setoutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);}recorder.setoutputfile(file.getabsolutePath());try { recorder.prepare();} catch (IOException e) { throw new RuntimeException(e);} 这个想法来自here
加:阅读文档. setAudioSamplingRate的文档说明如下:
总结The sampling rate really depends on the format for the audio recording,as well as the capabilitIEs of the platform. For instance,the sampling rate supported by AAC audio Coding standard ranges from 8 to 96 kHz,the sampling rate supported by AMRNB is 8kHz,and the sampling rate supported by AMRWB is 16kHz.
以上是内存溢出为你收集整理的android – 记录语音有什么好的setAudioEncodingBitRate全部内容,希望文章能够帮你解决android – 记录语音有什么好的setAudioEncodingBitRate所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)