我正在使用Lame将wav编码为android中的mp3。
http://lame.sourceforge.net/ - LAME,有这个啧啧。 http://developer.samsung.com/android/technical-docs/Porting-and-using-LAME-MP3-on-Android-with-JNI,一切都很好。创建libmp3lame.so和包装器部分。这里的问题是,当我将一个wav文件编码为一个mp3文件时,我会收到一个带有buzzie噪音的输出文件。不确定是否遗漏了任何配置。该守则如下:
// encoding params initializing
public static final int NUM_CHANNELS = 2;
public static final int SAMPLE_RATE = 16000;
public static final int BITRATE = 48;
public static final int MODE = 1;
public static final int QUALITY = 2;
private File mRawFile;
private File mEncodedFile;
// the following is for encoding
initEncoder(NUM_CHANNELS, SAMPLE_RATE, BITRATE, MODE, QUALITY);
File path = Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
// encoding
mRawFile = new File(path, "Vox_021.wav");
mEncodedFile = new File(path, "newmp3.mp3");
int result = encodeFile(mRawFile.getAbsolutePath(),
mEncodedFile.getAbsolutePath());
if (result == 0) {
Log.i("test", "encoded");
}
// / encoding done
wav文件“vox_021.wav”采样率为16000,位深度为16,立体声。我真的不知道为什么编码的mp3文件会输出噪音。在这2天以上的工作,任何帮助将不胜感激。