Help - Search - Members - Calendar
Full Version: FLAC -> MP3, how to migrate ReplayGain?
Hydrogenaudio Forums > Lossy Audio Compression > MP3 > MP3 - General
nitro322
I'm writing a script that will transcode FLAC files to either Ogg Vorbis or MP3. Part of the process involves copying over all tag and ReplayGain data. When converting to Ogg Vorbis this is easy because ReplayGain is implemented as comments in FLAC files; all I have to do is copy the tags and the ReplayGain information is included.

However, I'm not sure how I can copy over the ReplayGain information to an MP3 file. As far as I can tell there are no id3v1 or id3v2.3 tags available for ReplayGain. I know that mp3gain has some kind of support for APEv2 tags, but I'm not really sure how to apply that to an MP3 file.

I also considered using mp3gain directly, but I want to transfer the ReplayGain information, not reanalyze and apply new data. I know that you can specify the ReplayGain information mp3gain should apply, but I don't know how to make that work either as the information produced by ReplayGain and mp3gain seems to be different. For example, here's the Track ReplayGain and mp3gain information for the same song that was converted from a FLAC to an MP3:

CODE
$ vorbiscomment 01-Have\ Yourself\ a\ Merry\ Little\ Christmas.ogg
REPLAYGAIN_TRACK_PEAK=0.66180420
REPLAYGAIN_TRACK_GAIN=+1.14 dB

$ mp3gain -s c 01-Have\ Yourself\ a\ Merry\ Little\ Christmas.mp3
Recommended "Track" dB change: -0.405000
Recommended "Track" mp3 gain change: 0
Max PCM sample at current gain: 25685.721088
Max mp3 global gain field: 211
Min mp3 global gain field: 128

Any suggestions here? I'm sure I'm not the first person to do something like this, but I haven't had any luck so far searching for the answer. Any ideas would be most appreciated.

Thanks.
nexus77
I know that this doesn't answer your question, but you obviously know something that I am having a hard time figuring out. How are you encoding files from a CD and having the replay gain added to the FLAC comments? What program should I use? I am a bit of a newbie in this stuff. Thanks!

beto
Beware that replaygain values for lossless and lossy of the same track/album are *not* the same. There are differences that might be significant.
To be on the safe side you should reanalyze the lossy files.
nitro322
QUOTE(nexus77 @ Aug 13 2006, 16:41) *
How are you encoding files from a CD and having the replay gain added to the FLAC comments? What program should I use? I am a bit of a newbie in this stuff. Thanks!

I just use metaflac, which includes support for ReplayGain. I automate the ripping process using AutoFLAC.

QUOTE(beto @ Aug 13 2006, 17:02) *
Beware that replaygain values for lossless and lossy of the same track/album are *not* the same. There are differences that might be significant.
To be on the safe side you should reanalyze the lossy files.

Thanks, beto. That's an interesting point that I wasn't aware of. I'll probably add an option to do exactly that. However, if possible I'd still like to provide the option to simply migrate over the replaygain settings as-is, which would greatly speed up the conversion process when we're talking about hundreds of songs. Can anyone else provide some more information on doing that?
Cartman_Sr
QUOTE(beto @ Aug 13 2006, 15:02) *

Beware that replaygain values for lossless and lossy of the same track/album are *not* the same. There are differences that might be significant.
To be on the safe side you should reanalyze the lossy files.


What would be the difference?
Egor
QUOTE(Cartman_Sr @ Aug 14 2006, 12:34) *
What would be the difference?

RG values would be different, for example:
08 - Bon Jovi - Last Cigarette.wav: Track gain -9.51 dB, Track peak 1.000000
08 - Bon Jovi - Last Cigarette_lameV5_vbr-new.mp3: Track gain -9.55 dB, Track peak 1.271805
indybrett
Yes, I had observed this as well. I always rescan after converting to lossy. It's usually a small change, but I'm anal that way ;-)
nitro322
So... given the fact that there can be a difference, does anyone know of a way copy ReplayGain setting from one file to another if they just really wanted to? Egor, it looks like you have a way to read ReplayGain settings across multiple file types using a common format. Can that same method be used to apply the ReplayGain settings?
Kirby54925
foobar2000 can do that.
nitro322
Kirby54925, thanks for the reply, but the goal here is to write a script that transcodes FLAC files to a lossy format. I can't exactly use foobar2000 for that. smile.gif

I did, however, find a solution that works. I'm using a program called getID3() to handle the actual tag management. I posted a similar question on the getID3() forum, and one of the developers responsed with a post detailing the various methods used to apply ReplayGain to MP3 files. Anyone interested in this topic should give it a read:
http://www.getid3.org/phpBB2/viewtopic.php?t=605

So, adjusted my script to check for ReplayGain tags in the source file; if found, write the ReplayGain data to the APE tag fields, which directly corrspond to the ReplayGain fields used by FLAC and Ogg Vorbis. id3 info is applied separately to standard id3v1 and id3v2.3 tags, so this shouldn't have any negative effect on players that do not support ReplayGain.

In this case I use getID3() to apply the tags, but theoretically you should be able to use any APE tag writer to do the job. Of course, I don't know of any other APE tag writers available under Linux, so like I said, "theoretically."

Hope this helps someone else out there. Thanks to those that took the time to respond.
pepoluan
QUOTE(Egor @ Aug 14 2006, 12:47) *

QUOTE(Cartman_Sr @ Aug 14 2006, 12:34) *
What would be the difference?

RG values would be different, for example:
08 - Bon Jovi - Last Cigarette.wav: Track gain -9.51 dB, Track peak 1.000000
08 - Bon Jovi - Last Cigarette_lameV5_vbr-new.mp3: Track gain -9.55 dB, Track peak 1.271805


Humans can barely hear a +/- 0.5 dB difference and you're fussing over 0.04 dB?

Get real biggrin.gif
kjoonlee
Ah, but look at the peaks.
2Bdecided
If you could, you need to copy over the album and track gains (because they should never change significantly), but re-calculate the peaks (which is quicker than re-calculating eveything).

As for the original question...

Most people going down this route are encoding for portable players. In this case, ReplayGain tags are useless, and it makes more sense to apply the gain change before encoding.

However, I'm glad you got it to work!

Cheers,
David.
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.