If you already have a process that's close to working, all you need to do is find a commandline tagger that can "copy" tags from one file to another. id3cp
from the id3lib package might be what you need.
If I were to do this, I'd rip the CD to WAV files (in EAC
, because I've never seen anything compare to its accuracy with a good drive), then run a script that does the following pseudocode. I'd probably select the clips manually, because programmatically grabbing 45 useful seconds out of an arbitrarily-long track won't always work. But here's the basic process:
for each *.WAV:
1. convert <name>.wav to <name>.mp3
2. create a 45-second <name>.snippet.wav from <name>.wav
3. apply fade-out to <name>.snippet.wav
4. convert <name>.snippet.wav to <name>.snippet.mp3
5. apply id3 tags to both <name>.mp3 and <name>.snippet.mp3
Steps 1 and 4 can be accomplished with the lame
commandline encoder.
Steps 2 and 3 can be done with sox
or ecasound
(you might be able to combine them into a single command).
Step 5 can be done with id3v2
, mid3v2
(from the excellent mutagen
python tagging library), mp3info
(if you just want ID3v1 tags), or some other commandline tagger -- essentially your script would call the tagger twice, once for each MP3 created in this pass of the for-loop.
This process has the advantage of not creating transcoded snippets, since you haven't encoded to MP3, then decoded and re-encoded during the trim-and-apply-fadeout process.