Android : Record sound in mp3 format

Viewed 43281

I am building an android app, having feature of capturing sound through microphone and playing it through headphone. For this, I have used "AudioRecord" and "AudioTrack". Following is some part of code that I am using,(just for understanding)

mInBufferSize = AudioRecord.getMinBufferSize(mSampleRate,
            AudioFormat.CHANNEL_CONFIGURATION_MONO, mFormat);
mOutBufferSize = AudioTrack.getMinBufferSize(mSampleRate,
            AudioFormat.CHANNEL_CONFIGURATION_MONO, mFormat);
mAudioInput = new AudioRecord(MediaRecorder.AudioSource.MIC,
            mSampleRate, AudioFormat.CHANNEL_CONFIGURATION_MONO, mFormat,
            mInBufferSize);
mAudioOutput = new AudioTrack(AudioManager.STREAM_MUSIC, mSampleRate,
            AudioFormat.CHANNEL_CONFIGURATION_MONO, mFormat,
            mOutBufferSize, AudioTrack.MODE_STREAM);

But the main problem is that I want to record incoming sound in mp3 format? Please help me in this, I will really appreciate...

Thanks in Advance

6 Answers

I know this is an old question. but if it will help someone I created a repository with an android java full recording app demo, the output file is an mp3 file. keep in mind, I set the target sdk to 21 if to eliminate the need for requesting user permission. this is only for the demo purposes. you can clone and use it.

Most of the code I used is from this repo: this

My demo repo: mp3 recording app

Related