Pregunta

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 ?
¿Fue útil?

Otros consejos

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

Try this, change

recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

to

recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top