UNIX: convert m4a to mp3


First, convert m4a to wav:
Single file

mplayer -ao pcm mysong.m4a -ao pcm:file="mysong.wav"

Multiple files

#!/bin/bash
# 
# m4a2wav
# 
for i in *.m4a; do
    mplayer -ao pcm "$i" -ao pcm:file="${i%.m4a}.wav"
done

Then, convert wav to mp3:
Single file

lame -h -b 192 mysong.wav mysong.mp3

Multiple files

#!/bin/bash 
# 
# wav2mp3
# 
for i in *.wav; do
    lame -h -b 192 "$i" "${i%.wav}.mp3"
done
About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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