Site icon Leonid Mamchenkov

Converting FLAC to MP3 on Linux

FLAC is Free Lossless Audio Codec. A 35 megabyte WAV file converted to FLAC will occupy about 25 megabytes. This is a good decrease in size, considering the fact that no quality is lost. But some files aren’t all about quality and thus will be much better in mp3 or even ogg. Converting these is really simple. The key to the convertion is to decode flac files back to wav and than to convert them to whatever else is that you want.

Here is an example script to convert a bunch of flac files in the directory to mp3s.

for FILE in *.flac
do
 echo Converting $FILE
 # Decode FLAC back to WAV
 /usr/bin/flac -d "$FILE"
 # Save the filename without extension
 BASE=`basename "$FILE" .flac`
 # Convert resulting WAV to MP3 with variable bitrate preserving good quality
 /usr/bin/lame -h -V 2 "$BASE".wav "$BASE".mp3
done

/usr/bin/flac utility is a part of Fedora Linux distribution. /usr/bin/lame is a part of LAME project. RPMs for Fedora Linux are available from a number of repositories, such as FreshRPMs.

Exit mobile version