Home Download Debian

Convert FLAC files to MP3 under Debian

The following script will decode the .flac files in .wav and then encode them in .mp3 under a folder with the same name. The flac files will not be deleted.

1. We install FLAC and LAME:

apt-get install flac

lame program can be install from source following these instructions

2. Now we will generate a file to be reachable in any directory:

nano /bin/flac2mp3

3. Paste the following script:

# Encode
# v0.1 17.08.08 - First created
# Darren O'Connor

# This script, when run in a folder full of FLAC files, will create high quality VBR mp3's for use in mp3 players.
# This version uses lame 3.98. If you use version 3.97 and below you'll need to change a few options

#!/bin/bash
mkdir wav/
flac -d *.flac
mv *.wav wav/
cd wav/
for f in *.wav; do mv "$f" "${f%.wav}";done
mkdir ../mp3/
find -maxdepth 1 -type f -name '*' -exec lame -V0 -q0 '{}' -o '../mp3/{}' \;
cd ../mp3/
for FILE in *; do mv "$FILE" "$FILE.mp3"; done
cd ../
rm -r wav/

Short description: this script will extract all files in .wav files found in current directory and move them in wav directory. after this, it will convert all .wav files in .mp3 under mp3 directory, delete the wav folder and exit.

4. Make the script executable:

chmod +x /bin/flac2mp3

5. How to use it:

we navigate to out directory containing .flac files and run

flac2mp3

after everything was encoded, you will see a subdirectory called mp3. those are the files you need.

Resources: ubuntu for humans

0 comments:

Post a Comment