Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
10th August 2013, 08:05 | #1 | Link |
x264 fan
Join Date: Feb 2011
Location: In the trap
Posts: 458
|
Properly transcode FLAC to WAVE then encode with LAME
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 : Code:
flac -d %1 lame -b 320 -h --add-id3v2 %1 "%~dpn1.mp3" pause I also tried the simple comand line applied to the WAVE : Code:
lame -b 320 -h --add-id3v2 %1 "%~dpn1.mp3" pause Last edited by sirt; 10th August 2013 at 08:27. |
10th August 2013, 09:30 | #2 | Link |
brontosaurusrex
Join Date: Oct 2001
Posts: 2,392
|
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
__________________
certain other member Last edited by smok3; 10th August 2013 at 09:33. |
10th August 2013, 09:46 | #4 | Link |
brontosaurusrex
Join Date: Oct 2001
Posts: 2,392
|
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)
__________________
certain other member |
10th August 2013, 10:14 | #5 | Link |
x264 fan
Join Date: Feb 2011
Location: In the trap
Posts: 458
|
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 ? |
10th August 2013, 11:25 | #6 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
>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 BTW, using "%~dpnx1" in place of %1 enforces quote wrapping instead of trusting the OS to do it. |
10th August 2013, 12:05 | #7 | Link |
x264 fan
Join Date: Feb 2011
Location: In the trap
Posts: 458
|
Thanks raffriff42 for your answer. Something like that :
Code:
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 Code:
PUSHD %~dp0 if [%1]==[] goto :eof :loop lame -b 320 -q0 --add-id3v2 %1 "%~dpn1.mp3" shift if not [%1]==[] goto loop pause 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 ? |
10th August 2013, 12:09 | #8 | Link |
brontosaurusrex
Join Date: Oct 2001
Posts: 2,392
|
an example going from flac to lossy flac using "tag" to copy/paste tags;
Code:
@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 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)
__________________
certain other member |
10th August 2013, 12:37 | #9 | Link | |
x264 fan
Join Date: Feb 2011
Location: In the trap
Posts: 458
|
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 : Quote:
|
|
10th August 2013, 12:41 | #10 | Link |
brontosaurusrex
Join Date: Oct 2001
Posts: 2,392
|
maybe (not tested)
Code:
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
__________________
certain other member Last edited by smok3; 10th August 2013 at 12:44. |
10th August 2013, 12:56 | #11 | Link |
x264 fan
Join Date: Feb 2011
Location: In the trap
Posts: 458
|
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 ? Last edited by sirt; 10th August 2013 at 12:58. |
10th August 2013, 13:06 | #13 | Link |
x264 fan
Join Date: Feb 2011
Location: In the trap
Posts: 458
|
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 () 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. |
10th August 2013, 14:02 | #14 | Link |
Registered User
Join Date: Apr 2002
Posts: 74
|
Foobar2000
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.
__________________
Intel Core i5-4250U, 8 GB Ram, Intel HD 5000 |
10th August 2013, 14:49 | #15 | Link |
Registered User
Join Date: Aug 2009
Posts: 463
|
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. |
10th August 2013, 15:58 | #16 | Link |
x264 fan
Join Date: Feb 2011
Location: In the trap
Posts: 458
|
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. |
10th August 2013, 18:02 | #17 | Link |
Registered User
Join Date: Aug 2009
Posts: 463
|
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 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. Last edited by detmek; 10th August 2013 at 18:31. |
11th August 2013, 08:43 | #18 | Link |
x264 fan
Join Date: Feb 2011
Location: In the trap
Posts: 458
|
Ok thanks detmek.
After a few tests I found something like this : Code:
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 |
11th August 2013, 10:20 | #20 | Link | |
x264 fan
Join Date: Feb 2011
Location: In the trap
Posts: 458
|
Okay. Finally this code is working :
Quote:
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|