Menu
Text Links
Search
Calendar
Solution: Converting flac to mp3
rechosen | 10 April, 2007 14:40
Attention: this post now has an advanced counterpart providing a nice script. See Solution: Converting flac to mp3 advanced (supports drag 'n drop).
Note that you will need flac and lame for this to work. Run the following line in the directory where the flac files are:
[rechosen@localhost ~]$ for file in *.flac; do $(flac -cd "$file" | lame -h - "${file%.flac}.mp3"); done
This will output the mp3 files in the same directory as the flac files. If any of the mp3 files that's being created already exists, it will be overwritten. When the conversion has finished, you can copy the mp3 files to an other location like this:
[rechosen@localhost ~]$ cp *.mp3 /media/sda1
Note that this will copy all mp3 files in the current directory, not just the ones converted from the flac files! Of course, you could replace "/media/sda1" with any other directory. You could also replace "cp" by "mv" to move the mp3 files instead of copying them.
You can also make lame create the mp3 files somewhere else. Take the following line:
And replace YOURLOCATION with the location you want the mp3 files to be created in. For example:[rechosen@localhost ~]$ for file in *.flac; do $(flac -cd "$file" | lame -h - YOURLOCATION/"${file%.flac}.mp3"); done
The above line would output the mp3's in the /tmp directory.[rechosen@localhost ~]$ for file in *.flac; do $(flac -cd "$file" | lame -h - /tmp/"${file%.flac}.mp3"); done
Comments
Full blown script
Greg | 20/12/2009, 17:49
Hi,
thank's for your script and the comments.
Based on them I've created a python script that's walks recursivly and supports more file types (wav, ogg, flac, mp3, mru):
see:
http://code.google.com/p/music-collection-sync/
Greg
Perl Audio Converter 4.0.5
Charles Mitchell | 30/12/2009, 18:14
For Debian based systems (I run Kubuntu Jaunty) I found a nice app that works like a charm.
sudo apt-get install pacpl
Description:
Perl Audio Converter is a tool for converting multiple audio types from one format to another. It supports AAC, AC3, AIFF, APE, AU, AVR, BONK, CAF, CDR, FAP, FLA, FLAC, IRCAM, LA, LPAC, M4A, MAT, MAT4, MAT5, MMF, MP2, MP3, MP4, MPC, MPP, NIST, OFR, OFS, OGG, PAC, PAF, PVF, RA, RAM, RAW, SD2, SF, SHN, SMP, SND, SPX, TTA, VOC, W64, WAV, WMA, and WV. It can also convert audio from the following video extensions: RM, RV, ASF, DivX, MPG, MKV, MPEG, AVI, MOV, OGM, QT, VCD, SVCD, M4V, NSV, NUV, PSP, SMK, VOB, FLV, and WMV. A CD ripping function with CDDB support, batch conversion, tag preservation for most supported formats, independent tag reading/writing, and extensions for Amarok, Dolphin, and Konqueror are also provided.
Flac to mp3
Jon | 23/01/2010, 15:24
Thanks, this was very handy. I didn't have lame installed by default (using fc11) and wasn't aware that conversion was this easy. Cheers.
Add comment
Recently...
- Solution: Converting flac to mp3 advanced (supports drag 'n drop)
- Tutorial: Conditions in bash scripting (if statements)
- Linux Tutorial Blog is no longer frozen!
- Solution: Getting a Gravis GamePad Pro to work on Linux
- Linuxtutorialblog.com is now officially frozen!
- Solution: Preventing damage after a system lockup
- Solution: Creating an mpeg with mencoder that plays on Windows Media Player
- Cropping multiple images the same way (short tutorial)
- Solution: Converting flac to mp3
- Tutorial: Disabling unused daemons to speed up your boot sequence
Trackbacks (0)
another flac2mp3
AlienMind | 29/01/2009, 23:10
for FNAME in *.flac
do
PREFIX=`basename "${FNAME}" .flac`
if [ ! -e fifo ]
then
mkfifo fifo.wav
fi
lame --vbr-new -b 160 fifo.wav "${PREFIX}".mp3 &
mplayer "${FNAME}" \
-vc null -vo null -benchmark \
-ao pcm:fast:file=fifo.wav
rm fifo.wav
done