1

by using above code i am able to generate mp3 file but when i try to validate its format it shows not a mp3

mr = new MediaRecorder();
mr.setAudioSource(MediaRecorder.AudioSource.VOICE_DOWNLINK);
mr.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 
mr.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mr.setOutputFile(Environment.getExternalStorageDirectory()+File.separator+"aa1.mp3");`

How to generate valid mp3 in android

nakul
  • 503
  • 1
  • 7
  • 17
  • This doesn't seem to be possible, since it is patented. See [this question](http://stackoverflow.com/questions/4886365/androidhow-to-get-media-recorder-output-in-mp3-format) for further explanation. – MalaKa Mar 21 '13 at 10:30
  • You're creating an AMR-NB stream in an MPEG-4 container, which obviously doesn't qualify as a valid .mp3 file. MPEG-1 Layer 3 is not listed in MediaRecorder.AudioEncoder, so to save a recording as an .mp3 you'll probably have to record uncompressed PCM and encode the audio data yourself. – Michael Mar 21 '13 at 10:32
  • @Michael if i used aa1.mp4 then the generated mp4 is valid? – nakul Mar 21 '13 at 11:14
  • It should be, but I haven't checked it myself. Note that you probably want to use the AAC encoder instead of AMR-NB, unless you're recording speech and need the files to be really small. – Michael Mar 21 '13 at 11:46

0 Answers0