PDA

View Full Version : Questions on FLAC (encoding w/ReplayGain, native flac support)



Jeff Coffler
2004-10-20, 14:45
Hi folks,

I hope this isn't too much of a "newbie" question. I did check all list archives, at least.

I used to be an Audiotron owner, jumped ship for multiple SqueezeBoxes. I used MP3 at a high VBR, and also used MP3GAIN to set album levels. Now that I can use FLAC, I'm carefully considering it and have questions:

1a. flac and replaygain: How do you enable replaygain w/FLAC files?

I read that this is supported via a new qualifier in FLAC (in post v1.1), --apply-replaygain-which-is-not-lossless=a, which you can place in a SlimServer configuration file. Is this indeed the best way to set this up? What's the best place to put this (on the SlimServer side) once you have the correct version of FLAC? How do you know that this is actually being honored by the FLAC decoder?

1b. What's the best way to encode with FLAC to set replaygain tags?

I'm currently using EAC, and I've set it up via MUSE instructions. This works perfectly, and tagging works 100% fantastic. My expectation was that I could do another analyze path to set the replaygain tags appropriately. However, it appears that FLAC sets these on encoding only (with --replaygain set). Furthermore, for accurate album replaygain tags, you need to specify all files in the album on the command line. Now I'm stumped since EAC works song-at-a-time.

Is there a way you can have FLAC make a second pass (on already encoded FLAC files) to set these tags? Or must you only do it on the encode phase? If the encode phase, does this mean that I'd need to use EAC to WAV files (thereby losing all tagging), and use foobar2000 or something to retag the files once in flac? Or am I missing something?

Suggestions appreciated, thanks!

2. Status on native flac support in SqueezeBox firmware?

This has been brought up several times in the past. I'd expect the current state is "being considered", since I've not seen anything new on this. Is this still the state, or did I miss something?

Thanks much for the help, folks,

-- Jeff

Robin Bowes
2004-10-20, 15:06
Jeff Coffler wrote:
> Hi folks,
>
> I hope this isn't too much of a "newbie" question. I did check all list
> archives, at least.
>
> I used to be an Audiotron owner, jumped ship for multiple SqueezeBoxes.
> I used MP3 at a high VBR, and also used MP3GAIN to set album levels.
> Now that I can use FLAC, I'm carefully considering it and have questions:
>
> 1a. flac and replaygain: How do you enable replaygain w/FLAC files?
>
> I read that this is supported via a new qualifier in FLAC (in post
> v1.1), --apply-replaygain-which-is-not-lossless=a, which you can place
> in a SlimServer configuration file. Is this indeed the best way to set
> this up? What's the best place to put this (on the SlimServer side)
> once you have the correct version of FLAC? How do you know that this is
> actually being honored by the FLAC decoder?

Hi Jeff,

AFAIK, this is the only way to use replaygain.

I don't know for sure but custom conversion specifications go in
slimserver-convert.conf. I presume these override those specified in
convert.conf.

Try this thread:

http://lists.slimdevices.com/archives/discuss/2004-June/031443.html

> 1b. What's the best way to encode with FLAC to set replaygain tags?
>
> I'm currently using EAC, and I've set it up via MUSE instructions. This
> works perfectly, and tagging works 100% fantastic. My expectation was
> that I could do another analyze path to set the replaygain tags
> appropriately. However, it appears that FLAC sets these on encoding
> only (with --replaygain set). Furthermore, for accurate album
> replaygain tags, you need to specify all files in the album on the
> command line. Now I'm stumped since EAC works song-at-a-time.
>
> Is there a way you can have FLAC make a second pass (on already encoded
> FLAC files) to set these tags? Or must you only do it on the encode
> phase? If the encode phase, does this mean that I'd need to use EAC to
> WAV files (thereby losing all tagging), and use foobar2000 or something
> to retag the files once in flac? Or am I missing something?

You're not missing anything - if you're using EAC you need to do another
pass. You could use fb2k on each set of album files, or write a nifty
script that applies the replaygain tags to a directory tree as a batch
process. I've been meaning to write something like this for a while but
never quite got round to it, so let me know when you're done. :)

R.
--
http://robinbowes.com

Jeff Coffler
2004-10-20, 15:24
Hi Robin,

Thanks for your response to my questions!

> > Is there a way you can have FLAC make a second pass (on already encoded
> > FLAC files) to set these tags? Or must you only do it on the encode
> > phase? If the encode phase, does this mean that I'd need to use EAC to
> > WAV files (thereby losing all tagging), and use foobar2000 or something
> > to retag the files once in flac? Or am I missing something?
>
> You're not missing anything - if you're using EAC you need to do another
> pass. You could use fb2k on each set of album files, or write a nifty
> script that applies the replaygain tags to a directory tree as a batch
> process. I've been meaning to write something like this for a while but
> never quite got round to it, so let me know when you're done. :)

I expected another pass, so that's not a problem.

fb2k? Is that foobar2000? I've not tried that utilitity yet (haven't
needed it).

If flac only does album replaygain settings during encoding, then what do
you need to do? Have foobar2000 decode to wav and then reencode back to
flac? Or is there some way to run flac directly pointing to the input flac
files and have it write out the album/song replaygain tags?

If the former, I imagine I mind as well just extract to WAV to begin with?
And lose tags from EAC?

I guess I'm confused on the process. Please let me know exactly how to get
a set of FLAC files set up with the replaygain tags (particularly the album
gain, what I normally use). Or if you can't do that, then just let me know
the proper process! I have no qualms writing a perl script to do this (and
sharing it) as long as I understand the process - thanks!

-- Jeff

Robin Bowes
2004-10-20, 15:34
Jeff Coffler wrote:
> fb2k? Is that foobar2000? I've not tried that utilitity yet (haven't
> needed it).

Yes. fb2k = foobar2000.

> If flac only does album replaygain settings during encoding, then what do
> you need to do? Have foobar2000 decode to wav and then reencode back to
> flac? Or is there some way to run flac directly pointing to the input flac
> files and have it write out the album/song replaygain tags?
>
> If the former, I imagine I mind as well just extract to WAV to begin with?
> And lose tags from EAC?
>
> I guess I'm confused on the process. Please let me know exactly how to get
> a set of FLAC files set up with the replaygain tags (particularly the album
> gain, what I normally use). Or if you can't do that, then just let me know
> the proper process! I have no qualms writing a perl script to do this (and
> sharing it) as long as I understand the process - thanks!

flac can apply tags separately to encoding. So, use EAC as you do
currently to rip, encode and tag, then do a 2nd pass that just adds the
replaygain tags.

It should be as simple as running flac --replaygain *.flac in each album
directory.

R.
--
http://robinbowes.com

Jeff Coffler
2004-10-20, 15:43
Hi Robin,

> flac can apply tags separately to encoding. So, use EAC as you do
> currently to rip, encode and tag, then do a 2nd pass that just adds the
> replaygain tags.
>
> It should be as simple as running flac --replaygain *.flac in each album
> directory.

Not quite that simple ... suggestions?


D% flac --replay-gain *.flac

flac 1.1.1, Copyright (C) 2000,2001,2002,2003,2004 Josh Coalson
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for
details.

options: -P 4244 -b 4608 -m -l 8 -q 0 -r 3,3
ERROR: for encoding a raw file you must specify a value
for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
ERROR: for encoding a raw file you must specify a value
for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
ERROR: for encoding a raw file you must specify a value
for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
ERROR: for encoding a raw file you must specify a value
for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
ERROR: for encoding a raw file you must specify a value
for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
ERROR: for encoding a raw file you must specify a value
for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
ERROR: for encoding a raw file you must specify a value
for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
ERROR: for encoding a raw file you must specify a value
for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
ERROR: for encoding a raw file you must specify a value
for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
ERROR: for encoding a raw file you must specify a value
for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
ERROR: for encoding a raw file you must specify a value
for --endian, --sign, --
channels, --bps, and --sample-rate
Type "flac" for a usage summary or "flac --help" for all options
D%

Robin Bowes
2004-10-20, 18:03
Jeff Coffler wrote:
> Hi Robin,
>
>
>>flac can apply tags separately to encoding. So, use EAC as you do
>>currently to rip, encode and tag, then do a 2nd pass that just adds the
>>replaygain tags.
>>
>>It should be as simple as running flac --replaygain *.flac in each album
>>directory.
>
>
> Not quite that simple ... suggestions?
>

Jeff,

Sorry, I gave you a bum steer on this.

You need to use the metaflac program to add replay gain, like this:

# metaflac --add-replay-gain *.flac

I've actually been working on a perl script that recurses a directory
tree adding replaygain tags to all flac files found within the tree.

Feel free to check it out and see how it works for you.

R.

#!/usr/bin/perl -w
#
# Applies replaygain tags to all .flac files found within the
# specified directory tree. Album gain is also calculated for all
# files within each directory

use strict;

my $metaflac = "/usr/bin/metaflac";
my $flacargs = "--add-replay-gain";

@ARGV = ('.') unless @ARGV;

process_dirs(@ARGV);

sub process_dirs {
my @dirlist = @_;
foreach my $dir (@dirlist) {
# get all directory entries
print "Processing directory: $dir\n";
opendir(DIR, $dir) or die "Couldn't open directory $dir\n";
my @direntries = readdir(DIR) or
die "Couldn't read directory entries for directory $dir\n";
closedir(DIR);

# get all target files within the present directory
my @target_files = map { $_->[1] }
map { [ $_, "$dir/$_" ] }
grep { /\.flac$/ }
@direntries;

# get all subdirs of the present directory
my @subdirs = map { $_->[1] }
grep { -d $_->[1] }
map { [ $_, "$dir/$_" ] }
grep { !/^\.\.?$/ }
@direntries;

if (@target_files) {
# run metaflac on all target files in present directory
system ($metaflac, $flacargs, @target_files);
}
# process any subdirs of present directory
if (@subdirs) {
&process_dirs(@subdirs);
}
}
}

--
http://robinbowes.com

Robin Bowes
2004-10-20, 18:20
Robin Bowes wrote:
>
> I've actually been working on a perl script that recurses a directory
> tree adding replaygain tags to all flac files found within the tree.
>
> Feel free to check it out and see how it works for you.

Here's the first update (20 minutes after the first relase!)

>
> R.
>
> #!/usr/bin/perl -w
> #
> # Applies replaygain tags to all .flac files found within the
> # specified directory tree. Album gain is also calculated for all
> # files within each directory
>
> use strict;
>
> my $metaflac = "/usr/bin/metaflac";
> my $flacargs = "--add-replay-gain";

my $flacargs = "--add-replay-gain --preserve-modtime";

If you don't preserve the mod time when the file is updated then
slimserver will think the file has been modified and re-build the DB so
it's probably best to add the --preserve-modtime option.

R.
--
http://robinbowes.com

Robin Bowes
2004-10-21, 00:04
Robin Bowes wrote:
> Robin Bowes wrote:
>
>>
>> I've actually been working on a perl script that recurses a directory
>> tree adding replaygain tags to all flac files found within the tree.
>>
>> Feel free to check it out and see how it works for you.
>
>
> Here's the first update (20 minutes after the first relase!)
>
>>
>> R.
>>
>> #!/usr/bin/perl -w
>> #
>> # Applies replaygain tags to all .flac files found within the
>> # specified directory tree. Album gain is also calculated for all
>> # files within each directory
>>
>> use strict;
>>
>> my $metaflac = "/usr/bin/metaflac";
>> my $flacargs = "--add-replay-gain";
>
>
> my $flacargs = "--add-replay-gain --preserve-modtime";
>
> If you don't preserve the mod time when the file is updated then
> slimserver will think the file has been modified and re-build the DB so
> it's probably best to add the --preserve-modtime option.

Ok, so I didn't test this properly.

Here's a revised script that *does* work.

Save the code below into a script named apply_replaygain.pl (or whatever
you want) and run it as follows:

# apply_replaygain.pl /path/to/music

If no command-line path is specified the default is the current
directory, i.e. equivalent to apply_replayggain.pl .

I hope somebody finds this useful - I do!

R.

#!/usr/bin/perl -w
#
# Applies replaygain tags to all .flac files found within the
# specified directory tree. Album gain is also calculated for all
# files within each directory

use strict;

my $metaflac = "/usr/bin/metaflac";
my @flacargs = qw ( --preserve-modtime --add-replay-gain );

@ARGV = ('.') unless @ARGV;

process_dirs(@ARGV);

sub process_dirs {
my @dirlist = @_;
foreach my $dir (@dirlist) {
# get all directory entries
print "Processing directory: $dir\n";
opendir(DIR, $dir) or die "Couldn't open directory $dir\n";
my @direntries = readdir(DIR) or
die "Couldn't read directory entries for directory $dir\n";
closedir(DIR);

# get all target files within the present directory
my @target_files = map { $_->[1] } # extract pathnames
map { [ $_, "$dir/$_" ] } # form (name, path)
grep { /\.flac$/ } # just flac files
@direntries;

# get all subdirs of the present directory
my @subdirs = map { $_->[1] } # extract pathnames
grep { -d $_->[1] } # only directories
map { [ $_, "$dir/$_" ] } # form (name, path)
grep { !/^\.\.?$/ } # not . or ..
@direntries;

if (@target_files) {
# run metaflac on all target files in present directory
system ($metaflac, @flacargs, @target_files);
}
# process any subdirs of present directory
if (@subdirs) {
&process_dirs(@subdirs);
}
}
}



--
http://robinbowes.com

Jeff Coffler
2004-10-29, 22:48
Hi guys,

I'm having a question enabling ReplayGain with FLAC.

Robin Bowes said:

> I don't know for sure but custom conversion specifications go in
> slimserver-convert.conf. I presume these override those specified in
> convert.conf.
>
> Try this thread:
>
> http://lists.slimdevices.com/archives/discuss/2004-June/031443.html

I took a look at the thread. I added the qualifier to file
slimserver-convert.conf with an intentionally invalid qualifier (just to
make sure FLAC bombed). But, unfortunately, slimserver-convert.conf has no
difference. I start up slimserver.pl, and it looks like the file isn't
looked at whatsoever.

I can edit convert.conf, but as I understand it, this customization would be
lost on any upgrades of the SlimServer software.

slimserver-convert.conf (on Windows) goes in the "main SlimServer
directory". Is this the same directory as convert.conf, or one level up?

I'm pretty close. If I edit convert.conf, things clearly fly. But how do I
make this change with slimserver-convert.conf?

Thanks,

-- Jeff