Help - Search - Members - Calendar
Full Version: Linux audio cd back-up
Hydrogenaudio Forums > Hydrogenaudio Forum > General Audio
bugmenot
I am going to write three scripts to automate the backup process of my cd collection. The ripping script will be fully automated, i.e. a cd is ripped and immidiately played back simply by inserting it in the tray. No screen, no keyboard. So while my wife is at home listening to music she will do the ripping... A second script, running at night will parse log files for errors (so that I will only double check manually problematic rips), encode wav/bin files into flac, rename etc etc... A third script will decode falc/split/transcode/tag for other devices (mp3/ogg player).

Usual objective.... 1:1 bacup i.e. I should always be able to recreate a bit perfect cd from the backup. Which translates to: "I am not going to rip my collection twice"...

Usual tools as well: cdparanoia+cdrdao+flac+cddb.

Here are my questions, arguably some of them quite stupid (please be forgiving):
  1. Is the Single_File (e.g. cdparanoia "1-" or cdrdao read-cd) good enough to achieve 1:1 backup? Does it include pre-graps, hidden tracks etc...? Particularly, isn't the "1-" option in cdparanoia dangerous for hidden tracks (don't they start before track 1? I noticed though that 1- = sector 0) ? I assume it is ok, just need a confimation.
  2. Is the mapping Track_Files <-> Single_File bidirectional? E.g. using cdparanoia -B "1-" (or equivalent) can I join the individual tracks later on and get back the same file I would get if I ripped in one file? Assuming the relationship is bidirectional, do I need to merge them back at all before restoring the cd in case of damage? ...Maybe the tracks#.wav+toc file are enough for cdrdao...
  3. What are the main differences between cdparanoia/cdda2wav/cdrdao_read-cd when using the paranoia library? Do they use the same library? In cdrdao it is embedded in the code, it might not be identical... Which one is reccommended?
  4. I read that there might be problems with cdparanoia when using cd drives that cache data. How can I detect if I have such device?
  5. I need to log any ripping error. On the web (http://www.xiph.org/paranoia/manual.html) I noticed that cdparanoia has an --output-info flag. Exactly what I need, unfortunately, I do not get that on my distro package (Gentoo, cdparanoia III release 9.8 March/3/2001). Is this functionality active? If it isn't how can I reproduce it? Redirecting stdout to file won't do since the progress statistics create a huge file by adding a line at each screen refresh. It looks to me that stderr does not contain enough info, I will need to test it on a scratched cd. Same thing for other rippers, how do you get a useful log (see --output-info)?
  6. What exactly is --read-raw option in cdrdao for? If I use cdrdao read-cd don't I get a raw file to begin with? And yes... I read the man, and... I do not understand it.
  7. If I use flac to encode a .bin file, when decoding can I get back directly a wav file or do I always get back a .bin file which then needs to be transcoded to wav?
  8. Can I detect in a script little/big endian, signed/unsigned settings to pass to flac?
  9. I use cdrdao to extract a toc, but toc2cue does not seem to work, it creates an empty file. Any suggestion?
bugmenot
Here is my first script so far. It is a simple bash script to rip and playback by simply inserting the CDs into the tray, no interface is needed, no screen nor keyboard... You only need to use the eject button to play and rip... So everybody that listen to my CDs is in fact helping me ripping them. smile.gif

Next script will be a batch that runs at night, it should convert TOC to CUE (I have problems to do that now using toc2cue), compress to flac, and then rename the folders. Furthermore it will scan the log and alert me of any rip with potential problems.

Third script will take a list of folders and convert all the flac files in there into mp3/ogg, track separated + tags and save it to a target folder, in case I want to listen to my music over mp3 player.

Fourth script will allow me to change CDDB info manually ex-post or half manually (selecting from a list of possible matches), changing flac meta info, TOC, and renaming...
bugmenot
NOTE the script below, might have errors and it might have to be adapted to suit your need. You need to change the variable MUSICDIR, check the requirements. No guarantee whatsoever. Suggestions are welcome. Answers to the questions above as well... To use it simply run the script in the background and insert a cd into the tray (under a user with write permissions in MUSICDIR), enjoy the music, and when the CD is ejected you can insert another CD.

CODE
#!/bin/bash

#GPL License (as in http://www.gnu.org/copyleft/gpl.html)
#Copyright Ago

# Rip and playback by simply inserting the CDs into the tray, no interface is needed.
# The CD is backed up as a single wav file (using cdparanoia), it also saves discid,
# and cdrdao TOC with CDDB info. A few seconds after ripping starts, the cd is also
# played back (from HD). If there are errors, the ripping will naturally be slower
# than playback so the music will stop, furthermore errors should (hopefully) be logged.
# If a CD was already ripped, it will still play the album, but off the HD while
# the CD itself is ejected immidiately. You can stop ripping at any time by pressing eject.
# If a CD wasn't fully ripped, next time you insert the same cd it will be ripped from scratch.

#REQUIRES
#sox/play
#cdctl
#cdparanoia
#cdrdao

#START PARAMETERS

DEV=/dev/cdrom
MUSICDIR=/PATH/WHERE/MUSIC/IS/RIPPED
PLAY=true #shall we play when we rip?
PLAYER=play #mplayer does not work it caches the file
EJECT="cdctl -e"
DISCID="cd-discid $DEV"
RIP="cdparanoia -v -s -z -- 1- album.wav"
TOC="cdrdao read-toc --device $DEV --driver generic-mmc --with-cddb album.toc"

#END PARAMETERS

if ps -ef | grep $0 | grep -v grep | grep -v $$ > /dev/null; then
   echo "`basename $0` is already running..."
   exit 1
fi
echo "Waiting for CD..."
while (true); do
   #Try to get DISCID
   FULLID=$($DISCID 2> /dev/null)
   #Check if a CD is inserted
   if [ -z "$FULLID" ]; then
       sleep 2
   else
       ID=${FULLID%%" "*}
       echo "Audio CD $ID detected"
       #Get the directory to use
       DIR=$MUSICDIR/$ID
       if [ ! -d $DIR ]; then
           IDFILE=$(grep ^$ID" " $MUSICDIR/* --include=album.id -rl|head -n 1)
           if [ -f $IDFILE ]; then
               DIR=$(dirname $IDFILE)
           fi
       fi

       #Check if the CD was already ripped
       if [ -f $DIR/album.id ]; then
           #CD already ripped
           echo "CD $ID already ripped in $DIR"
           $EJECT
       else
           #Rip
           killall cdparanoia &> /dev/null
           killall cdrdao &> /dev/null
           if [ -d $DIR ]; then
               rm -f  $DIR/*
           else
               mkdir $DIR
           fi
           cd $DIR
           echo "Ripping to $DIR..."
      #NOTE: the brakets below open a subshell in the background
           #i.e. another process with the same filename
           ($RIP 2> album.log && \
         $TOC 2>> album.log && \
         echo $FULLID > album.id) & pid=$!
           sleep 5
       fi

       #Play
       if $PLAY; then
           echo "Playing $DIR/album.wav..."
           killall $PLAYER &> /dev/null
           killall sox &> /dev/null
           $PLAYER $DIR/album.wav &
       fi
       
       #similar to `wait $pid` but it will exit also if cd tray is opened
       while(true);do
           if ! ps|awk {'print $1'}|grep $pid &> /dev/null; then
               echo "Finished ripping"
               break
           elif [[ `cdctl -g` != *audio* ]]; then
               echo "Unable to read CD"
               killall cdparanoia &> /dev/null
               killall cdrdao &> /dev/null
               break
           else
               sleep 3
           fi
       done
    $EJECT
       echo "Waiting for CD..."
   fi
done
jcoalson
QUOTE(ago @ Oct 26 2004, 07:03 AM)
* If I use flac to encode a .bin file, when decoding can I get back directly a wav file or do I always get back a .bin file which then needs to be transcoded to wav?
*

I thought the .bin file is raw CD data (i.e. raw 2352-byte sectors). in any case, FLAC treats all input as raw PCM samples so if .bin is different, it will not do any conversion to .wav, you will get the same .bin out. you may also get less compression if there is any non-audio in it, especially if it messes up the frame alignment.

Josh
bugmenot
Thx, that is what I thought. Any idea bout 9? It is hodling me back!!! I am trying to pass to toc2cue the toc file "extracted" using cdrdao, but I only get back an empty file... Did anyone have the same problem?
jcoalson
someone on the flac list published a tool called 'mkcue' that may be suitable, see:

http://lists.xiph.org/pipermail/flac/2004-...ber/000347.html
http://lists.xiph.org/pipermail/flac/2004-...ber/000352.html

Josh
bugmenot
interesting thx
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.