"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.
- sandip's blog
- Login or register to post comments
Comments
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...
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
Your for loop is pretty ugly.
for f in *.ogg; do lame "$f" "${f%.ogg}.mp3"; done
sox instead of lame, of course. ;-)
Works nice, thanks for posting this. For Ubuntu/Debian users:
mkdir /tmp/sox reshrpms/fedora/linux/testing/ 3/sox-12.17.5-3.fr/sox-12.17.5 -3.fr.i386.rpm
cd /tmp/sox
wget http://ftp.freshrpms.net/pub/f
sudo apt-get install alien
sudo alien *.rpm
sudo dpkg -i *.deb
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.
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.
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.
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.
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.
applies a pitch-shift and an echo effect to the input file track01.mp3 and produces an output file of new_track01.ogg .
Setup the RPM Build Environment. Change to the SRPM directory and download the source rpm package for SoX.
Install required dependant packages for reading and writing mp3 files: Rebuild sox with mp3 support. Change to the RPMS directory of your architecture and install via: