Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: ripping cds using FLAC
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
supermihi
Guru
Guru


Joined: 09 Feb 2005
Posts: 348

PostPosted: Sun Mar 27, 2005 12:06 pm    Post subject: HOWTO: ripping cds using FLAC Reply with quote

****
EDIT 28.3.2005
KAudiocreator seems a got alternative to grip for those guys using KDE, added pro's/con's of kaudiocreator/grip.
****


Hi,
I'm a fan of sound quality, and since I have some disc space free, I decided to rip some CDs to the free lossless audio codec (FLAC) instead of ogg vorbis which I was using before. The compression rate is for now about 50%, depending on the content of the audio file. Also I found that FLAC encodes VERY fast (~60-140x on my Athlon XP 2400+).

What annoyed me was that there seemed to be no really good, easy configurable ripping app that supported FLAC, especially with meta tags (flac seems to use Vorbis-style comments). The KDE audiocd:/ virtual interface is good for oggs and mp3s, and for some people FLAC, too (didn't got it working here; also it doesn't support renaming single fields of the comments if you want them changed).
For the guys using KDE I suggest kaudiocreator, which supports FLAC and is somewhat configurable.
Pro's:
- native FLAC support
- better implementation of the CDDB request
- easy to use
Con's:
- no way to change the ripping backend (cdparanoia etc.)
There's also sound-juicer which I never tried.
For the gnome users I recommend grip as CD ripping app supporting flac, but without metatags and having some other issues. The main issue of this Howto is getting grip configured to do a good FLAC encoding.
Pro's:
- Highly configurable
Con's:
- default configuration almost unusable
- must work a bit to get reasonable FLAC files
Both kaudiocreator and grip are kinda fast since they start to encode after the first track is ripped parallel to ripping the other tracks.
So, for anyone who wants to rip his CD collection to FLAC with automated, FreeDB-aided tagging, feel invited to follow these steps:

1. emerge grip (this could take a while if you don't have the gnome libraries installed already) and, of course, flac.
Code:
emerge -av flac grip


2. i suggest using cdda2wav instead of grip's standard ripper cdparanoia, since it is about six times faster (for me, at least, could be machine dependant). It's, in the cdrtools package (don't know why that), so
Code:
emerge cdrtools


3. Now it's time to start and configure grip. Go to Configuration->Rip->Ripper and set the Ripper to "cdda2wav" (if you want). Maybe you have to give the full path /usr/bin/cdda2wav for grip to understand it.

4. Go to Configuration->Encode->Encoder and choose "flac". Parse this line into "command line":
Code:
-V -o %m %w --tag=TITLE=%n --tag=ALBUM=%d --tag=ARTIST=%a --tag=YEAR=%y --tag=GENRE=%G --tag=TRACKNUMBER=%t

This takes the meta tags given by grip and parses them into the flac file. You also can add add a quality parameter (-0 up to -8), giving you a minimal smaller file by extremely increased encoding time.

5. Set your file naming format to what you want - %A for artist, %d for album title, %t for track number, %n for track title and %x for the appropriate file ending (.flac in this case).

6. It doesn't matter what you fill in at "ID3" since you gave the informations directly.

7. I suggest you to go to "Misc" and check "Do not lowercase filenames" and "do not change spaces to underscores", unless that's what you want. Also you might have to add some chars to "Characters not to strip in filenames", if you have non-ASCII content.

8. Press "Rip->Rip and Encode" to rip the whole cd or single tracks.

9. Enjoy quality! :)

There are a lot of FLAC players around: flac123 for console output, the xmms-flac plugin, amarok, rhythmbox etc.

Please feel free to post your corrections or suggestions!
supermihi
_________________
"You may say I'm a dreamer, but I'm not the only one."


Last edited by supermihi on Mon Mar 28, 2005 6:58 pm; edited 2 times in total
Back to top
View user's profile Send private message
Deathwing00
Bodhisattva
Bodhisattva


Joined: 13 Jun 2003
Posts: 4087
Location: Dresden, Germany

PostPosted: Sun Mar 27, 2005 12:21 pm    Post subject: Reply with quote

Moved from Multimedia.
Back to top
View user's profile Send private message
Cintra
Advocate
Advocate


Joined: 03 Apr 2004
Posts: 2111
Location: Norway

PostPosted: Sun Mar 27, 2005 1:02 pm    Post subject: Reply with quote

Many thanks for your Howto..

I had been wondering whether to try grip or not (all those gnome files...) and your howto has given me the required push ;-)

Mvh

Edit: It worked fine with your setup, but to avoid hanging on a couple of faulty tracks I had to change to Grip Cdparanoia,
which handled the errors with no problem. As you mentioned, encoding is very fast!
_________________
"I am not bound to please thee with my answers" W.S.


Last edited by Cintra on Sun Mar 27, 2005 3:35 pm; edited 1 time in total
Back to top
View user's profile Send private message
tkdfighter
Apprentice
Apprentice


Joined: 14 May 2004
Posts: 271
Location: Bludenz, Austria

PostPosted: Sun Mar 27, 2005 1:16 pm    Post subject: Reply with quote

Great guide! But I'm planning on backing up my cd collection to FLAC, burning it on dvd and then reencode the FLACs to mp3 using lame. The encoding is pretty strait forward, but how do I attach the ID3 information to the mp3s?
Back to top
View user's profile Send private message
supermihi
Guru
Guru


Joined: 09 Feb 2005
Posts: 348

PostPosted: Sun Mar 27, 2005 2:18 pm    Post subject: Reply with quote

Quote:
how do I attach the ID3 information to the mp3s?


You can access the tags in the flac's with metaflac:
Code:
metaflac --show-vc-field=<FILED> file.flac


This will output, for example:
Code:
 TITLE=The Gentoo Song


Now you could use a script to transfer this information to lame -- according to
Code:
lame --longhelp
you can give the tag information for id3 as followin:
Code:
ID3 tag options:
    --tt <title>    audio/song title (max 30 chars for version 1 tag)
    --ta <artist>   audio/song artist (max 30 chars for version 1 tag)
    --tl <album>    audio/song album (max 30 chars for version 1 tag)
    --ty <year>     audio/song year of issue (1 to 9999)
    --tc <comment>  user-defined text (max 30 chars for v1 tag, 28 for v1.1)
    --tn <track>    audio/song track number (1 to 255, creates v1.1 tag)
    --tg <genre>    audio/song genre (name or number in list)
    --add-id3v2     force addition of version 2 tag
    --id3v1-only    add only a version 1 tag
    --id3v2-only    add only a version 2 tag
    --space-id3v1   pad version 1 tag with spaces instead of nulls
    --pad-id3v2     pad version 2 tag with extra 128 bytes
    --genre-list    print alphabetically sorted ID3 genre list and exit
    --ignore-tag-errors  ignore errors in values passed for tags

Now it's time for a little script that does this all by self. I'm not too versed in bash scripting but I'd try something like the following:

Code:

#!/bin/bash
for x in $* ;
do TITLE=$(metaflac --show-vc-field=TITLE $x | sed s/TITLE=//g)
do GENRE=...
[...]
flac -d $x -o - | lame --tt TITLE --tg GENRE [...] $x.mp3     #dont know how to remove the .flac from $x :)

something like that should work

_________________
"You may say I'm a dreamer, but I'm not the only one."
Back to top
View user's profile Send private message
tkdfighter
Apprentice
Apprentice


Joined: 14 May 2004
Posts: 271
Location: Bludenz, Austria

PostPosted: Sun Mar 27, 2005 3:25 pm    Post subject: Reply with quote

Ok, thanks! Scripting isn't very hard, I can do that.
Back to top
View user's profile Send private message
supermihi
Guru
Guru


Joined: 09 Feb 2005
Posts: 348

PostPosted: Sun Mar 27, 2005 3:33 pm    Post subject: Reply with quote

Ok, I read your post to late, I finally managed to make some basic scripts for flac to mp3 and flac to ogg conversion:

For converting FLAC files to ogg vorbis:
Code:
#!/bin/bash
# /usr/local/bin/flac2ogg
# this script converts given flac files to ogg vorbis
QUALITY=4.5 # change if you want to
for x in $* ;
do TIT=$(metaflac --show-vc-field=TITLE $x | sed s/TITLE=//g)
   GEN=$(metaflac --show-vc-field=GENRE $x | sed s/GENRE=//g)
   ALB=$(metaflac --show-vc-field=ALBUM $x | sed s/ALBUM=//g)
   ART=$(metaflac --show-vc-field=ARTIST $x | sed s/ARTIST=//g)
   YE=$(metaflac --show-vc-field=YEAR $x | sed s/YEAR=//g)
   TRA=$(metaflac --show-vc-field=TRACKNUMBER $x | sed s/TRACKNUMBER=//g)
   FIL=$(echo $x | sed s/flac/ogg/g)
   flac -d $x -o - | oggenc -q $QUALITY -N "$TRA" -t "$TIT" -l "$ALB" \
        -a "$ART" -d "$Y" -G "$GEN" -o "$FIL" -
done


For converting FLAC files to mp3 using lame
Code:
#!/bin/bash
# /usr/local/bin/flac2mp3
# this script converts given flac files to mp3 files
BITRATE=256 # change if you want to
for x in $* ;
do TIT=$(metaflac --show-vc-field=TITLE $x | sed s/TITLE=//g)
   GEN=$(metaflac --show-vc-field=GENRE $x | sed s/GENRE=//g)
   ALB=$(metaflac --show-vc-field=ALBUM $x | sed s/ALBUM=//g)
   ART=$(metaflac --show-vc-field=ARTIST $x | sed s/ARTIST=//g)
   YE=$(metaflac --show-vc-field=YEAR $x | sed s/YEAR=//g)
   TRA=$(metaflac --show-vc-field=TRACKNUMBER $x | sed s/TRACKNUMBER=//g)
   FIL=$(echo $x | sed s/flac/mp3/g)
   flac -d $x -o - | lame -b $BITRATE --tn "$TRA" --tt "$TIT" --tl "$ALB" \
        --ta "$ART" --ty "$Y" --tg "$GEN" - "$FIL"
done


Didn't test them well, I'm sure they're expandable, but should work.
_________________
"You may say I'm a dreamer, but I'm not the only one."
Back to top
View user's profile Send private message
llsardonicll
Tux's lil' helper
Tux's lil' helper


Joined: 07 Oct 2004
Posts: 110

PostPosted: Mon Mar 28, 2005 6:21 am    Post subject: Reply with quote

I can go to audiocd:/FLAC and it will let me do FLAC files...been doing it all day... unless I'm interpreting
that the wrong way.
Back to top
View user's profile Send private message
supermihi
Guru
Guru


Joined: 09 Feb 2005
Posts: 348

PostPosted: Mon Mar 28, 2005 3:26 pm    Post subject: Reply with quote

?? Which KDE version do you use? Did you install some special package?
_________________
"You may say I'm a dreamer, but I'm not the only one."
Back to top
View user's profile Send private message
llsardonicll
Tux's lil' helper
Tux's lil' helper


Joined: 07 Oct 2004
Posts: 110

PostPosted: Mon Mar 28, 2005 5:30 pm    Post subject: Reply with quote

Using kde-3.4 monolithic here. Haven't installed any special package that I'm aware of, just a flac use flag.
*just checked and kaudiocreator will do flac...and some odd reason i have sound juicer installed
and it will do flac too.
Back to top
View user's profile Send private message
supermihi
Guru
Guru


Joined: 09 Feb 2005
Posts: 348

PostPosted: Mon Mar 28, 2005 6:43 pm    Post subject: Reply with quote

You're right, kaudiocreator seems to support FLAC quite well. I'll edit the HOWTO a bit.
_________________
"You may say I'm a dreamer, but I'm not the only one."
Back to top
View user's profile Send private message
tkdfighter
Apprentice
Apprentice


Joined: 14 May 2004
Posts: 271
Location: Bludenz, Austria

PostPosted: Wed May 25, 2005 5:43 pm    Post subject: Reply with quote

supermihi, I edited you script a bit. Now it's recursive and puts the mp3s in a destination directory:
Code:
#!/bin/bash
# /usr/local/bin/flac2mp3
# this script converts given flac files to mp3 files

LAMEOPTS="-h -p -m j -b 160";
FLACOPTS="-o";

LAME="/usr/bin/lame";
FLAC="/usr/bin/flac";
METAFLAC="/usr/bin/metaflac";

DIR=$1;
DESTINATION=$2;

if [[ $DIR == "-h" || $DIR == "--help" ]]
then
  printf "Usage: $0 [source directory] [destination directory]\n";
  printf "flac2mp3 converts flac files to mp3 files, while preserving the directory structure.\n";
  printf "\n";
  printf "options:\n";
  printf "\t-h, --help\t\tPrint this help list\n";
  printf "\n";
  exit 1;
fi

chars=$(echo $DIR | wc --chars);

#for y in $(find -print | grep -v .flac);
#for y in $(find $DIR -print | grep -v .flac | sed s/$DIR/./g);
for y in $(find $DIR -print | grep -v .flac);
do
  y=$(echo ${y:$chars});
  mkdir -p $DESTINATION/$y
done

for x in $(find $DIR -name *.flac) ;
do
  TIT=$($METAFLAC --show-tag=TITLE $x | sed s/TITLE=//g)
  GEN=$($METAFLAC --show-tag=GENRE $x | sed s/GENRE=//g)
  ALB=$($METAFLAC --show-tag=ALBUM $x | sed s/ALBUM=//g)
  ART=$($METAFLAC --show-tag=ARTIST $x | sed s/ARTIST=//g)
  YER=$($METAFLAC --show-tag=YEAR $x | sed s/YEAR=//g)
  TRA=$($METAFLAC --show-tag=TRACKNUMBER $x | sed s/TRACKNUMBER=//g)
  #FIL=$(echo $x | sed -e s/$DIR.//1 -e s/flac/mp3/g)
  FIL=$(echo ${x:$chars} | sed s/\.flac/.mp3/g);

  $FLAC -d $x $FLACOPTS - | $LAME $LAMEOPTS --tn "$TRA" --tt "$TIT" --tl "$ALB" \
   --ta "$ART" --ty "$YER" --tg "$GEN" - "$DESTINATION/$FIL";
done


edit: updated the script and added command line arguments


Last edited by tkdfighter on Fri Dec 09, 2005 6:18 pm; edited 1 time in total
Back to top
View user's profile Send private message
ikke
Apprentice
Apprentice


Joined: 14 Jan 2005
Posts: 225
Location: Belgium

PostPosted: Thu May 26, 2005 6:30 am    Post subject: Reply with quote

You could just use abcde too ;)
_________________
Working day and night to enhance your Linux Desktop experience :)
Blog
Back to top
View user's profile Send private message
tkdfighter
Apprentice
Apprentice


Joined: 14 May 2004
Posts: 271
Location: Bludenz, Austria

PostPosted: Thu May 26, 2005 7:21 am    Post subject: Reply with quote

freshmeat.net/projects/abcde wrote:
About:
abcde is a frontend to cdparanoia, wget, cd-discid, id3, and your favorite Ogg Vorbis (the default), MP3, FLAC, Ogg Speex, or MPP (Musepack) encoder. It grabs an entire CD and converts each track to the desired format, then comments or ID3-tags each file, all with one command. It supports multiple output in a single CD read, the creation of a single track from a CD, resume operation, CD concatenation, volume normalization, gapless encoding (with LAME), parallelization, SMP, proxies, customizable filename organization and munging, playlist generation, distributed encoding via distmp3, and more.

That's not what I need. I already use grip for that. What I needed was a program/script that would convert the flac files to mp3/ogg/whatever. :wink:
Back to top
View user's profile Send private message
bludger
Guru
Guru


Joined: 09 Apr 2003
Posts: 389

PostPosted: Sat Nov 05, 2005 5:32 pm    Post subject: Reply with quote

I have a number of flac files that were ripped and encoded without tags. Is it possible to use the flac files to do a cddb lookup and then insert this information in the flac files in some way other than burning a cd from the flac files?
Back to top
View user's profile Send private message
supermihi
Guru
Guru


Joined: 09 Feb 2005
Posts: 348

PostPosted: Sat Nov 05, 2005 5:47 pm    Post subject: Reply with quote

You could try musicbrainz, although I don't know if it works with flac's, maybe only MP3 is supported now.
_________________
"You may say I'm a dreamer, but I'm not the only one."
Back to top
View user's profile Send private message
ahubu
Guru
Guru


Joined: 16 Aug 2003
Posts: 400
Location: Groningen, The Netherlands

PostPosted: Thu Nov 17, 2005 8:21 pm    Post subject: Reply with quote

Thank you very much, great HOWTO. Often I really dread finding out the proper commandline options (and building it up from scratch), it's always good to have a working baseline (although in this case, I didn't change anything :)). Happily FLACripping away here... some cd's just don't deserve t be mp3-ized.
_________________
Anne // Light travels faster than sound. That's why people appear bright until
you hear them speak.
-Unknown
Back to top
View user's profile Send private message
ecatmur
Advocate
Advocate


Joined: 20 Oct 2003
Posts: 3595
Location: Edinburgh

PostPosted: Thu Nov 17, 2005 9:46 pm    Post subject: Reply with quote

bludger wrote:
I have a number of flac files that were ripped and encoded without tags. Is it possible to use the flac files to do a cddb lookup and then insert this information in the flac files in some way other than burning a cd from the flac files?
You need a tagging program that supports FLAC. I use cowbell - it has a sane interface, automatic song lookup (from filename or other info), album cover support, and an automatic command line batch tagging interface.
_________________
No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS?
Back to top
View user's profile Send private message
ecatmur
Advocate
Advocate


Joined: 20 Oct 2003
Posts: 3595
Location: Edinburgh

PostPosted: Thu Nov 17, 2005 9:50 pm    Post subject: Reply with quote

I'd recommend sound-juicer over flac; the interface is a lot cleaner and it tags files properly in the default configuration.
_________________
No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS?
Back to top
View user's profile Send private message
Hauser
l33t
l33t


Joined: 27 Dec 2003
Posts: 650
Location: 4-dimensional hyperplane

PostPosted: Tue Nov 22, 2005 10:36 am    Post subject: Reply with quote

tkdfighter wrote:
... What I needed was a program/script that would convert the flac files to mp3/ogg/whatever. :wink:

Try this:
Code:
$ mplayer -ao pcm -aofile xxx.wav xxx.flac; normalize xxx.wav; oggenc xxx.wav xxx.ogg; rm -f xxx.wav

No tags though.
_________________
AMD Athlon XP 2600+; 512M RAM;
nVidia FX5700LE; Hitachi 120Gb
2.6.9-nitro4, reiser4, linux26-headers+nptl

Do I like to compile everything?
Positive definite!
Back to top
View user's profile Send private message
hhaamu
Apprentice
Apprentice


Joined: 23 Aug 2002
Posts: 253
Location: Finland

PostPosted: Thu Nov 24, 2005 3:08 pm    Post subject: Reply with quote

Hauser wrote:
Code:
$ mplayer -ao pcm -aofile xxx.wav xxx.flac; normalize xxx.wav; oggenc xxx.wav xxx.ogg; rm -f xxx.wav



1) oggenc supports flac input natively (incl tags!), no need for mplayer to interfere.

2) normalizing audio data is evil and unneeded when you have the power of replaygain (and vorbis comments). emerge media-sound/vorbisgain and do vorbisgain -a album/*.ogg

It's another thing to configure your players to use the stored replaygain data. XMMS, BMP, and Rhythmbox can do it, at least.
Back to top
View user's profile Send private message
psiox
n00b
n00b


Joined: 19 Jan 2005
Posts: 3

PostPosted: Mon Nov 28, 2005 1:57 pm    Post subject: Reply with quote

Hopefully this will help some people.

I've been doing the FLAC thing for a while myself, and as I have a car mp3 player that doesn't do anything but mp3s and an ipod that does mp3s/aacs, I try to maintain an automatically-transcoded collection of mp3s and aacs from the FLAC source. So I found this interesting perl script called flac2mp3 and hacked on it until it did aacs with proper tags as well. If you want to make AACs like me, emerge faad2 and faac first, then you can run this script fine. Otherwise, you just need lame.

http://veritox.net/flac2aacmp3.tbz

Just run it like so:
./flac2aac.pl /path/to/FLAC/root /path/to/transcodes/root
(or flac2mp3.pl)

It'll ignore anything other than FLACs (and will ignore FLACs it has already transcoded, so it's safe to run a cronjob nightly and it will just do new stuff) and will construct the same relative paths in the transcode directory. Enjoy, and I hope it helps someone!
Back to top
View user's profile Send private message
ruizs
n00b
n00b


Joined: 14 Jul 2004
Posts: 18

PostPosted: Sat Dec 03, 2005 8:33 am    Post subject: Reply with quote

The flac2aac script is great, and was just what I was looking for. I'm in a similar situation, with a need for different copies of my flac music.

I did edit the script slightly, so it would tag the files with a track# and genre. However, when I import the resulting m4a files into itunes, it doesn't seem to recognize the genre and track number tags...

In the script:
Code:
my $convert_command =
                "$flaccmd @flacargs \"$quotedsrc\""
              . "| $lamecmd @lameargs --artist \"$srcframes->{ARTIST}\" --title \"$srcframes->{TITLE}\" --album \"$srcframes->{ALBUM}\" --year \"$srcframes->{YEAR}\" --genre \"$srcframes->{GENRE}\" --track \"$srcframes->{TRACKNUMBER}\" -o \"$quoteddest\" -";


The command line it issues:
Code:
flac --decode --stdout --silent "Jets_To_Brazil/Perfecting_Loneliness/Further_North.flac"| faac -q 200 -w --artist "Jets To Brazil" --title "Further North" --album "Perfecting Loneliness" --year "2002" --genre "Indie" --track "09" -o "/home/stever/mp4/Jets_To_Brazil/Perfecting_Loneliness/Further_North.m4a" -


Has anybody gotten all the tags working, when going from faac -> itunes??
thanks!
Back to top
View user's profile Send private message
roguetoad
Tux's lil' helper
Tux's lil' helper


Joined: 24 Oct 2005
Posts: 124
Location: Office chair

PostPosted: Sun Dec 04, 2005 7:38 am    Post subject: Reply with quote

I've seen a lot of buzz about replaygain and was wondering how to factor that into ripping cd's to flac format.
Grip has a Calculate gain adjustment option you can click under ripper, but I don't know if it works for flac.
Second, there seems to be a couple of gain adjustments that can be calculated: 1. for the entire album 2. per track
I guess I'm wondering without some universal normalization, how replaygain would work across an entire collection of albums if these are the only two ways it can calculate.

Anybody got the skinny on how replay gain really works and better yet, how to add it into this howto for ripping to flac?
Back to top
View user's profile Send private message
jkcunningham
l33t
l33t


Joined: 28 Apr 2003
Posts: 649
Location: 47.49N 121.79W

PostPosted: Sun Feb 26, 2006 3:28 pm    Post subject: Re: HOWTO: ripping cds using FLAC Reply with quote

Since this is in 'Tips and Tricks' I thought I'd add a comment on this part:

supermihi wrote:
****
2. i suggest using cdda2wav instead of grip's standard ripper cdparanoia, since it is about six times faster (for me, at least, could be machine dependant). It's, in the cdrtools package (don't know why that), so
Code:
emerge cdrtools

supermihi


The reason cdparanoia is slower is that it does extensive error correction. Unless you know that what you are ripping is guaranteed to be error free, you want this. I can't count how many times I've ripped wavs that play with tics and tracking errors that cdparanoia fixes in the mp3s.

And the reason cdda2wav is in the cdrtools package is that the development is managed by the same guy (Jorg Schilling) who wrote cdrecord. It actually has a flag to use cdparanoia for its error correction (-parania). If you don't use it, it runs faster but won't fix any errors.

-jeff
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum