# Converting flac to mp3



## balanga (Sep 3, 2018)

Any recommendations for converting flac to mp3 files?

I did come acrorss this thread on the FreeBSD mailing list but I can't see how to convert flac to wav which is supposed to be the first step.


----------



## shkhln (Sep 3, 2018)

balanga said:


> I can't see how to convert flac to wav



Is that a serious question? What do you think the output format of the FLAC decoder is?


----------



## scottro (Sep 3, 2018)

Wouldn't ffmpeg work?  https://wiki.archlinux.org/index.php/Convert_FLAC_to_MP3 

Just google for something like flac to mp3 Linux command line, as there will be little written for FreeBSD, the tools are the same, and putting Linux as a search term will save you from Windows/Mac solutions.


----------



## ShelLuser (Sep 3, 2018)

Sometimes it really is an issue of just looking a little more careful. How about audio/flac123? From its description:


```
Flac123 is a  console-line Free Lossless Audio Codec (flac) audio player.
It implements mpg123's 'Remote Control' interface and has the ability to
output to a wav file or stdout.

WWW: http://flac-tools.sf.net
```
That's the first thing I'd try.


----------



## balanga (Sep 3, 2018)

shkhln said:


> Is that a serious question? What do you think the output format of the FLAC decoder is?



Thank you for that 'helpful' reply. I have never used flac and have no idea what the output format is.


----------



## balanga (Sep 3, 2018)

ShelLuser said:


> Sometimes it really is an issue of just looking a little more careful. How about audio/flac123? From its description:



I was not aware of this version ....I installed audio/flac


----------



## Maccraft123 (Nov 26, 2018)

audio/ffmpeg


----------



## fernandel (Dec 9, 2018)

balanga said:


> Any recommendations for converting flac to mp3 files?
> 
> I did come acrorss this thread on the FreeBSD mailing list but I can't see how to convert flac to wav which is supposed to be the first step.


http://srobb.net/dvds.html
Above page help me a lot.


----------



## scottro (Dec 10, 2018)

As that page's author, though, it doesn't deal with flac to mp3. I would just try ffmpeg.
`ffmpeg -i myfile.flac myfile.mp3` 

fernandel I'm glad you've found that page helpful. I  have to do some editing on it one of these days, to try to make it less meandering, but don't know when I'll have time.


----------



## cbj (Dec 10, 2018)

As scottro suggested, ffmpeg is probably the tool you want, because it usually preserves the metadata from the flac file and transfers it to the mp3-file. Just be mindful of the bit-rate setting of ffmpeg, that I think is less than optimal by default.

But for a more simple solution, you can pipe the decoded audio directly to lame:
`flac -c -d "$infile" | lame -b 192 -h --replaygain-accurate - "$outfile"`

Transferring the metadata is an exercise using metaflac before encoding to mp3, but easy to script.


----------



## kpa (Dec 10, 2018)

The basic idea of any conversion with these compressed audio formats: source format -> uncompressed PCM (wav) -> destination format. The uncompressed PCM (wav) is the only universal format that every tool understands so the first step is always uncompressing the source file to PCM and whatever is done then is done on the uncompressed data. You don't have to store the uncompressed data into a temporary file, the example above uses piping of the uncompressed PCM into a compressor program (lame).

Do note that uncompressing a flac file doesn't lose any quality because flac is a lossless codec meaning that uncompressing a flac file will always give you back the original wav file bit by bit accurately. However as soon as you compress the uncompressed PCM output with an MP3 compressor there will be a significant loss of quality that can't be ever recovered because MP3 is by design a lossy codec.


----------

