• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

Converting .ogg files to .mp3

Khyron320

Senior member
Aug 26, 2002
306
0
0
www.khyrolabs.com
I have hours of .ogg files and my new car only plays .mp3s

I have linux mint 7 installed and im very frustrated by how much work i had to do to get SOX to convert .ogg to .mp3s.

It all has to do with licensing i guess.

What im wondering is.... Is there a program i can PAY for on linux that would simplify this task if i had to do it again.

I had to compile about 6 different programs to get SOX to convert these files.

There is no CLEAR guide out there because people are so afraid of the legalities of it its just silly.

I own the MP3 player in the car and id like to be able to use it.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I haven't really compiled anything Linux for years. Off the top of my head I'd probably have just used mplayer to convert the ogg files to wav and then lame to encode them to MP. It's slightly manual, but not difficult.
 

xSauronx

Lifer
Jul 14, 2000
19,582
4
81
SoundConverter should handle this with the appropriate plugins installed for ogg and mp3 support. i havent used it in a while but it worked fine doing FLACs and WAVs to MP3s last time I used it.
 

Praetor

Diamond Member
Oct 14, 1999
4,498
4
81
Shamelessly stolen from another board. See if this works.

synss said:
I recently purchased an iPod and almost all of my music is in ogg, I wrote a short shell-script for the conversion. It works and you get the idea if you want to expand it, it only does what I need right now...
Code:
#!/bin/sh
# (c) Mathias Laurin, Tokyo, 20070220, GPLv2
# Dep: oggdec and lame
#
# Takes a filename as argument, use for loops or
# find for batch processing!

INFILE="$1"
MYPATH="$2"

#VERBOSE=1

# Quality / approx bitrate
#(HQ)     -V0 245  # -V1 225  # -V2 190  # -V3 175
#(mid Q)  -V4 165  # -V5 130  # -V6 115
#(low Q)  -V7 100  # -V8 85  # -V9 65
LAMEARGS="-V5 --vbr-new"
LAMEARGS="$LAMEARGS --replaygain-fast"
#LAMEARGS="$LAMEARGS --quiet"

if [ "${INFILE##*.}" = "ogg" ]
then
        echo "<<< $INFILE"

        # set/create new directory and filename.mp3
        OUTFILE=$(basename "${INFILE%ogg}mp3")
        OUTPATH="${MYPATH:-.}/$(dirname "$INFILE")"

        if [ -e "$OUTPATH/$OUTFILE" ]
        then
                # Skip encoding if the file already exists
                echo "$OUTPATH/$OUTFILE already exists, skipping"
                exit
        fi

        [ ! $DEBUG ] && \
                [ ! -d "$OUTPATH" ] && mkdir -p "$OUTPATH"

        # get ogginfo once
        INFO="$(ogginfo "$INFILE")"

        # parse tags
        ARTIST="$(echo "$INFO" | awk 'BEGIN { IGNORECASE = 1; FS = "="}
/^[ \t\f\n\r\v]Artist=/ { print $2 }')"
        [ -n "$ARTIST" ] || ARTIST="Anonymous"
        ALBUM="$(echo "$INFO" | awk 'BEGIN { IGNORECASE = 1; FS = "="}
/^[ \t\f\n\r\v]Album=/ { print $2 }')"
        [ -n "$ALBUM" ] || ALBUM="Untitled"
        GENRE="$(echo "$INFO" | awk 'BEGIN { IGNORECASE = 1; FS = "="}
/^[ \t\f\n\r\v]Genre=/ { print $2 }')"
        [ -n "$GENRE" ] || GENRE="0"
        TITLE="$(echo "$INFO" | awk 'BEGIN { IGNORECASE = 1; FS = "="}
/^[ \t\f\n\r\v]Title=/ { print $2 }')"
        [ -n "$TITLE" ] || TITLE="Untitled"
        DISC="$(echo "$INFO" | awk 'BEGIN { IGNORECASE = 1; FS = "="}
/^[ \t\f\n\r\v]Disc=/ { print $2 }')"
        #[ -n "$DISC" ] || DISC=
        TRACK="$(echo "$INFO" | awk 'BEGIN { IGNORECASE = 1; FS = "="}
/^[ \t\f\n\r\v]Tracknumber=/ { print $2 }')"
        [ -n "$TRACK" ] || TRACK="00"
        #[ "$#TRACK" = "1" ] && TRACK="0$TRACK"
        YEAR="$(echo "$INFO" | awk 'BEGIN { IGNORECASE = 1; FS = "="}
/^[ \t\f\n\r\v]Date=/ { print $2 }')"
        [ -n "$YEAR" ] || YEAR="00"


        # on-the-fly re-encoding
        echo ">>> $OUTPATH/$OUTFILE"
        if [ $VERBOSE ]
        then
                echo "$ARTIST"
                echo "$ALBUM"
                echo "$GENRE"
                echo "$DISC$TRACK"
        fi
        oggdec -Q "$INFILE" -o - | lame "$LAMEARGS" --ta "$ARTIST" --tl "$ALBUM" --tg "$GENRE" --tt "$TITLE" --tn "$DISC$TRACK" --ty "$YEAR" - "$OUTPATH/$OUTFILE"

fi

First argument is filename.ogg, second optional argument is the output directory.


For using in a single directory
Code:
for n in *; do ogg2mp3.sh "$n"; done
for a bunch of files
Code:
find . -name "*.ogg" -print0 | xargs -0 -I'{}' ogg2mp3.sh '{}' /path/to/somewhere/else
should do
 

Khyron320

Senior member
Aug 26, 2002
306
0
0
www.khyrolabs.com
Thank you Praetor but i have it all working. My complaint is i had to compile stuff from source to make it work. There has to be an easier way, because 1 year from now ill probably get a new machine and have to do this all over again =P

In case your wondering here is the command in sox to convert files once u have it working

sox file.ogg file.mp3
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Thank you Praetor but i have it all working. My complaint is i had to compile stuff from source to make it work. There has to be an easier way, because 1 year from now ill probably get a new machine and have to do this all over again =P

In case your wondering here is the command in sox to convert files once u have it working

sox file.ogg file.mp3

Then make sure you get yourself an audio player that supports formats that aren't encumbered by licensing. =)

Oh and I'd bet that mencoder would do what you want in one command as well.
 

Scarpozzi

Lifer
Jun 13, 2000
26,392
1,780
126
I prefer Windows for conversion utilities to mp3 simply because rather than typing or scripting commands, you can simply drag & drop a list of files to convert. I haven't had to do conversions for a long time since I just rip to mp3 in the first place, but if you can setup an NFS or Samba Mount to a windows box you can probably save yourself a lot of time with the right util.