Go to TogaWare.com Home Page.
GNU/Linux Desktop Survival Guide
by Graham Williams
Google

m4a to mp3


To convert a directory of iTunes m4a format files to mp3 we can use Debian's faad and lame packages. Install them with:

  $ wajig install faad lame

You may need to have one of the unofficial Debian archives in your sources list to obtain these packages:

  deb ftp://ftp.nerim.net/debian-marillat/ sid main

You can then run the command faad to convert to wav format and then lame to convert to mp3 format:

  $ faad -o abc.wav abc.m4a
  $ lame -h -b 192 abc.wav abc.mp3

The -h option of lame requests the production of higher quality output (taking more time to do so) and the -b option results in a bitrate of 192kbps for the resulting mp3.

A simple script can be created to transform a directory of m4a files. You could put the following script into a file (first line should be #!/bin/sh) and call the file /usr/local/bin/m4a2mp3 with the appropriate permissions (chmod a+rx /usr/local/bin/m4a2mp3). Or you can simply select this code and paste it into a command line Terminal.

  for i in *.m4a
  do
    faad -o - "$i" | lame -h -b 192 - "${i%m4a}mp3"
  done

The recipe iterates over all files in the current directory that match the pattern *.m4a (i.e., all files with an extension of m4a). The faad command is applied to each m4a file in turn (the $i argument is quoted in case the filenames contain spaces). The - argument to the -o option of faad indicates that the output should be to the standard output, which is then piped to the lame command. The ${i%m4a}mp3 replaces the m4a extension with the mp3 extension in the filename.

Copyright © 1995-2006 [email protected]
Contribue and access the PDF Version