Unprotected m4a to mp3

Here’s a quick script that can convert m4a (AAC encoded music files) to mp3. This is a nice example of how powerful the command line can be.

It uses mplayer to write out the raw wave file, then uses lame to encode the mp3′s. After that it cleans up the file endings using sed. This script requires mplayer and lame to be installed.

It should work well on Fedora Core 5 and Ubuntu 6.

#!/bin/bash

for i in *.m4a
do
mplayer -vc null -vo null -ao pcm:fast:waveheader “${i}”
mv audiodump.wav “${i}.wav”
done

for i in *.wav
do
lame –preset fast standard “$i” “$i.mp3″
rm -rf “$i”
done

for i in *.mp3
do
x=`echo “$i”|sed -e ‘s/m4a.wav.mp3/mp3/’`
mv “$i” “$x”
done

[tags]programming, bash, linux, fedora, ubuntu, lame, mplayer, command line[/tags]

One comment

  1. Thanks!!! I wil added to my nautilus-scripts folder.
    Greetings

Leave a comment

Comment moderation is enabled. Your comment may take some time to appear.