如何将音频文件录制为 .m4a 格式。
我正在使用下面的代码:
public void startRecording() throws IOException {
recorder = new MediaRecorder();
path = "/sdcard/pithysongs_" + System.currentTimeMillis() + ".m4a";
String state = android.os.Environment.getExternalStorageState();
if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
throw new IOException("SD Card is not mounted. It is " + state
+ ".");
}
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);
recorder.prepare();
recorder.start();
}
thanks..
您可以在示例中设置输出格式:
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
and here http://developer.android.com/reference/android/media/MediaRecorder.OutputFormat.html是可用输出格式的列表,其中包括:
AMR_WB AMR WB file format
DEFAULT
MPEG_4 MPEG4 media file format
RAW_AMR AMR NB file format
THREE_GPP 3GPP media file format
这是更多信息 http://developer.android.com/guide/appendix/media-formats.html关于支持的格式,看起来它支持 MPEG-4 音频 (m4a),所以我assume你应该选择MediaRecorder.OutputFormat.MPEG_4
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)