gpt4 book ai didi

android - 如何为媒体录音机android使用不同的音频编码比特率

转载 作者:搜寻专家 更新时间:2023-11-01 07:59:26 25 4
gpt4 key购买 nike

在我的应用程序中,我使用媒体录音机进行录音。我想使用不同的比特率 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();

但是使用上述所有不同的比特率条件,我没有得到任何质量变化。我该如何使用它?

最佳答案

根据documentation比特率以每秒位数设置,

Prepare() may perform additional checks on the parameter to make sure whether the specified bit rate is applicable, and sometimes the passed bitRate will be clipped internally to ensure the audio recording can proceed smoothly based on the capabilities of the platform.

我假设,在这种情况下发生了削波,因为即使每秒 160 位也低得离谱。

关于android - 如何为媒体录音机android使用不同的音频编码比特率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23266492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com