Extracting audio from 3gp files using ffmpeg

Extracting audio from a 3gp video file recorded on an Android phone (this was tested on a video file recorded on Google Nexus One running Gingerbread).

First find out what audio format is present in the file:

ffmpeg -i VID_20110518_184415.3gp
.
.
Stream #0.0(eng): Audio: aac, 16000 Hz, mono, s16, 96 kb/s

Turns out, the audio encoded as .aac. Here’s what can be done next:

1. Don’t transcode the audio just extract the audio track as it is:

ffmpeg -i VID_20110518_184415.3gp -vn -acodec copy clarinet.aac

2. Extract audio and transcode it to mp3 at 64kbps:

ffmpeg -i VID_20110518_184415.3gp -vn -acodec libmp3lame -ab 64k clarinet.mp3

3. Extract audio and transcode it to ogg at medium quality:

ffmpeg -i VID_20110518_184415.3gp -vn -acodec libvorbis -aq 50 clarinet.ogg

This can be handy if you want to embed the file using the new HTML5 audio tag. e.g.

<audio controls>
  <source src="clarinet.ogg"/>
  <source src="clarinet.mp3"/>
</audio>

With a lot of help from: http://howto-pages.org/ffmpeg/