我该如何以 .m4a 格式录制音频文件?

3

我该如何将音频文件录制为.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..

1个回答

8
这是您在示例中设置输出格式的位置:
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);

这里是一个包含可用输出格式的列表,包括:

链接
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

这里有关于支持格式的更多信息,看起来它支持MPEG-4音频(m4a),因此我推测您应该选择MediaRecorder.OutputFormat.MPEG_4


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接