我正在努力解决这个问题,我已经改变了比特率以减少录制文件大小,我的应用程序正确地将音频文件发布到服务器,但我想最小化文件大小,这是我的记录代码
private void startRecording() throws IOException {
String state = android.os.Environment.getExternalStorageState();
if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
throw new IOException("No SD mounted. It is" + state
+ ".");
}
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setAudioSamplingRate(44100);
mRecorder.setAudioEncodingBitRate(44100);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
File path = new File(Environment.getExternalStorageDirectory()
.getPath());
if (!path.exists() && !path.mkdirs()) {
throw new IOException("The file directory is invalid.");
}else{
try {
archivo = File.createTempFile("audio", ".3gp", path);
} catch (IOException e) {
}
}
mRecorder.setOutputFile(archivo.getAbsolutePath());
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}
我现在正在进行一分钟录制336 kb,我想 减少到每分钟大约100 - 200 kb而不会松动 质量很高
答案 0 :(得分:1)
你可以试试几件事。
1)使用AMR(自适应多速率)进行更高压缩:
recorder.setAudioEncoder(mRecorder.AudioEncoder.AMR_NB);
AMR宽带和AMR窄带是设备用于电话呼叫的编码方法。可能没有你所需的质量。
2)使用mono 1频道:
mRecorder.setAudioChannels (1)
// Sets the number of audio channels for recording. Call this method before
// prepare().
// Usually it is either 1 (mono) or 2 (stereo).