Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Record .m4a file Android

How can i record M4A audio file with MediaRecorder in Android 2.2 ?
What output format, encoder and sampling rate i need to set ?

I need to record it from microphone and save it in SDCARD

UPDATE

I tried this code, but the result doesn't valid (not play in browser for example):

recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); // error here ?!?
recorder.setAudioSamplingRate(96000); // what value ?
like image 780
enfix Avatar asked Sep 27 '12 19:09

enfix


2 Answers

These codes work to produce an m4a file:

    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.HE_AAC);

or

    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);

with

    mRecorder.setAudioChannels(1);
    mRecorder.setAudioSamplingRate(44100);
    mRecorder.setAudioEncodingBitRate(96000);
    mRecorder.setOutputFile(absFilePath);// must have an .m4a extension
like image 51
BinCodinLong Avatar answered Oct 06 '22 01:10

BinCodinLong


Try the bellow link

how can i record audio file as .m4a format?

OR

http://www.benmccann.com/blog/android-audio-recording-tutorial/

this may help you.

like image 39
bashu Avatar answered Oct 06 '22 01:10

bashu