The faad
program is what is supposed to be used to play M4A files,
but it seemed to not work with all of mine. MPlayer seems to be better.
Unfortunately, MPlayer
can't
output the decoded PCM data to stdout, so to achieve parallel
decoding/encoding, a named pipe is necessary. This is like a pipe on the
command line except that it has a filename.
mkfifo tmp.pipe
mplayer -noconsolecontrols -ao pcm:file=tmp.pipe whatever.m4a &
lame --preset standard tmp.pipe whatever.mp3
rm -f tmp.pipe
Substitute your preferred lame
flags.
To do all files in a directory recursively:
mkfifo tmp.pipe
find . -name "*.m4a" | while read filename
do
mp3_filename=`basename "$filename" ".m4a"`.mp3
mplayer -noconsolecontrols -ao pcm:file=tmp.pipe "$filename" &
lame --preset standard tmp.pipe "$mp3_filename"
done
rm -f tmp.pipe
Add -maxdepth 1
to find
's arguments to be non-recursive.
A little simpler. Here's the recursive version:
find . -name "*.flac" | while read filename
do
mp3_filename=`basename "$filename" ".flac"`.mp3
flac -dc "$filename" | lame --preset standard - "$mp3_filename"
done
Hey.. good idea. I also made a script that parallelizes and put it on github.