Converting m4a files to mp3 using faad and lame

This script will convert all m4a files in a directory to mp3 format. For each mp4 file, the faad program converts it into wav format, then lame converts it to mp3 (a temporary wav file will be created, with the same name as the mp4 but with an added .wav extension). The original files will be left intact.

Usage: m4a2mp3 [directory_containing_m4a_files]

#!/bin/bash
#
# Convert m4a to mp3

if [ -n "$1" ]; then

  for i in $1/*.m4a
  do
    faad -o "$i.wav" "$i"
    dest=`echo "$i.wav"|sed -e 's/m4a.wav$/mp3/'`
    lame -h -b 192 "$i.wav" "$dest"
    rm "$i.wav"
  done

else
  echo "Usage: m4a2mp3 [directory_containing_m4a_files]"
fi

References

Original script modified from that by mwiertz posted on the Gentoo forums: converting m4a files under linux (gentoo).

faad usage taken from this useful list of conversion commands: Konverzija između različitih audio formata.

Last modified: 16/05/2007 Tags: (none)

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top