Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Patch: Add Test & Copy to abcde/cdparanoia (Read 15093 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Patch: Add Test & Copy to abcde/cdparanoia

Hi all,

here's a diff against abcde v2.1.19. It adds the Test & Copy functionality to abcde. If you're interested there are also some cdparanoia hints at the bottom of this post.

Test & Copy only works when using cdparanoia as ripping software. It doesn't work with any other ripper or in case abcde is used with the parameter '-1' ("Encode the whole CD in a single file").

It needs the md5sum program, so you got to have it installed. But I guess everyone has md5sum.

It works quite simple: Reads the track, gets the MD5 sum, rereads the track, gets the MD5 sum, compares the two MD5 sums. If they don't match, abcde aborts, otherwise it continues.

There's a new option. It's called "CDPARANOIA_TEST_N_COPY". It defaults to 'n', so in order to actually use Test & Copy you have to say so in your config file.
Code: [Select]
CDPARANOIA_TEST_N_COPY=y

As an alternative you can start abcde with the new parameter '-2'. It doesn't have an (optional) argument.
Code: [Select]
abcde -2 [other options]


This should work with newer abcde versions, too, but there's a possibility you have to adapt the patch a little.


Cheers

mic

Code: [Select]
--- abcde.old   2006-03-25 12:46:59.000000000 +0100
+++ abcde       2006-03-25 12:47:06.000000000 +0100
@@ -1483,7 +1483,33 @@
               echo "Grabbing track $UTRACKNUM..." >&2
       fi
       case "$CDROMREADERSYNTAX" in
-               cdparanoia) nice $READNICE $CDROMREADER -d $CDROM $UTRACKNUM "$WAVDATA" >&2;;
+               cdparanoia)
+                       if [ "$CDPARANOIA_TEST_N_COPY" = "y" ]; then
+                               nice $READNICE $CDROMREADER -d $CDROM $UTRACKNUM "$WAVDATA" >&2
+                               RETURN=$?
+                               if [ "$RETURN" != "0" ]; then
+                                       false
+                               else
+                                       MD5_1=`nice $READNICE $MD5SUM "$WAVDATA"`
+                                       nice $READNICE $CDROMREADER -d $CDROM $UTRACKNUM "$WAVDATA" >&2
+                                       RETURN=$?
+                                       if [ "$RETURN" != "0" ]; then
+                                               false
+                                       else
+                                               MD5_2=`nice $READNICE $MD5SUM "$WAVDATA"`
+                                               if [ "$MD5_1" != "$MD5_2" ]; then
+                                                       echo "MD5 sum of track $UTRACKNUM doesn't match after reripping." >&2
+                                                       echo "Encoding the remainder of the properly ripped tracks (if any)." >&2
+                                                       echo >&2
+                                                       false
+                                               fi
+                                       fi
+                               fi
+                       else
+                               nice $READNICE $CDROMREADER -d $CDROM $UTRACKNUM "$WAVDATA" >&2
+                       fi
+                      ;;
+
               cdda2wav)
                       if [ "$OSFLAVOUR" = "OSX" ]; then
                               # Hei, we have to unmount the device before running anything like cdda2wav in OSX
@@ -1586,7 +1612,7 @@
CDDBCOPYLOCAL="n"
CDDBLOCALDIR="$HOME/.cddb"
CDDBUSELOCAL="n"
-
+CDPARANOIA_TEST_N_COPY="n"
# If using scsi devices, cdda2wav needs a CDROMID, instead of a device node
# i.e. CDROMID="1,0,0"
CDROMID=""
@@ -1740,11 +1766,14 @@
       fi
fi

# Parse command line options
#while getopts 1a:bc:C:d:Dhj:klLnNo:pr:S:t:T:vVx opt; do
-while getopts 1a:bc:C:d:Dhj:klLnNo:pr:S:vVx opt; do
+while getopts 12a:bc:C:d:Dhj:klLnNo:pr:S:vVx opt; do
       case "$opt" in
               1) ONETRACK=y;;
+               2) CDPARANOIA_TEST_N_COPY=y;;
               a) ACTIONS="$OPTARG";;
               b) BATCH=y;;
               c) if [ -e "$OPTARG" ]; then . "$OPTARG"; else echo "abcde error: config file \"$OPTARG\" cannot be found." >&2; exit 1; fi;;


cdparanoia hints

- cdparanoia is able to correct your cdrom reader offset. Use the '-O' (e.g. '-O 6') parameter for this. If you don't know your drives offset have look at the AccurateRip database. Chances are you'll find it there.
Note: In case your cdrom drive can't read into the Lead-Out (positive offset correction) or Lead-In (negative offset correction), consider not using '-O'. cdparanoia can't append silence in case your drive can't read into the Lead-Out/Lead-In. E.g. using a drive which needs a positve offset correction and is unable to read into the Lead-Out you'll see this at the end of the last track most of the time:
Code: [Select]
(== PROGRESS == [                             !*| 186674 00 ] == :^D * ==)

Allthough the MD5 sums will match (given there aren't other errors), your copy won't be perfect.

- some other interesting options are '-z' and '-X'.
Code: [Select]
       -z --never-skip[=max_retries]
             Do not accept any skips; retry forever if needed.  An optional maximum number of retries can  be  specified;  for  comparison,
             default without -z is currently 20.

Code: [Select]
       -X --abort-on-skip
             If the read skips due to imperfect data, a scratch, whatever, abort reading this track.  If output is to a  file,  delete  the
             partially completed file.


- you can specify your cdparanoia options in '~/.abcde.conf' like this:
Code: [Select]
CDPARANOIAOPTS='-O6 -z -X'


- if you're using an ATAPI cdrom reader and you run a recent kernel (>kernel-2.6.8) you should apply Peter Jones' cdparanoia patches, which introduce SG_IO to cdparanoia. SG_IO is a transport for SCSI commands. Without them chances are that the quality of audio extraction will completely depend on your drive and cdparanoia won't be able to detect read errors. Some people have experienced problems using SG_IO with kernels older than 2.6.15. So I think it would be best to use a kernel >=2.6.15.

You can find the patches at http://people.redhat.com/pjones/cdparanoia/. Or you can grab them in a single archieve from here: Link
In case you're a Gentoo addict all you have to do is unmask 'media-sound/cdparanoia-3.9.8-r3' and emerge it. But you have to run at least kernel 2.6.15, otherwise the ebuild won't apply the patches.

Patch: Add Test & Copy to abcde/cdparanoia

Reply #1
v2:
- got rid of 'test', now simply using 'false'
- niced md5sum (using the same niceness as cdparanoia)
- added checks for cdparanoias return value, e.g. in case cdparanoia detects a non-audio track abcde will exit as usual.

mic

Patch: Add Test & Copy to abcde/cdparanoia

Reply #2
v3:
- added command line parameter '-2'
- changed 'CDPARANOIATESTNCOPY' to 'CDPARANOIA_TEST_N_COPY'
- added some cdparanoia hints to the first post.

mic

Patch: Add Test & Copy to abcde/cdparanoia

Reply #3
Hey ... just wanted to say thanks for the patch since no one else had commented yet.  Works great for me, and nice to have my process fully automated again.

Patch: Add Test & Copy to abcde/cdparanoia

Reply #4
Hey ... just wanted to say thanks for the patch since no one else had commented yet.  Works great for me, and nice to have my process fully automated again.


Thank you, you're welcome!

Cheers

micmac

Patch: Add Test & Copy to abcde/cdparanoia

Reply #5
Hmm, the last hunk of the patch seems to have a small error

@@ -1740,11 +1766,14 @@

I think that should read 12 or there are two lines with only + in them missing.

Anyway, the patch has to be ported for my version. Have you considered to submit the patch to Jesus?

Patch: Add Test & Copy to abcde/cdparanoia

Reply #6
Yes, I submitted the patch right after posting it here. Haven't heard from Jesus yet, but what else is new?

mic

Patch: Add Test & Copy to abcde/cdparanoia

Reply #7
Another thing: The point of Test&Copy is to increase ripping speed by using burst mode, while retaining confidence that the rip is unflawed. Shouldn't cdparanoia be invoked with --disable-paranoia with your modification?

Patch: Add Test & Copy to abcde/cdparanoia

Reply #8
Knock yourself out

Patch: Add Test & Copy to abcde/cdparanoia

Reply #9
Molya?

Patch: Add Test & Copy to abcde/cdparanoia

Reply #10
I am an anal-retentive ripper. I think it would be better if we were rip the entire CD once and then again instead of twice the 1st track, then twice the 2nd and so on because if the tracks are extremely short they may fit into the cache. So if you reread them, you just read it from the cache. Would you consider this micmac?

Triza

Patch: Add Test & Copy to abcde/cdparanoia

Reply #11
Molya?

Sorry? It was a figure of speech, meaning you can do what you like. You can put anything you like into the cdparanoia options of your abcde.conf.

I am an anal-retentive ripper. I think it would be better if we were rip the entire CD once and then again instead of twice the 1st track, then twice the 2nd and so on because if the tracks are extremely short they may fit into the cache. So if you reread them, you just read it from the cache. Would you consider this micmac?

Triza


Hi, I'm not sure what you mean. How about you write it down and I append it as an annotation of yours to the first post?

mic

Patch: Add Test & Copy to abcde/cdparanoia

Reply #12
What Triza meant is reading the tracks a second time only after all of them have been read once, ie.: 1, 2, 3, ..., last, 1, 2, 3, ..., last rather than 1, 1, 2, 2, 3, 3, ..., last, last.

Patch: Add Test & Copy to abcde/cdparanoia

Reply #13
What Triza meant is reading the tracks a second time only after all of them have been read once, ie.: 1, 2, 3, ..., last, 1, 2, 3, ..., last rather than 1, 1, 2, 2, 3, 3, ..., last, last.


Bingo! Thanks Never_Again. That is exactly what I meant.

The current method (1, 1, 2, 2, 3, 3, ..., last, last) is not perfect because lets assume that track 2 is very short. So short in fact that it fits into the cache of the drive. If that is the case, then when you read track 2, you just read it from the cache, therefore no wonder you'll get the same result.

BTW this is the problem with EAC/cdparanoia just in a bit more extreme sense since it rereads reads each "sector" twice one after another. If the drive caches audio, then it rereads the same sector directly from the cache. Your strategy is a bit better because now we reread an entire track, but not perfect because it is possible that some of your track is so short that it fits into the cache.

Almost all (if not all) drive caches audio these days. My reckoning is based on the number of desperate posts who wish to find non-caching drives for EAC.

Triza

Patch: Add Test & Copy to abcde/cdparanoia

Reply #14
Ah, now I get it. But there's no point for me to add that to the first post, because that'd require more patching of abcde, and it'd prolly be more difficult than adding Test and Copy. And I'm personally not interested in abcde anymore since I got EAC up and running in Wine, sorry.

Btw., cdparanoia handles caching drives well to a certain amount of cache I believe. Maybe the barrier is 1MB, so it's unfortunately not enough for most of todays drives, allthough my brand new dvd reader (no writer) only has 254kB of cache.

mic

Patch: Add Test & Copy to abcde/cdparanoia

Reply #15
That is fine. Yes I think it would require more patching. No sweat. Thanks for your contribution anyway.

Triza

Patch: Add Test & Copy to abcde/cdparanoia

Reply #16
Do you have any intentions to make this work with the "-1" parameter?  I'd like to be able to verify my flac images automatically...  Regardless, thanks for the patch.  This is great work.
a windows-free, linux user since 1/31/06.