问题描述
我已经录制的声音与Android AudioRecord,我想将它转化成的Ogg Vorbis,因为它是无专利。我已经尝试Vorbis格式-java的测试版,但它似乎没有工作,或者我做一些错误的。
I have recorded voice with android AudioRecord and I would like to convert it to ogg vorbis as it is patent free. I have try vorbis-java beta, but it seem not work or I make some mistake.
下面是我的code:
int frequency = 44100;
int channel = AudioFormat.CHANNEL_IN_STEREO;
int mAudioSource = MediaRecorder.AudioSource.MIC;
int mAudioEncoder = AudioFormat.ENCODING_PCM_16BIT;
try {
final File outputFile = new File(mOutputPath);
DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile)));
int bufferSize = AudioRecord.getMinBufferSize(frequency, channel, mAudioEncoder);
AudioRecord audioRecord = new AudioRecord(mAudioSource, frequency, channel, mAudioEncoder, bufferSize);
short[] buffer = new short[bufferSize];
audioRecord.startRecording();
while (isRecordStart) {
int bufferReadResult = audioRecord.read(buffer, 0, bufferSize);
for(int i = 0; i < bufferReadResult; i++) {
dos.writeShort(buffer[i]);
}
}
audioRecord.stop();
dos.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
我将它保存到扩展名为WAV的文件,并使用例如Vorbis格式-Java来恩code,但产量只有ZZZ .......
I save it to a file with extension wav and use example of vorbis-java to encode, but output is only zzz.......
如何连接code这的Ogg Vorbis android系统?
How to encode this to ogg vorbis in android?
推荐答案
我觉得我在几个星期前阅读了这个问题,也是超级沮丧。我结束了写作所需要的NDK包装使用Xiph.org的东西。唯一的缺点是,为了使其运行良好,我不得不启用浮点指令。仿真器不具备浮点运算,所以它会崩溃的模拟器。它运行在pretty的多的任何电话,不过,你会好到哪里去。它被设计来模拟一个FileInputStream和FileOutputStream中用于与Vorbis文件连接。
I think i read this question a few weeks ago and was also super frustrated. I ended up writing the needed ndk wrapper to use Xiph.org's stuff. The only catch is that in order to make it run well, I had to enable floating point instructions. Emulators don't have floating point, so it'll crash the emulator. Run it on pretty much any phone, though, and you'll be good to go. It's designed to emulate a FileInputStream and FileOutputStream for interfacing with the vorbis files.
https://github.com/nwertzberger/libogg-vorbis-android
这篇关于如何连接code中记录声音的Ogg Vorbis?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!