开发者

how can i record audio file as .m4a format?

开发者 https://www.devze.com 2023-04-03 13:11 出处:网络
how can i record audio file as .m4a format. i am using the code below: public void startRecording() throws IOException {

how can i record audio file as .m4a format.

i am using the code below:

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)) {
        th开发者_StackOverflow中文版row 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..


Here's where you set the output format in your example:

recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);

and here is a list of the available output formats which include:

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

and here's more information about supported formats which looks like it supports MPEG-4 audio (m4a) so I assume that you should choose MediaRecorder.OutputFormat.MPEG_4

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号