[Nottingham] Converting mp3 to ogg

Camilo Mesias camilo at mesias.co.uk
Sun Aug 16 00:51:13 UTC 2009


Hi

I once had to do a similar thing to convert ogg back to mp3, because
although we once had ogg-friendly personal music players, we ended up
with several that would play mp3 but not ogg. Although ogg is a noble
cause, mp3 is very much the de-facto format.

Converting the audio seems quite easy, you might even be able to
stream the intermediate wav through pipes to avoid having huge
temporary files. I didn't manage to do that, instead I decoded and
re-encoded the files one at a time. I used oggdec and lame.

I digress. I wanted to say - the easy bit is converting the audio. It
was much harder to get the tag information copied across correctly,
for all files even ones with annoying non-ascii characters or missing
tags. I used a combination of shell and Perl scripts like this:

# decode the ogg file
oggdec "$1" -q -o $wavfile || success=no

if [ $success = "yes" ] ; then
  # re-encode as mp3
  mkdir -p "$mp3dir"
  lame --quiet $wavfile "$mp3file" || success=no

  if [ $success = "yes" ] ; then
    # transfer tags
    oggtagtomp3tag.pl "$oggfile" "$mp3file"
  else
    echo "Failed to lame up $wavfile (from $oggfile to $mp3file)"
  fi

The Perl script to transfer the tags was considerably more messy than
that - so, if anyone knows of a tool that manages the audio and does
sensible things with tags, supports the different versions of mp3tags,
even letting you control which charset / encoding is used, I'd be very
interested.

-Cam



More information about the Nottingham mailing list