Essentially, the .flac files within a directory will be decompressed to .wav and then the resulting .wav files will be encoded to .mp3 using the latest LAME switches for encodings (''-V 0 --vbr-new''). The ID3 tags of the original .flac files will be passed to the resulting .mp3 files.

+

Here are a few scripts and tools that facilitate converting FLAC to MP3.

−

The original .flac files will not be harmed and the resulting .mp3s will be in the same directory.

+

For more information on LAME switches/settings such as V0, visit the [http://wiki.hydrogenaudio.org/index.php?title=LAME Hydrogenaudio LAME Wiki]. V0 is roughly equivalent to {{ic|--preset extreme}} which results in a variable bitrate usually between 220-260. The audio of a V0 is transparent, meaning one cannot tell the difference between the lossy file and the original source (compact disc/lossless), but yet the file size is a quite reasonable.

−

For more information on LAME switches/settings such as V0, visit [http://wiki.hydrogenaudio.org/index.php?title=LAME Hydrogenaudio LAME Wiki]. V0 is roughly equivalent to ''--preset extreme'' which results in a variable bitrate usually between 220-260. The audio of a V0 is transparent, meaning one cannot tell the difference between the lossy file and the original source (compact disc/lossless), but yet the file size is a quite reasonable.

+

== Scripts ==

−

==Installation==

+

In these two examples, the FLAC files in a directory are read, decompressed to WAV, and streamed into the MP3 encoder, LAME. Both scripts pass the ID3 tags from the FLAC files to the resulting MP3 files, and encode to MP3 V0.

−

First you need to install the following packages: flac, lame, and id3

+

The original {{ic|.flac}} files are not modified and the resulting {{ic|.mp3}}s will be in the same directory. All files with extensions not matching {{ic|*.flac}} in the working directory ({{ic|.nfo}}, images, {{ic|.sfv}}, etc.) are ignored.

−

<pre>

+

=== With FFmpeg ===

−

pacman -S flac lame id3

−

</pre>

−

Once those are installed, copy the following script and make it executable:

+

Chances are, your system already has {{Pkg|ffmpeg}} installed, which brings in the {{Pkg|flac}} and {{Pkg|lame}} packages. FFmpeg has all the encoding and decoding facilities built in to do the job.

−

<pre>

+

{{bc|

−

for a in *.flac

+

#!/bin/bash

−

do

+

for a in *.flac; do

−

OUTF=`echo "$a" | sed s/\.flac/.mp3/g`

+

< /dev/null ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}"

+

done

+

}}

+

+

=== Without FFmpeg ===

+

+

If for some reason you have something against FFmpeg, you still need to have {{Pkg|flac}} and {{Pkg|lame}} installed. Here, the tagging process is more explicit, using the metadata utility that comes with {{Pkg|flac}}, and passing the information to {{Pkg|lame}}

For ease of use, add the script to your {{ic|PATH}}. Open up a terminal, {{ic|cd}} to the directory of FLAC files that you wish to convert, and invoke {{ic|flac2mp3}} (or whatever you named the script). You'll see the verbose decoding/encoding process in the terminal which may take a few moments. Done! At this point, it's trivial to {{ic|mv *.mp3}} all your new MP3s wherever you wish.

−

Save the script as flac2mp3 in your home directory. As root copy the script to /usr/local/bin

+

A useful extension of the above scripts is to let it recurse into all subdirectories of the working directory. Replace the first line ({{ic|for .... do}}) with

−

<pre>

+

$ find -type f -name "*.flac" -print0 | while read -d $'\0' a; do

−

cp flac2mp3 /usr/local/bin

−

</pre>

−

===Usage===

+

== Packages ==

−

Once that is done, you are ready to use the script. Open up a terminal and cd to the directory of .flac files that you wish to convert and run ''flac2mp3''

+

* {{AUR|whatmp3}} - A small Python script that accepts a list of directories containing FLAC files as arguments and converts them to MP3 with the specified options.

+

* {{AUR|flac2all}} - Audio converter of FLAC to either Ogg Vorbis or MP3 retaining all tags and metadata.

+

* {{AUR|flac2mp3-bash}} - Bash script to convert Flac to Mp3 easily.

−

Done. The newly-encoded .mp3s will be V0.

+

== See also ==

−

More information on flac: [http://wiki.hydrogenaudio.org/index.php?title=Flac FLAC]

Revision as of 16:13, 22 December 2013

Here are a few scripts and tools that facilitate converting FLAC to MP3.

For more information on LAME switches/settings such as V0, visit the Hydrogenaudio LAME Wiki. V0 is roughly equivalent to --preset extreme which results in a variable bitrate usually between 220-260. The audio of a V0 is transparent, meaning one cannot tell the difference between the lossy file and the original source (compact disc/lossless), but yet the file size is a quite reasonable.

Contents

Scripts

In these two examples, the FLAC files in a directory are read, decompressed to WAV, and streamed into the MP3 encoder, LAME. Both scripts pass the ID3 tags from the FLAC files to the resulting MP3 files, and encode to MP3 V0.

The original .flac files are not modified and the resulting .mp3s will be in the same directory. All files with extensions not matching *.flac in the working directory (.nfo, images, .sfv, etc.) are ignored.

With FFmpeg

Chances are, your system already has ffmpeg installed, which brings in the flac and lame packages. FFmpeg has all the encoding and decoding facilities built in to do the job.

Without FFmpeg

If for some reason you have something against FFmpeg, you still need to have flac and lame installed. Here, the tagging process is more explicit, using the metadata utility that comes with flac, and passing the information to lame

Usage

For ease of use, add the script to your PATH. Open up a terminal, cd to the directory of FLAC files that you wish to convert, and invoke flac2mp3 (or whatever you named the script). You'll see the verbose decoding/encoding process in the terminal which may take a few moments. Done! At this point, it's trivial to mv *.mp3 all your new MP3s wherever you wish.

A useful extension of the above scripts is to let it recurse into all subdirectories of the working directory. Replace the first line (for .... do) with

$ find -type f -name "*.flac" -print0 | while read -d $'\0' a; do

Packages

whatmp3AUR - A small Python script that accepts a list of directories containing FLAC files as arguments and converts them to MP3 with the specified options.

flac2allAUR - Audio converter of FLAC to either Ogg Vorbis or MP3 retaining all tags and metadata.