如何将音频文件录制为.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();
}
感谢..
答案 0 :(得分:7)
您可以在此处设置示例中的输出格式:
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
和here是可用输出格式的列表,其中包括:
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
以及more information关于支持的格式,看起来它支持MPEG-4音频(m4a)所以我假设你应该选择MediaRecorder.OutputFormat.MPEG_4