ogg to mp3 audio file format conversion

"SoX" (Sound eXchange) is a command line program that can convert most popular audio files to most other popular audio file formats. It can optionally change the audio sample data type and apply one or more sound effects to the file during this translation.

Fedora 3 does not come with "sox" compiled with mp3 support. You will need to download the source and recompile for mp3 support and install it. Else you can grab a prebuilt rpm if you are looking for a quick and easy way out. Download mp3 and lame enabled sox via FreshRPMS.net and install it:

$ wget http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/testing/3/sox-12.17.5-3.fr/sox-12.17.5-3.fr.i386.rpm
# rpm -Uvh sox-12.17.5-3.fr.i386.rpm

You can now begin converting ogg to mp3 via:

$ sox file.ogg file.mp3

Do a batch covert of all ogg files in a folder using the handy one liners as shown below:

$ for x in * ; do mv "$x" `echo -n $x | tr " " "_"`; done
$ for x in *.ogg ; do sox $x `echo $x|awk -F . '{print $1 ".mp3"}'`; done

It first converts all spaces in the file name with underscores and then convert to mp3.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

online tool

If you just had one file you wanted to convert real quick... you could try http://www.oggconvert.com

online tool, nothing to download...works great for linux...

Drama

I have a problem, perhaps it is something obvious.. I have multiple files of different rate/channel count and want to concatenate/merge them. What I do is

sox test*wav -r 44100 -c 2 preview.mp3 pad 0 0.2

but I get

sox FAIL sox: Input files must have the same sample-rate

The same is true for

sox -r 44100 -c 2 test*wav preview.mp3 pad 0 0.2

Better bash code.

Your for loop is pretty ugly.

for f in *.ogg; do lame "$f" "${f%.ogg}.mp3"; done

Err.

sox instead of lame, of course. ;-)

Ubuntu/Debian instructions

Works nice, thanks for posting this. For Ubuntu/Debian users:

mkdir /tmp/sox
cd /tmp/sox
wget http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/testing/3/sox-12.17.5-3.fr/sox-12.17.5-3.fr.i386.rpm
sudo apt-get install alien
sudo alien *.rpm
sudo dpkg -i *.deb

MP3info - ID3 Tag Viewer and Editor

MP3info is a small utility for reading and writing MPEG Layer 3 (MP3) ID3 tags. Console (command-line and interactive ncurses) and GTK versions are included. MP3Info can also display various techincal aspects of an MP3 file including playing time, bit-rate, sampling frequency and other attributes in a pre-defined or user-specifiable output format.

script to transfer ogg file iinformation to MP3 ID3 tags

A script to transfer the information that is stored in the ogg file such as title, artist, etc. can be found here: http://www.fell.it/2009/11/28/convert-ogg-files-to-mp3/. It is a command line version without any GUI, so it's perfect to process folders in a batch.

Reduce audio file size and other effects with sox...

Full CD-quality sound files are very large. In most cases, we won't need the full quality, and would like to reduce the size of the files.

sox can resample a sound file to a different rate.

$ sox -V track10.wav -r 16000 newtrack10.wav

will convert the input file (track10.wav) to one at 16 kHz (newtrack10.wav). If the input file was at 44.1 kHz, the new file will be only 36% as big.

It can also convert a stereo file to mono - this will cut the size in half.

$ sox -V track10.wav -r 16000 -c 1 newtrack10.wav

both reduces the sample rate to 16 kHz, and the number of channels to 1 (monaural).

sox is also able to convert between different audio file formats, and to apply many different filters and special effects to a file.

$ sox track01.mp3 new_track01.ogg pitch 200 echo 1 .5 200 .4

applies a pitch-shift and an echo effect to the input file track01.mp3 and produces an output file of new_track01.ogg .

Enabling mp3 support in SoX - Fedora Core 4

  1. Setup the RPM Build Environment.
  2. Change to the SRPM directory and download the source rpm package for SoX.
    $ wget http://download.fedora.redhat.com/pub/fedora/linux/core/4/SRPMS/sox-12.17.7-3.src.rpm
    
  3. Install required dependant packages for reading and writing mp3 files:
    # yum -y --enablerepo=freshrpms install libmad libmad-devel lame lame-devel
    
  4. Rebuild sox with mp3 support.
    $ rpmbuild --rebuild sox*.src.rpm
    
  5. Change to the RPMS directory of your architecture and install via:
    # rpm -Uvh sox*.rpm --force
    
Comment