在我的应用程序中,我使用媒体记录器进行录音。我想使用不同的比特率 32,64,128,160 等。
recorder = new MediaRecorder();
/******Audio Source******/
try{
if(audio_source.equals("Camcorder"))
recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
else if(audio_source.equals("MIC"))
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
else recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
}
catch(Exception e){
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
}
/******Audio Channel******/
try{
if(audio_channel.equalsIgnoreCase("mono")){
recorder.setAudioChannels(1);
}
else if(audio_channel.equalsIgnoreCase("stereo")){
recorder.setAudioChannels(2);
}
}
catch(Exception e){
recorder.setAudioChannels(1);
}
System.out.println(" bitrate -- "+bit_rate);
if (Build.VERSION.SDK_INT >= 10) {
recorder.setAudioSamplingRate(44100);//44100
}
else{
recorder.setAudioSamplingRate(8000);//44100
}
/******AudioEncodingBitRate******/
try{
System.out.println(" in try ..."+bit_rate);
if(bit_rate.equalsIgnoreCase("32")){
recorder.setAudioEncodingBitRate(32000);
}
else if(bit_rate.equalsIgnoreCase("64")){
recorder.setAudioEncodingBitRate(64000);
}
else if(bit_rate.equalsIgnoreCase("96")){
recorder.setAudioEncodingBitRate(96000);
}
else if(bit_rate.equalsIgnoreCase("128")){
recorder.setAudioEncodingBitRate(128000);
}
else if(bit_rate.equalsIgnoreCase("160")){
recorder.setAudioEncodingBitRate(160000);
}
}
catch(Exception e){
recorder.setAudioEncodingBitRate(64);
}
/******File Format******/
//recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
if(format.equals(".mp4"))
{
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
}
else
{
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
}
if (Build.VERSION.SDK_INT >= 10) {
recorder.setAudioSamplingRate(44100);//44100
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
}
else{
recorder.setAudioSamplingRate(8000);//44100
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
}
recorder.setOutputFile(audiofile.getAbsolutePath());
recorder.prepare();
但是使用上述所有不同的比特率条件,我没有得到任何质量变化。我该如何使用它?