Log in

View Full Version : Properly transcode FLAC to WAVE then encode with LAME


sirt
10th August 2013, 08:05
Hi,

Last year I asked many questions about how to encode and transcode. But, I don't manage to do what I plan properly.

First of all, let's say I've ripped a CD of mine in FLAC via EAC. The extracted FLAC files contain tags such as the name of the artist, the year and so on. I would like to transcode a resulting FLAC to WAV then to encode the later with LAME. If I use the following comand line in a BAT file :

flac -d %1
lame -b 320 -h --add-id3v2 %1 "%~dpn1.mp3"
pause


It doesn't work because the %1 doesn't refer to the transcoded WAVE file. Consequently Lame doesn't find this WAVE.

I also tried the simple comand line applied to the WAVE :


lame -b 320 -h --add-id3v2 %1 "%~dpn1.mp3"
pause


It works but the tags (artist, year..) are lost ! To sum up, how could I properly transcode the FLAC to WAVE without loosing the tags then encode it to 320 in one single BAT file ? In fact I don't particulary want to transcode from FLAC to WAVE but Lame doesn't seem to work when a FLAC is an input.

smok3
10th August 2013, 09:30
you could use ffmpeg to keep metadata as well, challenge is to get some nice mp3 command line.

https://trac.ffmpeg.org/wiki/Encoding%20VBR%20(Variable%20Bit%20Rate)%20mp3%20audio

like;

ffmpeg -i some.flac -q:a 2 out.mp3

If the tags are incorectly copied then you could use some sort of command line tagger to copy tags from flac to mp3.

for win cli and parameter expansions, perhaps read
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true

sirt
10th August 2013, 09:38
Thanks smok3. But I don't want to use ffmeg or anything like that. I want to use a BAT file. At least, I would like to transcode and encode like I tried above.

smok3
10th August 2013, 09:46
you can
a. change my ffmpeg example to your bat by reading the provided parameter expansions link
b. make a bat file that uses: flac -d, lame to encode, 3rd party tagger to copy tags from flac to mp3 (again this will be possible once you understand parameter expansions)

There are also lame compiles that are capable of flac input
http://www.rarewares.org/mp3-lame-bundle.php

(I'am not on windows, so I can't really test all that)

sirt
10th August 2013, 10:14
Unfortunately I don't really understand how this bat language works. As I said below, I don't even manage to transcode from FLAC to WAV and then encode in the same BAT file. We could first start to set that.

Secondly, I'm not sure to understand either how I could use a "3rd party tagger to copy tags from flac to mp3" in a BAT file. And about the lame compiles capable of dealing with FLAC input, is this RareWares version similar to the official one ?

raffriff42
10th August 2013, 11:25
>It doesn't work because the %1 doesn't refer to the transcoded WAVE file.
Instead of
lame ... %1 "%~dpn1.mp3"
use
lame ... "%~dpn1.wav" "%~dpn1.mp3"

See Path Manipulation in a Batch File (http://blogs.msdn.com/b/ben/archive/2007/03/09/path-manipulation-in-a-batch-file.aspx)

BTW, using "%~dpnx1" in place of %1 enforces quote wrapping instead of trusting the OS to do it.

sirt
10th August 2013, 12:05
Thanks raffriff42 for your answer. Something like that :

if [%1]==[] goto :eof
:loop
flac -d %1
lame_normal -b 320 -q0 --add-id3v2 "%~dpn1.wav" "%~dpn1.mp3"
del "%~dpn1.wav"
shift
if not [%1]==[] goto loop
pause

Transcodes all the FLAC from the directory to WAVES and encode those WAVES to MP3. The WAVES are also deleted after being compressed. Then, this is equivalent to :

PUSHD %~dp0
if [%1]==[] goto :eof
:loop
lame -b 320 -q0 --add-id3v2 %1 "%~dpn1.mp3"
shift
if not [%1]==[] goto loop
pause


By using the special build from smok3 link allowing FLAC processing.

Howhever, in both cases I loose all the original tags from FLAC files and it forces me to rewrite them manually. What would be a simple way to preserve them ? I guess it would be based on smok3 idea but I don't understand.

Moreover how could I write the MP3 into a directory called "result" for example ? What would be the command to use into the BAT ?

smok3
10th August 2013, 12:09
an example going from flac to lossy flac using "tag" to copy/paste tags;

@echo off
:repeat
if %1.==. goto end
if exist %1 flac -d %1 --stdout --silent|lossywav - --stdout -P --stdinname %1|flac - -b 512 -o "%~dpn1.lossy.flac" --silent && tag --fromfile %1 "%~dpn1.lossy.flac"
shift
goto repeat
:end

tag can be found here;
http://www.rarewares.org/others.php

(again this is just from my memory, not even sure if that compile of tag is still working today)

sirt
10th August 2013, 12:37
smok3, thanks for your help. Something is still unclear to me : let's say I download that "TAG command line tagger" from your related link. Then, how am I supposed to use your last code above ?

I don't see how it could be included there :

if [%1]==[] goto :eof
:loop
flac -d %1
lame_normal -b 320 -q0 --add-id3v2 "%~dpn1.wav" "%~dpn1.mp3"
del "%~dpn1.wav"
shift
if not [%1]==[] goto loop
pause

To be honest I'm not even sure to understand your code : is this a way to recover the tags from flac files, keep them in memory and rewrite them into the final mp3 files generated by lame ? It is in fact much more similar to an example so I can't use it directly in my context. In particular, I don't want to recompress any flac to "lossy flac".

smok3
10th August 2013, 12:41
maybe (not tested)

if [%1]==[] goto :eof
:loop
flac -d %1
lame_normal -b 320 -q0 --add-id3v2 "%~dpn1.wav" "%~dpn1.mp3" && tag --fromfile %1 "%~dpn1.mp3"
del "%~dpn1.wav"
shift
if not [%1]==[] goto loop
pause

sirt
10th August 2013, 12:56
Well, thanks at least this code works but there is something weird. Even if the tags seem to have been written they don't exist. I open a resulting MP3 into Mp3tag in order to add a frame as tag to but none of the tags previously written appear there. I don't see a reason why excepted that the "tag.exe" doesn't write them properly.

After different tries, it seems there is a conflict with a lame parameter I use --add-id3v2 because tag reports "ID3v1tag written". Disabling --add-id3v2 enables tag to write some tags but the type of music isn't kept for example. Well do you think it is possible to writ v2 tags with tag.exe instead of v1 tags ?

smok3
10th August 2013, 13:02
According to tag docs it does not support writing id3v2 tags (only reading and removing).

sirt
10th August 2013, 13:06
Then what is the difference between v1 and v2 ? Personally, I don't mind but does that, practically, change something ?

And to conclude, if you want to make me really happy (:D) let's say the FLAC files are on a folder named MAIN, I would like the MP3 files to be written into a folder called RESULT inside MAIN.

JReiginsei
10th August 2013, 14:02
I use Foobar2000 because it will keep the tags when transcoding FLAC. But it doesn't seem to transfer the cover art.

So, I use mp3tag to add the cover art to the transcoded songs.

detmek
10th August 2013, 14:49
It would be much easier to use some of lame GUIs like TAudio Converter, foobar2000, LamedropXPd3, dbPowerAmp ect. LamedropXPd3 works with drag-and-drop, dbPowerAmp offers shell integration (even in free version), foobar can apply DSP effects during conversion. So, if your goal is a specific way of conversion (using cmd) I can not help but if you just want mp3 files one of the GUIs is the way to go.
So, the question is: Do you really need CMD way of conversion?
BTW, WAV files have no standard way of taging so most applications do not support tagging WAV files. Converting FLAC to WAV and than to mp3 is useless.

sirt
10th August 2013, 15:58
Thanks detmek, indeed I want to learn how to do all this manually. I could simply do it with EAC but I intentionally extracted tracks as FLAC files via EAC in order to encode them like I intend above. Well, what I did before is great : my code works fine and I just need to add a few things on Mp3tag to be satisfied. My only doubt is that conflict between v1 and v2 way of tagging : do you know something about this ? In particular, what would change using v1 instead of v2 ?

And moreover why do you think converting FLAC to WAVE and finally to MP3 is "useless" ? By using the code above, FLAC are transcoded to WAVES then encoded to LAME and the use of tag.exe allows to extract (all) tags from original FLACS and write them into the resulting MP3.

detmek
10th August 2013, 18:02
Because lame.exe with FLAC input support already decode FLAC to PCM internaly (that is also what you get when you decode FLAC to WAV). So, it is useless, takes more time and disk space and complicates your script. And you already extract info from FLAC files, not WAV ones.

ID3 V1 tags have more restrictions than V2, like shorter file names, custom fields can not be used with V1, tag size is limited to 128 bytes, limited genre support, no album art, ect. You have article on Wikipedia (https://en.wikipedia.org/wiki/Id3) about ID3 tags.

You could use MediaInfo to extract info from original file and than write that to new mp3 file or pass it to lame encoder. In that case you can use ID3 V2 tags. It will require more complicated script, though.

sirt
11th August 2013, 08:43
Ok thanks detmek.

After a few tests I found something like this :

if [%1]==[] goto :eof

mkdir result

:loop
flac -d %1
lame_normal -b 320 -q0 --add-id3v2 "%~dpn1.wav" "%~dp0result\~n1.mp3"
del "%~dpn1.wav"
if not [%1]==[] goto loop
pause

I would have excepted this code to create a sub folder "result" under my main folder where all the compressed MP3 files would have been compressed. But it doesn't work well : indeed, "result" is created by the mkdir line but if I drag several FLAC files to the BAT file, it looks like an infinit loop occurs : the first track is processed and it never stops.

raffriff42
11th August 2013, 09:07
> it looks like an infinit loop occurs
You left out the "shift" line; see post #10

sirt
11th August 2013, 10:20
Okay. Finally this code is working :

if [%1]==[] goto :eof

mkdir result

:loop
flac -d %1
lame_normal -b 320 -q0 --add-id3v2 "%~dpn1.wav" "%~dp1result\%~n1.mp3"
del "%~dpn1.wav"
shift
if not [%1]==[] goto loop
pause

Reino
11th August 2013, 16:06
Not piping flac's output to lame doesn't make sense in this case, especially since you delete the wav-file afterwards.

There are 3 ways to accomplish what you want (without a temporary wav-file!):

@ECHO OFF

SET pathToFlac="D:\Binaries\flac (FLAC 1.3.0,MSVC2012).exe"
SET pathToLame="D:\Binaries\lame (MP3 Encoder 3.99.5, 29022013).exe"
SET pathToTag="D:\Binaries\tag (Tag 2.0.52, command line tagger).exe"

:loop
IF "%~1"=="" GOTO end
%pathToFlac% -dc %1 | %pathToLame% -V 5 - "%~dpn1.mp3" && %pathToTag% --hideinfo --hidetags --fromfile %1 "%~dpn1.mp3"
DEL %1
SHIFT
GOTO loop
:end
PAUSEPipe Flac's output to Lame's input and copy the tag afterwards.

@ECHO OFF

SET pathToLame="D:\Binaries\lame (MP3 Encoder 3.99.5 using libsndfile 1.0.25, 29022013).exe"
SET pathToTag="D:\Binaries\tag (Tag 2.0.52, command line tagger).exe"

:loop
IF "%~1"=="" GOTO end
%pathToLame% -V 5 --nohist --noreplaygain %1 "%~dpn1.mp3" && %pathToTag% --hideinfo --hidetags --fromfile %1 "%~dpn1.mp3"
DEL %1
SHIFT
GOTO loop
:end
PAUSEAs mentioned earlier by smok3, this lame version accepts Flac-files directly.
In both cases you need Tag, because even with a direct flac-to-mp3 Lame can't copy the tag. Downside is Tag can only write id3v1 tags.

@ECHO OFF

SET pathToFFmpeg="D:\Binaries\ffmpeg-20130720-git-835eee8.exe"

:loop
IF "%~1"=="" GOTO end
%pathToFFmpeg% -i %1 -q:a 5 "%~dpn1.mp3"
SHIFT
GOTO loop
:end
PAUSEDirect flac-to-mp3 with id3v2.4 tag using FFmpeg.

[off-topic]Input #0, flac, from 'sample.flac':
Metadata:
ALBUM : sample
ARTIST : sample
DATE : sample
GENRE : sample
TITLE : sample
track : sample
Duration: 00:00:25.50, bitrate: 809 kb/s
Stream #0:0: Audio: flac, 44100 Hz, stereo, s16

...

Output #0, mp3, to 'sample.mp3':
Metadata:
TALB : sample
TPE1 : sample
TDRL : sample
TCON : sample
TIT2 : sample
TRCK : sample
TSSE : Lavf55.12.102
Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p
Stream mapping:
Stream #0:0 -> #0:0 (flac -> libmp3lame)
Press [q] to stop, [?] for help
size= 428kB time=00:00:25.52 bitrate= 137.3kbits/sSource: 0:25.500 (1 124 550 samples)
Lame's mp3: 0:25.500 (1 124 550 samples)
FFmpeg's mp3: 0:25.548 (1 126 656 samples) (as reported by foobar2000)
I actually never encode to mp3, but when I do I normally use Lame. So does anyone know what's this about with ffmpeg?
[/off-topic]

sirt
11th August 2013, 17:09
Wow CoRoNe many thanks for your help. I really appreciate those informations !

As I said below, there was a conflict when using tag.exe : it didn't allow id3v2 tagging which I rather prefer. So I gave a try to your first code, it works thanks but any tag appears in Mp3tag when I load a resulting file. It is due to the fact I use the --add-id3v2 with Lame. If I don't use this line, it works well (the tags are recognized) but they are id3 v1 tags.

Do you know how I could use v2 ? I don't want to use FFMpeg or anything like this.

Reino
11th August 2013, 18:19
Since Tag can only write id3v1 tags and you don't want to use ffmpeg, you're out of luck.
Or... you could enter the info all manually of course :D:
%pathToLame% -V 5 --nohist --noreplaygain --id3v2-only --pad-id3v2 --ta "artist" --tt "title"
--tg "genre" --tl "albumtitle" --ty "year" --tn "tracknr/numtracks" %1 "%~dpn1.mp3"

Other than that, I would use Mp3Tag (http://www.mp3tag.de/en).

sirt
11th August 2013, 18:27
CoRoNe, yes it is exactly what I do, entering the infos manually :D It just requieres some time. But I just copy them from the FLAC.

To conclude, as it seems you are great at bash language, let's say I have a main folder named PRINCIPAL which contains the different .exe needed. Imagine I copy into this folder another one called MUSIC_(flac). We can work with your first code for example. I would like to create a BAT file that would automatically select this MUSIC_(flac) folder (or whatever the name is) and then generate a folder with the same name excepted the end : MUSIC_(mp3) in which I would have the different compressed MP3 files. Would you know how to do something like that ?

Reino
11th August 2013, 21:11
Haha, hardly. I'm a beginner as well.

@ECHO OFF

SET pathToLame="D:\Binaries\lame (MP3 Encoder 3.99.5 using libsndfile 1.0.25, 29022013).exe"
SET pathToTag="D:\Binaries\tag (Tag 2.0.52, command line tagger).exe"

mkdir "%~dp1MUSIC_(mp3)"

:loop
IF "%~1"=="" GOTO end
%pathToLame% -V 5 --nohist --noreplaygain %1 "%~dp1MUSIC_(mp3)\%~n1.mp3"
&& %pathToTag% --hideinfo --hidetags --fromfile %1 "%~dp1MUSIC_(mp3)\%~n1.mp3"
SHIFT
GOTO loop
:end
PAUSE
This worked for me where MUSIC_(mp3) is just another sub-directory. I don't know how to create and set the directory 1 parent higher. Clearly "%~dp1..\MUSIC_(mp3)" doesn't work.

smok3
11th August 2013, 22:42
there are some scripts like that (I have only tested this one on debian)
http://robinbowes.github.io/flac2mp3/
(perl in this case)

sirt
12th August 2013, 07:34
CoRoNe

Well thanks, what you did is actually what I managed to achieve. You are manually creating a folder called MUSIC_(mp3). But I would prefer a code automatically creating a folder with the same name than the one copied into the main one. It could be : dqqsfqfqfg_(FLAC) and I expect to get dqqsfqfqfg_(MP3). But it is perhpas not possible to set this without knowing the name of the FLAC folder.

smok3

Thanks, I knew it but I don't like that one because I can't use the comand line I want excepted if I modify myself the code.

Overdrive80
12th August 2013, 14:43
You can obtain name folder of this way:

for /f "tokens=5 delims=\" %%i in ("C:\Users\Isra\Desktop\Descargas") do (

echo %%i

)

SeeMoreDigital
12th August 2013, 16:38
I would like to transcode a resulting FLAC to WAV then to encode the later with LAME.
Is there any particular reason why you can't encode from FLAC directly to LAME (MP3)?

sirt
12th August 2013, 19:55
Yes, thanks Overdrive80.

SeeMoreDigital, official LAME builds don't accept FLAC as input.

detmek
12th August 2013, 21:07
No, but you can use stdout/stdin. I found this exaple:
for %F in (*.flac) do flac -d -c | lame - "%~nF.mp3"
Modify to your needs.
P.S. -c is for stdout, as you can see.

hello_hello
13th August 2013, 17:33
I don't bother with tagging while encoding as invariably I'll want to check/edit the tags anyway. If you're converting a large number of files to MP3 and the originals are correctly tagged you can copy all the tags from the flac files to the MP3 files quite easily with Mp3Tag.

Just open the folder containing the original flac files (or just the files you converted) with Mp3Tag, highlight them all, right click and use the option for copying tags. Open the folder full of encoded MP3s with Mp3Tag, highlight, right click and paste.
Just make sure when you open each they're ordered in the same way so you don't end up pasting the tags into the wrong files. Generally I'd re-encode so the output MP3s have the same file names as the input flac files, therefore I'd order them by file name in Mp3Tag.

Because multiple types and versions of tags can be stored in the same file, Mp3Tag has a few options regarding which tags it'll display and which tags it writes etc. For instance if you open a bunch of files containing ID3 version 1 tags but Mp3Tag is set to only display ID3 version 2, I don't think you'll see any tags until you change the setting, but once you get your head around that I think it's a good system for working with multiple tags in the same file.

I use ID3 version 2.3 tags myself because ID3 version 1 is too limited and ID3 version 2.4 isn't as widely supported. I think for that reason, a while back foobar2000 reverted to writing 2.3 tags by default instead of 2.4

sirt
18th August 2013, 10:30
Thanks to all of you for your answers.

What I am doing is purely educative : I can rip my personal CD's with EAC ; hello_hello, your solution is interesting. I didn't know it is possible to copy paste like that in Mp3tag.

Futhermore, for what reason do you think ID3 v1 is limited unless the limitations mentioned above ? Otherwise, is there an alternative to that tag.exe that would allow v2 tagging ?

hello_hello
18th August 2013, 14:56
It's been a while since I've paid much attention to ID3v1 tags.... aside from using Mp3Tag to copy and paste them as ID3v2.3 before removing them.... but yeah I think the limitations are pretty much just what has already been mentioned.

In case you haven't used it much, Mp3Tag is very handy for renaming files and/or tagging according to file name etc. As an example, if you have a bunch of files correctly tagged, you can tell Mp3Tag to rename them using your desired format (Artist-Track-Title, or Title-Artist etc). Likewise it can use the file names to automatically create tags.

I think foobar2000 has been suggested previously, but as you mentioned the automatic naming of files and batch encoding earlier.... foobar2000 will do both for you and you can save the way it names files as part of a conversion preset. It'll also automatically tag and it'll probably use tags for naming too if you want it to, but I don't use it for tagging much myself as I'm accustomed to Mp3Tag. One advantage of foobar2000 is you can load a bunch of files into a playlist, highlight them all, right click and select a conversion preset, and it'll encode as many simultaneously as you have CPU cores until it's done. Or you can convert to multiple formats at the same time etc. Or you can encode to a multi-track file (ie an album as a single FLAC file, correctly tagged) or re-encode multi-track files as individual tracks etc....
foobar2000 will rip CDs and it has a couple of "secure" ripping modes.

foobar2000 will also scan files using ReplayGain, and you can optionally use the ReplayGain data when re-encoding to another format, so you could keep your FLAC files at their original volumes, scan them, and then convert them to MP3s which all sound pretty much the same level.
I tend to convert to MP3 "as-is" and then use MP3Gain to scan them and adjust their volumes, but doing it that way is more habit than anything else. Chances are most conversion programs will apply ReplayGain when re-encoding these days, but in my opinion if you're converting to a final format for "playing", levelling out the volumes is an absolute "must". Especially if you're like me and tend to put a variety of MP3s on a portable player and run it in random playback mode.

sirt
18th August 2013, 19:08
Thank you hello_hello for your detailled explanations.

Do you mean that if, on the one hand, I rip a CD in MP3 with EAC and on the other hand I just extract data in FLAC with EAC and encode them afterwards to MP3, there will be a difference ? I have never heard about "ReplayGain", isn't there something like this included into LAME MP3 encoder ? From what you say, it looks as if extracted FLAC files (with EAC) doesn't keep their original volume. Or, am I wrong and you are just telling me about how to enhance MP3 resulting files ? Anyway can you use "ReplayGain" in CLI mode with LAME ?

detmek
18th August 2013, 19:26
In both cases it is ripping. And no, there will be no difference if you rip directly from CD to MP3 or go with CD - FLAC - MP3.
There is ReplayGain option in LAME encoder but it strores values to LAME header and none of the players reads that value. foobar2000 can scan files for ReplayGain and write those values to ID3 tags. When you convert to other format with foobar, you have an option to apply those values so the outputted files will have the same volume even on non-replaygain aware players.
BTW, ReplayGain is like normalizing. The difference is normalizing uses peak loudness while ReplayGain tries to calculate average loudness.

sirt
18th August 2013, 19:46
Thanks detmek, I just had an eye to the related wiki page. ReplayGain (used into MP3Gain) seems to be an algorithm to normalize MP3 data without distorsions. But it is unclear to me : why would I do this in so far as I rip music from commercial CD's ? It is commonly admitted data from such CD's usually have the same volume, pitch and so on. Or at least I believe this. And I'm not convinced encoding lossless data to MP3 (with decent parameters) will alter this.

Actually, I guess I don't see the point of doing this. So here I've uploaded an MP3 file ripped with EAC from my own commercial CD. I used -b 320 -q 0 as encoding parameters :

http://www.sendspace.com/file/uaktiv

Then do you mean you can make it sound better with MP3Gain ? I would like to see but I've never used anything like this. In fact, this MP3 above is already great to me, that is why I don't understand what MP3Gain could improve.

Groucho2004
18th August 2013, 21:57
I just had an eye to the related wiki page. ReplayGain (used into MP3Gain) seems to be an algorithm to normalize MP3 data without distorsions. But it is unclear to me : why would I do this in so far as I rip music from commercial CD's ?
It's explained in the first paragraph of the Wikipedia page you referred to.

It is commonly admitted data from such CD's usually have the same volume, pitch and so on.
If you think that then you must only have 2 or 3 CDs which coincidentally have the same volume. Also, what is "commonly admitted"?

And I'm not convinced encoding lossless data to MP3 (with decent parameters) will alter this.
There is no such thing as lossless data. A conversion or encoding process can be lossless or lossy.

Then do you mean you can make it sound better with MP3Gain ? I would like to see but I've never used anything like this. In fact, this MP3 above is already great to me, that is why I don't understand what MP3Gain could improve.As usual, my advice to you is to read up on very basic concepts.

Reino
19th August 2013, 11:05
Mp3Tag would indeed be the first choice for many people, but trying to figure out how to do it in batch-script is always very educative.
I figured out the following returns the desired directory...

FOR %%? IN ("%~1\..") DO ECHO Parent Folder : %%~dp?

...but I don't know how to integrate it into the original script. Then you'd be home free (and if someone can help, I would learn something too).

hello_hello
19th August 2013, 11:22
Thanks detmek, I just had an eye to the related wiki page. ReplayGain (used into MP3Gain) seems to be an algorithm to normalize MP3 data without distorsions. But it is unclear to me : why would I do this in so far as I rip music from commercial CD's ? It is commonly admitted data from such CD's usually have the same volume, pitch and so on. Or at least I believe this. And I'm not convinced encoding lossless data to MP3 (with decent parameters) will alter this.

Think of ReplayGain as being an "automatic" way to turn the player's volume up and down to compensate for the different volumes between tracks. That's really all it is.
ReplayGain has two different modes. I think the names were changed at one stage as the word "album" isn't used so much any more, but they still do the same thing. I know them as "track gain" and "album gain".
Track gain scans all tracks individually. Album gain scans a group of tracks as a whole. The idea being you might want to apply ReplayGain to an album but you don't want to change the volume of the tracks relative to each other. Album gain effectively treats a group of tracks as a single track.
I always use track gain as I don't play an album's worth of tracks from start to finish very often. I'll put whole CDs on my MP3 player, but I just run it in random mode. As a result, the player can go from playing Billie Holiday to Billy Idol and you really need to make sure all the tracks sound the same in terms of volume when you do that.

Then do you mean you can make it sound better with MP3Gain ? I would like to see but I've never used anything like this. In fact, this MP3 above is already great to me, that is why I don't understand what MP3Gain could improve.

The whole idea of ReplayGain is to level out the volume between different tracks. It doesn't compress the audio or anything like that. It calculates the average loudness of a track. So it doesn't change the quality, just the overall volume.

The original idea of ReplayGain was to store the ReplayGain data in tags. Then you'd play a track and the player would read the tags and adjust the volume of the track accordingly. Unfortunately though, ReplayGain support outside of PC audio players is almost non-existent. I'm pretty sure ipods support it, but Apple basically ripped it off and called it something else, so ipods don't use standard ReplayGain tags.

So given players won't read the tags and adjust track volumes accordingly, the alternative is to create tracks which already have ReplayGain applied.
MP3s can have their volumes adjusted losslessly (no need to re-encode). It's the only format which can. Hence MP3Gain.
MP3Gain will scan MP3s and adjust their volumes, and store the data in APE tags in each MP3, so as long as the tags remain, it can reverse any volume changes it makes. I think these days foobar2000 can do the same.
The alternative is to scan files with ReplayGain and use the ReplayGain info to adjust the volume of tracks while re-encoding. foobar2000 can do that. So.....

Myself, I rip to FLAC because it's lossless. I've got a lossless copy of each CD as the "master". That way I can convert the FLAC files to a lossy format such as MP3 for playing, but if next year I buy a player which supports AAC or the "new clever audio compression format", I don't need to re-rip all my CDs, I can just convert the FLAC files to the new format.
If you convert the FLAC files to MP3 you can then run the MP3s through MP3Gain. Or you can scan the original FLAC files with ReplayGain and foobar2000 will save the ReplayGain data in tags (it won't change the audio itself in any way). Then when you convert to MP3, you can tell foobar2000 to apply ReplayGain (either track gain or album gain) while encoding. The resulting files should all have around the same volume. Unlike using MP3Gain after converting, the process can't be reversed as it's being applied while encoding, but of course as you're converting the original lossless FLAC files, there's always the option to convert them to MP3 again without using ReplayGain if you want to.

ReplayGain isn't perfect, but it's very, very, very good. The difference between track volumes can be huge. For older CDs it's not uncommon for ReplayGain to result in track volumes being increased. For newer CDs it generally lowers the volume quite a bit, but the end result is you can stick all your music on a player, let it run and not have to reach for the volume between every single track.

There should be no difference between ripping to MP3 and ripping to FLAC and then converting to MP3, aside from the fact method two gives you a lossless copy as a backup or to use in the future, whereas method one does not.
I don't use 320kb/s CBR MP3s for that reason. As I have lossless FLAC versions I just convert them to MP3 using the standard LAME V2 VBR preset. The resulting MP3 file size will be a lot smaller, and I can't hear a difference. Here's what the golden-eared folks over at hydrogenaudio say about CBR 320kb/s Vs the variable bitrate presets:

Recommended encoder settings (http://wiki.hydrogenaudio.org/index.php?title=LAME#Recommended_encoder_settings)
"As demonstrated by blind ABX tests, LAME-encoded MP3s typically achieve this level of transparency when encoded with the default settings, at bitrates well below maximum. Encoding with other settings will have no effect on the quality. "
-b 320
"This CBR mode will maximize the MP3's bitrate and overall file size. The extra space may allow for some parts of the audio to be compressed with fewer sacrifices, but to date, no one has produced ABX test results demonstrating that perceived quality is ever better than the highest VBR profiles described above."

I'd recommend you pick a couple of MP3s from your collection which have completely different volumes. Make a copy of each to play with and load the copies into MP3Gain. Use the TrackGain button to apply track gain. When it's done, listen to the copies of the MP3s again. Once you have you'll probably wonder how you ever listened to music without ReplayGain. ;)

sirt
20th August 2013, 09:57
Groucho2004

By "commonly admitted" I was pointing the fact that different tracks from the same commercial CD have the same volume. At least, I hope it is like this. Else, it would mean the CD has badly been mastered. It looks like using this MP3Gain is a way to enhance MP3 but, well, I already like my MP3 in the way they are so...


CoRoNe

Thank you but I think it will kind of hard to reproduce Mp3Tags into bash files. I wish you good luck to achieve this :D

hello_hello

Wow, extraordinary post. The main word I will remember is "automatic". As a matter of fact, I don't like anything automatic. Even if adjusting audio levels would lead to a better audio listening "perception", I'm not in favour of something like this. But it is personal.

Indeed, from all we talked over in there, it brings out original CD quality is not distorted if tracks are ripped in FLAC or MP3. But, perhaps, original audio levels are not always "correct" and MP3Gain will restore them. The problem is I haven't never listened any "huge difference" between tracks (from the same CD). I am perhaps deaf ! In your reasoning, you maybe refer to the fact one would like to create a playlist with different MP3 from different sources. In this case, I understand the interest of MP3Gain. But if you use several tracks from the same original CD and note volume difference between them then, in my opinion, it means the CD is crap.

smok3
20th August 2013, 22:16
By "commonly admitted" I was pointing the fact that different tracks from the same commercial CD have the same volume. At least, I hope it is like this. Else, it would mean the CD has badly been mastered.


That is certainly not a fact, also you have a huge gap in understanding volume/loudness and similar stuff (No, I will not do your homework)

Moby 18, r128 analysis example, check the (I) values from song to song;
https://dl.dropboxusercontent.com/u/79532365/moby18_r128.txt

Reino
20th August 2013, 22:19
Thank you but I think it will kind of hard to reproduce Mp3Tags into bash files. I wish you good luck to achieve this :DWell, as long as the target is a sub-directory, all goes well, but for some reason Tag.exe is having difficulty the moment it's one directory higher than %~1 (http://www.hydrogenaudio.org/forums/index.php?showtopic=26497&view=findpost&p=842494).

hello_hello
21st August 2013, 07:11
By "commonly admitted" I was pointing the fact that different tracks from the same commercial CD have the same volume. At least, I hope it is like this. Else, it would mean the CD has badly been mastered. It looks like using this MP3Gain is a way to enhance MP3 but, well, I already like my MP3 in the way they are so...

Yes and no..... these days when pop music has always got to be as loud as possible, what you're saying is very often true, there's very little volume difference between tracks on a CD. However, often there's more than you'd expect.


Wow, extraordinary post. The main word I will remember is "automatic". As a matter of fact, I don't like anything automatic. Even if adjusting audio levels would lead to a better audio listening "perception", I'm not in favour of something like this. But it is personal.

I'd completely agree and completely disagree at the same time. I tend to be a control freak too. I set up every video encode individually, checking cropping and experimenting with filtering etc. "Automatic" isn't good enough. However....
When it comes to adjusting the volume of audio tracks so they all sound the same level, it's physically impossible to do it "manually". Sure you could listen to a handful of them, but for hundreds of tracks you'd spend the rest of your life getting it right.
All ReplayGain does is scan the tracks using a formula to determine how loud each one sounds to the human ear. It doesn't change the audio in any way aside from the volume, so the only way it can change "perception" is when it comes to playing one track after another and whether you the need to adjust the volume each time... or not.
ReplayGain works very well. Much better than you'd ever manage yourself, especially when it comes to adjusting large numbers of files. If it didn't work well, I wouldn't use it myself.

Indeed, from all we talked over in there, it brings out original CD quality is not distorted if tracks are ripped in FLAC or MP3. But, perhaps, original audio levels are not always "correct" and MP3Gain will restore them. The problem is I haven't never listened any "huge difference" between tracks (from the same CD). I am perhaps deaf ! In your reasoning, you maybe refer to the fact one would like to create a playlist with different MP3 from different sources. In this case, I understand the interest of MP3Gain. But if you use several tracks from the same original CD and note volume difference between them then, in my opinion, it means the CD is crap.

True to a certain extent, although I could probably name several CDs off the top of my head which have huge volume differences between tracks, but that's okay as that's how they're supposed to be. "Concept Albums" (which I guess are a thing of the past) would more often than not fall into that category. There's even plenty of albums where there's no silence between the tracks... which is why ReplayGain has Album Gain mode.

Yes, if all you ever do is play a whole CD from start to finish, there's probably not a huge need for ReplayGain (although I'd still use it myself), but if you're creating play-lists from multiple CDs etc, it's indispensable.

Anyway, it's up to you if you want to try it, but I wouldn't be too quick to dismiss something until I had (because I've done just that enough times in the past myself, only to realise later it was a big mistake). You can probably test quite easily whether ReplayGain works as described. Take a CDs worth of MP3s.... one of those CDs where you're confident every track sounds the same in terms of volume... and run them through MP3Gain using Track Gain (you can run a scan and MP3Gain will report the results without changing anything). All that'll probably happen, is MP3Gain will confirm what you already know. Many times I've run a similar CD's worth of tracks through MP3Gain and it's reported almost identical volumes between them. Sometimes the variation is as small as 3dB for modern "pop" CDs.
If when you do though, MP3Gain reports a much larger volume difference between tracks than you expected, let it adjust them all using Track Gain and then compare them again yourself. You might be surprised as to which one of you got it right. ;)

Reino
21st August 2013, 20:11
Well, as long as the target is a sub-directory, all goes well, but for some reason Tag.exe is having difficulty the moment it's one directory higher than %~1 (http://www.hydrogenaudio.org/forums/index.php?showtopic=26497&view=findpost&p=842494).Weird. I can't reproduce the issue I had anymore. Mp3's in a parent directory now get properly tagged.

So you can use the following batch-script:
@ECHO OFF

SET pathToLame="D:\Binaries\lame (MP3 Encoder 3.99.5 using libsndfile 1.0.25, 29022013).exe"
SET pathToTag="D:\Binaries\tag (Tag 2.0.52, command line tagger).exe"

mkdir "%~dp1..\MUSIC_(mp3)"
:loop
IF "%~1"=="" GOTO end
%pathToLame% -V 5 --nohist --noreplaygain %1 "%~dp1..\MUSIC_(mp3)\%~n1.mp3"
&& %pathToTag% --hideinfo --hidetags --fromfile %1 "%~dp1..\MUSIC_(mp3)\%~n1.mp3"
SHIFT
GOTO loop
:end
PAUSE
Copy-paste it in Notepad, change paths (lame and tag) appropriately, change lame settings if you so desire and save as *.bat. Then you can drag&drop any flac-file (or wav-file) onto it.

Stereodude
30th August 2013, 17:26
I think foobar2000 has been suggested previously, but as you mentioned the automatic naming of files and batch encoding earlier.... foobar2000 will do both for you and you can save the way it names files as part of a conversion preset. It'll also automatically tag and it'll probably use tags for naming too if you want it to, but I don't use it for tagging much myself as I'm accustomed to Mp3Tag. One advantage of foobar2000 is you can load a bunch of files into a playlist, highlight them all, right click and select a conversion preset, and it'll encode as many simultaneously as you have CPU cores until it's done. Or you can convert to multiple formats at the same time etc. Or you can encode to a multi-track file (ie an album as a single FLAC file, correctly tagged) or re-encode multi-track files as individual tracks etc....
foobar2000 will rip CDs and it has a couple of "secure" ripping modes.IMHO, dBpoweramp's Batch Converter does FLAC to ____ conversions one better. It also copies the tags, but it retains the album art when converting formats. For whatever reason Foobar2k doesn't retain art when converting.

Stereodude
30th August 2013, 17:29
Thanks detmek, I just had an eye to the related wiki page. ReplayGain (used into MP3Gain) seems to be an algorithm to normalize MP3 data without distorsions. But it is unclear to me : why would I do this in so far as I rip music from commercial CD's ? It is commonly admitted data from such CD's usually have the same volume, pitch and so on. Or at least I believe this. And I'm not convinced encoding lossless data to MP3 (with decent parameters) will alter this.

Actually, I guess I don't see the point of doing this. So here I've uploaded an MP3 file ripped with EAC from my own commercial CD. I used -b 320 -q 0 as encoding parameters :

http://www.sendspace.com/file/uaktiv

Then do you mean you can make it sound better with MP3Gain ? I would like to see but I've never used anything like this. In fact, this MP3 above is already great to me, that is why I don't understand what MP3Gain could improve.I only use MP3gain to reduce the volume of all the MP3s in a album the same amount so that none of the MP3s will clip on playback while keeping any track to track volume differences intact. This is not how most people use it though.