Convert FLAC to MP3: Difference between revisions

From BakaBT Wiki
Jump to navigation Jump to search
(Added section)
 
(6 intermediate revisions by 3 users not shown)
Line 15: Line 15:


You must also install the LAME MP3 encoder software onto the computer, which is not so straight forward but still easy. If it comes in the form of a .exe file, just install it like any other application. If it is in .zip form, extract it to a folder.
You must also install the LAME MP3 encoder software onto the computer, which is not so straight forward but still easy. If it comes in the form of a .exe file, just install it like any other application. If it is in .zip form, extract it to a folder.
Now in foobar, go to "File --> Preferences", then find "Converter" under the Tools menu.


====Step 02 - Adding files====
====Step 02 - Adding files====
Line 34: Line 32:
=====Bitrate Settings=====
=====Bitrate Settings=====


This is obviously easy to understand, simply move the slidebar to the left for lower quality but smaller files and to the right for higher quality and larger files. The default is 190kbps. This is a variable bitrate option which means it will be of higher quality (generally) than CBR MP3 audio '''[''citation needed'']'''. Make your bitrate selection and click '''OK'''.
Move the slidebar to the left for lower quality but smaller files, and to the right for higher quality and larger files. The default setting is V2. This is a variable bitrate option which means the bitrate does not stay constant, so the indicated bitrate is only an estimate. Recommended setting for upload to BakaBT is "Best quality, V0". Make your bitrate selection and click '''OK'''.


*Note: As MP3 is a lossy audio format, there will be audio information discarded in the '''FLAC --> MP3''' conversion. This discarded information will '''not''' be automagically re-added back to the file if you convert it back from MP3 to FLAC. So you should never convert an MP3 file to a FLAC file just to make it ''seem'' like a higher-quality file.
*Note: As MP3 is a lossy audio format, there will be audio information discarded in the '''FLAC --> MP3''' conversion. This discarded information will '''not''' be automagically re-added back to the file if you convert it back from MP3 to FLAC. So you should never convert an MP3 file to a FLAC file just to make it ''seem'' like a higher-quality file.
Line 52: Line 50:




===Requirements===
====Step 1 - Installation====
 
First, we need to get [http://sbooth.org/Max/ Max]. Scroll down to the Download section, and either download the stable (first link, old but works) or the unstable (third link, has some improvements not in the stable version, but may not work.) version. If you're not sure, get the stable. When it's downloaded, double click it if necessary to extract it, open the resulting folder and drag Max.app to your applications directory.
 
 
====Step 2 - Configuring Output====
 
Now, open Max. It does not have a window by default, so don't worry if nothing appears. (Check your menu bar/dock.) With Max in the foreground, hit Cmd+, (that's a comma) to bring up preferences. Click Formats. In the bottom list there, click MP3. (Or another format, if you prefer.) Click +. The default settings will work for most people.
 
NOTE: If you care about the quality of your audio, you should select Custom in Encoder Quality, set the Encoder Target to Bitrate, move the Bitrate slider to the hard right, and make sure Restrict encoder to constant bitrate is unchecked. (Constant bitrates are silly and wasteful.)
 
Click OK. Then, click the checkbox beside the newly created MP3 row in the table. (If you create another format like you just did with MP3 and select it, your FLACs will be converted into one of every format you configured.) You may wish to configure stuff in Output, but the defaults spit the MP3's out in your music folder, which is a sane default. Close the preferences window.
 
====Step 3 - Converting Files====
Click File, then Convert Files. A file selector comes up, use it to find all the FLACs you wish to convert. Click open. If you want, select some files and modify metadata or album art using the toolbar buttons. Once you're satisfied, click convert. Make a cup of tea. Note: The tea is optional.
 
In the future, to convert more files in the same way, simple open Max, File > Convert Files, Select files, Convert. Done.
 
 
==How to convert using Linux==
 
====Conversion using FFmpeg command line====
 
There are quite a few GUI applications that allow you to convert FLACs into desired MP3, but if you use Linux you probably will find your way around them, so this will focus on using command line tools to do conversion.
 
One way to do that is by using FFmpeg, which is used by majority of GUI frontends anyway (But FFmpeg itself uses lib3lame to do actual conversion with desired parameters). Example conversion of a FLAC file to MP3 below.
 
Conversion to MP3 320kbps:
ffmpeg -i inputfile.flac -codec:a libmp3lame -b:a 320k outputfile.mp3
 
Conversion to MP3 V0:
ffmpeg -i inputfile.flac -codec:a libmp3lame -qscale:a 0 outputfile.mp3


[http://www.macupdate.com/info.php/id/14246 xACT] ---> X Audio Compression Toolkit. <br>[http://www.apple.com/itunes/ iTunes] ---> A popular audio player with a wide range of support for playing audio files<br>            and converting them to other formats.
Of course, those can be chained into bigger bash scripts in order to mass convert a folder. Here is example line to execute inside folder with FLAC file, which will create a new directory alongside FLAC directory with changed name (for this example i created a sed-like name replacement, you will have to adjust it accordingly to your case) which will be filled with converted FLAC files:


There are two steps in converting your FLAC files to MP3. The first is to decode the FLAC’s into WAV files. After that’s done, you’ll encode the WAV files into MP3’s.
newdir=../"$(basename ${PWD/FLAC*]/MP3 V0]})"; mkdir $newdir; for i in *.flac; ffmpeg -i $i -codec:a libmp3lame -qscale:a 0 $newdir/"${i/flac/mp3}"


====Step 01 - Decoding with xACT====
Aftermath of operation like this leaves us with this result:
➜  test tree
.
├── Pizzicato Five - Bossa Nova 2001 (1993) [FLAC (level 8)]
│  ├── 01 Rock'n'roll.flac
│  ├── 02 Sweet Soul Revue.flac
│  ├── 03 Magic Carpet Ride.flac
│  ├── 04 Groovy Is My Name.flac
│  ├── 05 Sophisticated Catchy.flac
│  ├── 06 Peace Music.flac
│  ├── 07 Strawberry Sleighride.flac
│  ├── 08 Sleeper.flac
│  ├── 09 Sweet Thursday.flac
│  ├── 10 Rain Song.flac
│  ├── 11 Go Go Dancer.flac
│  ├── 12 Eclipse.flac
│  ├── 13 Saga.flac
│  ├── 14 Hallelujah Hare Krishna.flac
│  ├── 15 Playback 2001.flac
│  ├── 16 Cleopatra 2001.flac
│  ├── Bossa Nova 2001.cue                                                                                                                                                                                       
│  ├── bossa nova 2001.jpg
│  └── Bossa Nova 2001.log                                                                                                                                                                                       
└── Pizzicato Five - Bossa Nova 2001 (1993) [MP3 V0]
    ├── 01 Rock'n'roll.mp3
    ├── 02 Sweet Soul Revue.mp3
    ├── 03 Magic Carpet Ride.mp3
    ├── 04 Groovy Is My Name.mp3
    ├── 05 Sophisticated Catchy.mp3
    ├── 06 Peace Music.mp3
    ├── 07 Strawberry Sleighride.mp3
    ├── 08 Sleeper.mp3
    ├── 09 Sweet Thursday.mp3
    ├── 10 Rain Song.mp3
    ├── 11 Go Go Dancer.mp3
    ├── 12 Eclipse.mp3
    ├── 13 Saga.mp3
    ├── 14 Hallelujah Hare Krishna.mp3
    ├── 15 Playback 2001.mp3
    └── 16 Cleopatra 2001.mp3
                                                                                                                                                                                                                   
2 directories, 35 files                                                                                                                                                                                           
➜  test


#Launch '''xACT''' and select the '''decode''' tab
#Click the '''add''' button
#Navigate to the '''.flac''' files you want to decode, select them all, and then click '''Add files'''
#Now you’ll need to select the output - I use and suggest '''.wav'''. Click '''Decode''' when you’re ready
#You’ll be prompted to choose a location to save the output files. Select the same folder where the .flac files are located and then click '''Choose'''
#The decoding process only takes a few minutes. When it’s completed you’ll be back at the '''decode''' screen but there won’t be any files in the decode list. Feel free to close xACT now.


====Step 02 - Encoding with iTunes====
Keep in mind this is a ZSH script! Adjustments will be necessary if you are using bash. Also, as mentioned earlier, directory name was changed. This is because of sed-like regular expression:
${PWD/FLAC*]/MP3 V0]}


#Open up '''iTunes''' and select iTunes from the top menu, and then '''Preferences...''' from the drop-down list
Basically, here it replaced a bracet with FLAC string found and everything else to the right until a closing bracket is found. Adjust it accordingly to directory name, or you will end up in MP3 files in same directory (If no matches will be found, regex won't replace anything, therefore $newdir = $basename).
#Select the '''Advanced''' tab from the top menu, and then '''Importing''' from the lower menu
#From the '''Import Using''': list, select '''MP3 Encoder'''
#From the '''Setting''': list, select your quality preference. I opt for '''Higher Quality''' (192 kbps)
#It also annoys me to have songs playing while they’re importing, so I disable that feature by removing the check from the box labeled '''Play songs while importing'''. This is entirely optional. Click '''OK''' to return to iTunes.
#Now select '''File''' from the top menu, and then '''Add to Library...''' from the drop-down list
#Navigate to the folder where you saved all of the .wav files from xACT, select that folder, and then click '''Choose'''
#iTunes will now import all of the .wav’s into iTunes. Find all of the newly added files (usually at the bottom of your iTunes list, but it depends on how you sort your music) and select them all. Once they’re all highlighted, right-click (ctrl-click for you one-button folks) on any of the selected songs and choose '''Convert Selection to MP3''' from the pop-up menu.
#While iTunes is encoding your MP3s, a status indicator will appear in the left window (see image below). Depending on how “fast” your mac is (processor speed, memory etc) and how many files you’re encoding, this step can take anywhere from a few minutes to an hour.
#Once all of the files have been encoded, iTunes will probably beep to get your attention. Before you start listening to your music, now’s a good time to get rid of the .wav files, since they’re no longer needed.

Latest revision as of 13:19, 4 December 2018

This article shows how to turn Free Lossless Audio Codec (FLAC) files into MP3 files. The benefits to this are obvious, the files are smaller and have better support among software and hardware players (also use less power when playing on supporting MP3 players). The drawbacks also exist too; MP3 is a lossy format. FLAC is lossless, which means it loses no audio information from it's original source, it is just compressed and can be returned to its original state at any time.

How to convert using Windows

Requirements

LAME MP3 Encoder (alternate link) ---> You need this software for the conversion to MP3. 

Foobar 2000 ---> A popular audio player with a wide range of support for playing audio files
and converting them to other formats.

Converting from FLAC to MP3 should not take too long and won't take up too much hard drive space.

Step 01 - Installation

Run the Foobar 2000 installation. The steps involved are self explanatory and don't need to be explained in detail here. The installation should be very quick and you will have the option to run Foobar 2000 for the first time at the end of the process.

You must also install the LAME MP3 encoder software onto the computer, which is not so straight forward but still easy. If it comes in the form of a .exe file, just install it like any other application. If it is in .zip form, extract it to a folder.

Step 02 - Adding files

Open FLAC files in Foobar 2000, either use the Open Files option in the file menu or simply drag and drop FLAC music files onto the program window. The files will be displayed in the playlist panel. You can play the file now if you wish as FLAC is natively supported by Foobar 2000.

Step 03 - Converting

Select a FLAC file (if you want to select many then just hold down the CTRL or SHIFT key and click them) and right click on it. Move the mouse down to the Convert sub-menu as shown in the picture above. Now click Convert to... and Foobar 2000's conversion options will pop-up on the screen.

Converter Setup

The Converter Setup program allows you to select different audio formats to convert source audio files to. Foobar 2000 is a very powerful application on its own, but for some of the conversions it will need outside software (might even need a plug-in simply to support the source audio, APE for instance). From the Encoding Preset drop-down menu, select MP3 (LAME).

Now click the button labelled "..." beside the Output format drop-down box. This will allow you to select a bitrate and determine the output quality of the resulting MP3 file(s).

Bitrate Settings

Move the slidebar to the left for lower quality but smaller files, and to the right for higher quality and larger files. The default setting is V2. This is a variable bitrate option which means the bitrate does not stay constant, so the indicated bitrate is only an estimate. Recommended setting for upload to BakaBT is "Best quality, V0". Make your bitrate selection and click OK.

  • Note: As MP3 is a lossy audio format, there will be audio information discarded in the FLAC --> MP3 conversion. This discarded information will not be automagically re-added back to the file if you convert it back from MP3 to FLAC. So you should never convert an MP3 file to a FLAC file just to make it seem like a higher-quality file.

You will now be back at the Converter Setup. Click OK and Foobar 2000 should now attempt to locate the LAME.EXE file.

Conversion Process

In most cases, this conversion will happen very quickly. If you selected multiple files then it will go through them one by one. Please remember to always check the output MP3 files before you delete the FLAC files.

Hopefully you will have successfully converted FLAC audio to MP3 audio for your personal use. If you need to repeat this process again, you won't need to point out LAME.EXE anymore to Foobar 2000, just right click and select Convert to.


Without locating the lame.exe file, Foobar 2000 won't be able to convert the FLAC audio to MP3. Navigate to the folder where the LAME encoder files were extracted/installed to, select lame.exe and click Open.

How to convert using OS X

Step 1 - Installation

First, we need to get Max. Scroll down to the Download section, and either download the stable (first link, old but works) or the unstable (third link, has some improvements not in the stable version, but may not work.) version. If you're not sure, get the stable. When it's downloaded, double click it if necessary to extract it, open the resulting folder and drag Max.app to your applications directory.


Step 2 - Configuring Output

Now, open Max. It does not have a window by default, so don't worry if nothing appears. (Check your menu bar/dock.) With Max in the foreground, hit Cmd+, (that's a comma) to bring up preferences. Click Formats. In the bottom list there, click MP3. (Or another format, if you prefer.) Click +. The default settings will work for most people.

NOTE: If you care about the quality of your audio, you should select Custom in Encoder Quality, set the Encoder Target to Bitrate, move the Bitrate slider to the hard right, and make sure Restrict encoder to constant bitrate is unchecked. (Constant bitrates are silly and wasteful.)

Click OK. Then, click the checkbox beside the newly created MP3 row in the table. (If you create another format like you just did with MP3 and select it, your FLACs will be converted into one of every format you configured.) You may wish to configure stuff in Output, but the defaults spit the MP3's out in your music folder, which is a sane default. Close the preferences window.

Step 3 - Converting Files

Click File, then Convert Files. A file selector comes up, use it to find all the FLACs you wish to convert. Click open. If you want, select some files and modify metadata or album art using the toolbar buttons. Once you're satisfied, click convert. Make a cup of tea. Note: The tea is optional.

In the future, to convert more files in the same way, simple open Max, File > Convert Files, Select files, Convert. Done.


How to convert using Linux

Conversion using FFmpeg command line

There are quite a few GUI applications that allow you to convert FLACs into desired MP3, but if you use Linux you probably will find your way around them, so this will focus on using command line tools to do conversion.

One way to do that is by using FFmpeg, which is used by majority of GUI frontends anyway (But FFmpeg itself uses lib3lame to do actual conversion with desired parameters). Example conversion of a FLAC file to MP3 below.

Conversion to MP3 320kbps:

ffmpeg -i inputfile.flac -codec:a libmp3lame -b:a 320k outputfile.mp3

Conversion to MP3 V0:

ffmpeg -i inputfile.flac -codec:a libmp3lame -qscale:a 0 outputfile.mp3

Of course, those can be chained into bigger bash scripts in order to mass convert a folder. Here is example line to execute inside folder with FLAC file, which will create a new directory alongside FLAC directory with changed name (for this example i created a sed-like name replacement, you will have to adjust it accordingly to your case) which will be filled with converted FLAC files:

newdir=../"$(basename ${PWD/FLAC*]/MP3 V0]})"; mkdir $newdir; for i in *.flac; ffmpeg -i $i -codec:a libmp3lame -qscale:a 0 $newdir/"${i/flac/mp3}"

Aftermath of operation like this leaves us with this result:

➜  test tree
.
├── Pizzicato Five - Bossa Nova 2001 (1993) [FLAC (level 8)]
│   ├── 01 Rock'n'roll.flac
│   ├── 02 Sweet Soul Revue.flac
│   ├── 03 Magic Carpet Ride.flac
│   ├── 04 Groovy Is My Name.flac
│   ├── 05 Sophisticated Catchy.flac
│   ├── 06 Peace Music.flac
│   ├── 07 Strawberry Sleighride.flac
│   ├── 08 Sleeper.flac
│   ├── 09 Sweet Thursday.flac
│   ├── 10 Rain Song.flac
│   ├── 11 Go Go Dancer.flac
│   ├── 12 Eclipse.flac
│   ├── 13 Saga.flac
│   ├── 14 Hallelujah Hare Krishna.flac
│   ├── 15 Playback 2001.flac
│   ├── 16 Cleopatra 2001.flac
│   ├── Bossa Nova 2001.cue                                                                                                                                                                                        
│   ├── bossa nova 2001.jpg
│   └── Bossa Nova 2001.log                                                                                                                                                                                        
└── Pizzicato Five - Bossa Nova 2001 (1993) [MP3 V0]
    ├── 01 Rock'n'roll.mp3
    ├── 02 Sweet Soul Revue.mp3
    ├── 03 Magic Carpet Ride.mp3
    ├── 04 Groovy Is My Name.mp3
    ├── 05 Sophisticated Catchy.mp3
    ├── 06 Peace Music.mp3
    ├── 07 Strawberry Sleighride.mp3
    ├── 08 Sleeper.mp3
    ├── 09 Sweet Thursday.mp3
    ├── 10 Rain Song.mp3
    ├── 11 Go Go Dancer.mp3
    ├── 12 Eclipse.mp3
    ├── 13 Saga.mp3
    ├── 14 Hallelujah Hare Krishna.mp3
    ├── 15 Playback 2001.mp3
    └── 16 Cleopatra 2001.mp3
                                                                                                                                                                                                                   
2 directories, 35 files                                                                                                                                                                                            
➜  test


Keep in mind this is a ZSH script! Adjustments will be necessary if you are using bash. Also, as mentioned earlier, directory name was changed. This is because of sed-like regular expression:

${PWD/FLAC*]/MP3 V0]}

Basically, here it replaced a bracet with FLAC string found and everything else to the right until a closing bracket is found. Adjust it accordingly to directory name, or you will end up in MP3 files in same directory (If no matches will be found, regex won't replace anything, therefore $newdir = $basename).