10.38 Audio Conversions


The GNOME application soundconverter will convert a multitude of sound formats to, for example, ogg format. Supported formats include ogg, aac, mp3, flac, wav, avi, mpeg, mov, m4a, ac3, dts, alac, mpc, ape, and sid.

10.38.1 Convert 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
    faad -o - "$i" | lame -h -b 192 - "${i%m4a}mp3"

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.

Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0