Tips from RHCEs

Featured Article: Ogg Vorbis, Open Source Audio Utility

Scott McBrien, RHCE, Red Hat Instructor

Most people know about MP3, but due to licensing changes in mp3.org, it is no longer GPL compatable. However, there's been a lot of research into an open source audio compression utility. Enter Ogg Vorbis. Red Hat Enterprise Linux 3 comes with several utilities that are useful for working with Ogg Vorbis formatted files. oggenc is the Ogg Vorbis encoder to generate the files you need, and xmms the standard audio player for Red Hat Enterprise Linux 3 is already compiled with Ogg Vorbis support. To get started you need the vorbis-tools RPM installed and the cdparanoia RPM installed.

Below is a quick script to rip and encode Ogg Vorbis files from an audio CD. It requires that the song names are listed in a file called /tmp/tracknames, each song title on it's own line. Notice you could also glean the songs in interactive mode, but that feature is currently commented out.

#!/bin/bash
echo -n "Enter artist: " 
read artist 
echo -n "Making temporary directory ... " 
if [ -d /tmp/"$artist" ] 
then 
true 
else 
mkdir /tmp/"$artist" 
fi 
echo "Done!" 
echo -n "Changing to temporary directory ... " 
cd /tmp/"$artist" 
echo "Done!" 
echo "Ripping CD in batch mode ... " 
cdparanoia -B 
echo "Done!" 
eject
if [ -e track00.cdda.wav ] 
then 
 rm -f track00.cdda.wav 
fi 
for i in 'seq 1 $(ls *.wav | wc -l)' 
do 
 if [ $i -lt 10 ] 
 then 
#   echo -n "What is the name of track0$i on this album? " 
#   read name 
  echo "Working on track0$i ... "  #   oggenc  track0$i.cdda.wav -o "$artist"\ -\ "$name".ogg 
  oggenc  track0$i.cdda.wav -o "$artist"\ -\ "'head -1 /tmp/tracknames'".ogg 
  tail +2 /tmp/tracknames > /tmp/tmptracknames 
  mv /tmp/tmptracknames /tmp/tracknames 
  echo "Done!" 
  echo -n "Removing track0$i.cdda.wav ... " 
  rm track0$i.cdda.wav 
  echo "Done!" 
  echo 
  echo 
 else 
#   echo -n "What is the name of track$i on this album? " 
#   read name 
  echo "Working on track$i ... " 
#   oggenc  track0$i.cdda.wav -o "$artist"\ -\ "$name".ogg 
  oggenc  track0$i.cdda.wav -o "$artist"\ -\ "'head -1 /tmp/tracknames'".ogg 
  tail +2 /tmp/tracknames > /tmp/tmptracknames 
  mv /tmp/tmptracknames /tmp/tracknames 
  echo "Done!" 
  echo -n "Removing track$i.cdda.wav ... " 
  rm track$i.cdda.wav 
  echo "Done!" 
  echo 
  echo 
 fi 
done
rm /tmp/tmptracknames &> /dev/null 
rm /tmp/tracknames &> /dev/null 

You can do some pretty neat things while encoding into Ogg Vorbis format as well, like embedding the artist, song title, album name, and comment into the Ogg Vorbis file itself. The oggenc man page has full details.