5

I have to record voice in OGG/MP3 format using Android MediaRecorder. I need these formats to play with HTML5 audio tag. The android documentation specifies in MediaRecorder.OutputFormat class about the formats but do not speak anything about which output format equals mp3 and ogg.

Whereas documentation also says that android supports mp3 and ogg vorbis on Supported Media Formats page. Very much confused, please clarify.

Nidheesh
  • 4,390
  • 29
  • 87
  • 150
RamKr
  • 756
  • 10
  • 17

1 Answers1

4

None of the formats equals mp3 or ogg.

Android supports decoding Vorbis and MP3 audio according to the media formats documentation - not encoding.

With the built-in tools the closest you can probably get is one of the AAC_* codecs inside of an MPEG_4 file. AAC is designed as a successor to the MP3 file format.

But for an .ogg file you need to encode the audio with Vorbis encoder (to get the audio frames) and then package it inside an Ogg container.

If you really require Vorbis or MP3, there are few questions touching the subject already:

For most purposes I'd imagine having AudioEncoder set to one of the AAC_* formats and OutputFormat set to MPEG_4 should provide you with a file that could be played back in most modern (audio) applications.

Community
  • 1
  • 1
Mikko Rantanen
  • 7,884
  • 2
  • 32
  • 47
  • 1
    Thanks @Mikko Rantanen. Your suggestions are helpful. I also went through media jargon like media container, codecs and now I understand it better. I created a recording with **Media File** set to `MPEG_4` and **Audio Codec** set to `AAC` and saved the file with `.mp3` extension. Its working in `HTML5 – RamKr May 27 '14 at 10:00
  • 2
    Thanks a lot! Your direction worked and I am using `AAC` encoder with `MPEG_4` output format in Android. BTW I didn't find any conversion library in Android and stick to the above solution. – RamKr May 28 '14 at 09:54
  • I think Android now supports encoding Vorbis no? With `MediaRecorder.AudioEncoder.VORBIS`? – Noitidart Jun 09 '17 at 23:58
  • Thanks you solution worked after searching for hours for a solution!!!! – Vibhanshu Biswas Jan 23 '20 at 20:21