Convert FLAC to MP3 script (Lazer fast and accurate)

So I like to use micro clip MP3 players and just dump my favorite songs from multiple artists in each genre folder.
71l5gRqkE3L.AC_SL1500

For example Smooth Jazz, Rock, and Country. After I have gone through all the songs I like from all the bands in each genre (Jazz, Rock, Country). I load them all in there separate genre folder and use FLAC2MP3 script to convert them to MP3. I don’t load MP3’s in folders in hierarchy structures like Artist - Album - Song on my device.

There is a AUR script called flac2mp3 for just that purpose but I don’t use it.
I know THIS (FLAC2MP3) script and have used it extensively just recently and it works great.

HOW TO GET IT:

Just open terminal and while in home dir

$touch FLAC2MP3 
$nano FLAC2MP3

and then copy and paste the script below to nano and edit the settings to your preferences concerning encoding parameters. (Have a read through the script)

With the size of MP3 players now usually 16GB it’s fine to leave on the default settings. Of course original flac sounds best but (-V 0 --vbr-new ) is pretty close and is nearly half the size of flac files.

When your finished save and close nano with Ctrl+x choose y and enter.

Give it permission with this command

$chmod +x FLAC2MP3

then mv FLAC2MP3 to your path either /usr/bin or /bin

$sudo mv FLAC2MP3 /usr/bin or /bin

I think this command refreshes the terminal to allow you to use tab completion but I guess it can’t hurt.

$source .bashrc

USING SCRIPT:

So Iike I said I just dump all my favroite song from multiple Smooth Jazz artists into a SMOOTH_JAZZ folder then just use the command to encode all the flac files.

$FLAC2MP3 /home/user/Music/SMOOTH_JAZZ/*.flac

Then just delete all the flac files with

$rm /home/user/Music/SMOOTH_JAZZ/*.flac

Thats it enjoy!

Got a better way of doing this.
Lets hear about it!

#!/bin/bash
#########################################################
# Flac to Mp3 Conversion Software #
# Script Created by Nick Sklavenitis #
# Date: September 18 2007 #
#########################################################

###########################################################################
#The script listed below takes arguments in the following fashion. #
#	either you can specify a single file name to convert or you  #
#   can specify a wildcard as example 2 shows. #
#Example 1: Flac2Mp3 01-The Black Parade.flac #
#Example 2: Flac2Mp3 *.flac #

##  To use this script just copy and paste the section below and to a filename Flac2Mp3 and the chmod+x Flac2Mp3


# modify the lame options to your preference example change -b 320 to -b 128 or -b 192 or -b 256
#
#                ******* VBR OPTIONS *****
# Switch				Preset		Target Kbit/s 	 Bitrate range kbit/s
# 
#
# -V 0 --vbr-new					245				220...260
# -V 0			preset extreme	245				220...260
# -V 1 --vbr-new					225				200...250
# -V 1							225				200...250
# -V 2 --vbr-new 	presetstandard 	190				170...210
# -V 2							190				170...210
# -V 3 --vbr-new					175				155...195
# -V 3							175				155...195
# -V 4 --vbr-new 	fastmedium		165				145...185
# -V 4			preset medium 	165				145...185
# -V 5 --vbr-new					130				110...150
# -V 5							130				110...150
# -V 6 --vbr-new					115				95...135
# -V 6							115				95...135
# -V 7 --vbr-new					100				80...120
# -V 7							100				80...120
# -V 8 --vbr-new					85				65...105
# -V 8							85				65...105
# -V 9 --vbr-new					65				45...85
# -V 9							65				45...85
#
#
#
#                 ***** CBR OPTIONS *******
# -b 32, 40, 48, 64, 80, 96, 112, 128, 160, 192, 224, 256, or 320				320	CBR
# ##########################################################################################
#
##      My Preferences
#-----------------------------
# Vocal:	-V 9 --vbr-new
# Music:	-V 0 --vbr-new
#-----------------------------
#
#lame_opts=" -V 8 --vbr-new"    ##Vocal
lame_opts=" -V 0 --vbr-new"   ##Music
#
# Creates the loop that allows more than 1 file to be specified, Can use single file name or example *.flac
for x in "${@}"
do
FLAC=${x}
MP3=`basename "${FLAC%.flac}.mp3"`
[ -r "$FLAC" ] || { echo can not read file \"$FLAC\" >&1 ; exit 1 ; } ;

#This section pulls the Tag info from flac and stores it as a variable.

TITLE="`metaflac --show-tag=TITLE "$FLAC" | awk -F = '{ printf($2) }'`"
ALBUM="`metaflac --show-tag=ALBUM "$FLAC" | awk -F = '{ printf($2) }'`"
ARTIST="`metaflac --show-tag=ARTIST "$FLAC" | awk -F = '{ printf($2) }'`"
TRACKNUMBER="`metaflac --show-tag=TRACKNUMBER "$FLAC" | awk -F = '{ printf($2) }'`"
GENRE="`metaflac --show-tag=GENRE "$FLAC" | awk -F = '{ printf($2) }'`"
COMMENT="`metaflac --show-tag=COMMENT "$FLAC" | awk -F = '{ printf($2) }'`"
DATE="`metaflac --show-tag=DATE "$FLAC" | awk -F = '{ printf($2) }'`"

#This section handles the conversion of the Flac file to MP3

flac -dc "$FLAC" | lame${lame_opts} \
--tt "$TITLE" \
--tn "$TRACKNUMBER" \
--tg "$GENRE" \
--ty "$DATE" \
--ta "$ARTIST" \
--tl "$ALBUM" \
--add-id3v2 \
- "$MP3"

done
5 Likes