How can I convert audio from ogg to mp3?

I use ffmpeg for sound conversion:

ffmpeg -i file.ogg file.mp3
ffmpeg -i file.{ogg,mp3}      # if only the extension changes 

If your filename contains spaces don’t forget to quote it, e.g.:

ffmpeg -i "file with spaces".{ogg,mp3}

To perform batch processing you can either use a for loop like

for i in *.ogg; do ffmpeg -i "$i" "${i%.*}.mp3"; done

or – especially for many and/or large files! – GNU parallel:

parallel ffmpeg -i "{}" "{.}.mp3" ::: *.ogg

This last command will convert every .ogg file in the current directory to .mp3 efficiently using your CPU(s) to perform multiple tasks in parallel.

To set the audio bitrate ffmpeg provides the -b:a BITRATE option, e.g. -b:a 192k. If you want to include metadata like title, album and so on, you can use these options:

-map_metadata 0:s:0 -id3v2_version 3 -write_id3v1 1

See man ffmpeg and this linuxforums.org.uk post for further information.


You can try ogg2mp3.

You can install ogg2mp3 in Ubuntu 12.04 or 13.10 by first getting the debian package file from this ogg2mp3 download page.

Open the .deb file using the Software Center, it will install it for you.

Batch conversion

First put all the files that you want convert into a single folder (let’s call it ogg_src). Then simply give ogg2mp3 the folder path with the appropriate audio parameters (bitrate, channels etc) and it will automatically convert one by one, open a terminal and type:

ogg2mp3 /home/me/ogg_src/ -a 96

For more information please read its manual (including the actual converting tool called lame by using the below commands:

man ogg2mp3
man lame

Source


SoundConverter, which makes use of GUI(Gnome), but can also be used from the command line. Supported Formats Mp3, OGG, AAC, WAV, Flac

Install:

sudo apt-get install soundconverter

Convert:

soundconverter -b -m "mp3" -s ".mp3" /home/za/Music/blackmill.ogg
  • b, --batch Convert in batch mode, from command line, without a graphical user interface.
  • m, --mime-type Set the output MIME type for batch mode. The default is audio/x-vorbis.
  • s, --suffix Set the output filename suffix for batch mode. The default is .ogg.