ubuntu: sudo apt-get install lame ffmpeg libavcodec-extra-53Then cd to the directory with flac files and use find (or change ffmpeg for avconv):
find -name "*.flac" -exec ffmpeg -i {} -acodec libmp3lame -ab 128k {}.mp3 \;Done! You now have the exact same filenames with .mp3 encoding (also adds .mp3 at the end but keeps the .flac as well).
Enjoy.
Notes:
- Obviously, change *.flac to whatever extension your input files are in
- You can also change the output codec by replacing libmp3lame to whatever codec you'd like
- Heck, just use man find ;)
- If you don't like the .flac.mp3 thing, you can rename easily (I like it since it tells me it came from a lossless source, which is likely sitting somewhere on my hard drive):
rename 's/\.flac//' *.mp3
Alternative without ffmpeg
If you don't have ffmpeg and prefer using lame and flac directly, first install the codecs if you dont have them already.Ubuntu: sudo apt-get install flac lame
Arch: sudo pacman -Syu flac lameThen, convert away!
find . -name '*.flac' -exec sh -c 'flac -cd "{}" | lame - "{}".mp3' \;You can also do this in the current folder only with a for-loop:
for f in *.flac; do flac -cd "${f}" | lame - "${f}.mp3"; done;Set the target bitrate depending on the quality/size you prefer with the -b option of lame:
lame -b 320 - "${f}.mp3"
NB: don't forget the 'k' on the bitrate, eg `-ab 128k`
ReplyDeleteI'm not sure about your version of ffmpeg but on my system the 'k' isn't necessary.
DeleteI still updated the post to add it. They both work.
DeleteVery elegant, thanks for a neat solution.
ReplyDeleteYou may use
ReplyDeletels *.flac|xargs -IQ ffmpeg -i Q -ab 320k Q.mp3
:P
Just a little shorter, nothing different to OP.
Actually not quite the same. The find binary will also look in subfolders while ls won't without the -R. If you add the -R to your command it becomes essentially the same yes.
DeleteThis is turbo sweet man, thanks.
ReplyDeletels *.flac|sed -e s/.flac//|xargs -IQ ffmpeg -i Q.flac -ab 320k Q.mp3
ReplyDeleteThat's even cleaner :)
How would you use this code to scan all of home/Music/.....folders and sub folders ?
ReplyDeletels *.flac|sed -e s/.flac//|xargs -IQ ffmpeg -i Q.flac -ab 320k Q.mp3
This article was written by a real thinking writer without a doubt. I agree many of the with the solid points made by the writer. I’ll be back day in and day for further new updates. sbunoah ewe getsemane live mp3 download
ReplyDeletefakaza thina zungu 2020 album
ReplyDeletefakaza 2020
The trunk has a higher exposure to heat and humidity that’s why it is not advisable to place it there. sa mp3 download
ReplyDeleteAmazing script. I easily understood everything. Very simply written, anyone can understand. Now I can convert FLAC to mp3 and convert mp3 to wav. Thanks for sharing the beautiful post.
ReplyDeleteAmapiano 2020
ReplyDelete