Howto convert MPC, Flac and Ogg to mp3 on Linux with free tools

In my MP3 library’s past I had experimented with different file formats. I have recordings of vinyl or radio in FLAC (Free Lossless Audio Codec), MPC (Musepack), Ogg (Ogg Vorbis) and other, extracted audio tracks from DVB-recordings on my PC. But since my car’s radio, my phone and my DVD player don’t support those formats (Nokias N900 did!), I chose to convert them to MP3. I made three little bash scripts, that probably only prove my limited coding capabilities… 🙂

Nevertheless, these little snippets are quite handy for me, and yes, I do know there are better solutions around, but that simply works for me. For security reasons, the source files are not deleted, but moved to a new subdirectory. The final “ls” creates a playlist in the working directory.

If you want to try that at home, you’ll need the programs:

– oggdec from the vorbis-tools package

– flac from the flac package

– mpcdec from the package musepack-tools

All of them are in standard Ubuntu repositories and can easily be installed via aptitude (at least here on Maverick (10.10).

a) FLAC, via stdout:

for file in *.flac
do flac -cd “$file” | lame -h – “${file%.flac}.mp3”;
mkdir flac.old
mv *.flac flac.old/
ls *3 > playlist.m3u

b) … and the same for MPC:

for file in *.mpc
do mpcdec “$file” – | lame -h – “${file%.mpc}.mp3”;
mkdir mpc.old
mv *.mpc mpc.old/
ls *3 > playlist.m3u

c) Ogg Vorbis:

Directing Oggdec to stdout wouldn’t work here, so I needed a temp.wav file for each conversion process:

for file in *.ogg
do oggdec -o temp.wav “$file”;
lame -h -V4 temp.wav “${file%.ogg}.mp3”;
rm temp.wav
mkdir ogg.old
mv *.ogg ogg.old/
ls *3 > playlist.m3u

Next thing will be extracting the audio track from 3GP files, like ancient mobile phones used to record. As far as i read up to now, Mplayer or its partner mencoder should be able to do that, e.g. for videos with

mencoder infile.3gp -oac pcm -ovc raw -o outfile.avi

I’ll keep you updated.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: