【发布时间】:2014-04-24 10:37:57
【问题描述】:
在我的应用程序中,我使用媒体记录器进行音频录制。 我想使用不同的比特率 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();
但是使用上述所有不同的比特率条件,我没有得到任何质量变化。 我该如何使用它?
【问题讨论】:
-
MPEG4 是 容器 格式。您似乎没有指定要使用的 编码器 (
setAudioEncoder)。默认编码器是 AMR_NB 的可能性很大,它具有非常低的最大比特率和固定的采样率。 -
我用过。 AMR_NB.查看更新的代码
-
在这种情况下,请参阅我之前评论的第二部分。如果您想要更高质量的录音,请指定其他编码器,例如 AAC。
-
但我想要比特率明智的质量。我提供比特率选项,如 32,64,128 ...
-
AMR_NB 的最大比特率为 12.2 kbit/s,采样率固定(8000 Hz)。再次;如果您期望质量不错的东西,请使用其他编码器。
标签: android mediarecorder bitrate