2004-04-19:
Playing iTunes/iMusic m4a/AAC music on Debian,
installing faad2 and xmms plugins

Update: Debian stable (and probably most other systems) finally come with these libraries installed. This solution is probably finally obsolete.

First of all, iTunes iMusic store music is generally encrypted and cannot be played except on iTunes (which doesn't currently exist for UNIX).

Decrypting these files is likely a violation of the iMusic user agreement and possibly a violation of the DMCA in the US.

There are tools that will do it, such as playfair, but you'll have to find them elsewhere (check playfair.org). This will let you convert .m4p files to .m4a/ACC files.

But whether you've done that or you just have unencrypted ACC files is your business, if you want to play the unencrypted files on Debian, you can use libfaad2, but it won't compile out of the box for version 2.1, because it gets this error:

configure.in:34: warning: AC_TRY_RUN called without default to allow cross compiling

To fix:

First install libid3-dev

% apt-get install libid3-dev
Get faad2 code from: http://www.audiocoding.com/

Add:

AC_PREREQ(2.50)
To the top of configure.in

Remove the rpm target from Makefile.am:

REMOVE->  rpm:    Makefile
REMOVE->          make dist
REMOVE->          $(RPMBUILD) -ta $(PACKAGE)-$(VERSION).tar.gz
REMOVE->          rm $(PACKAGE)-$(VERSION).tar.gz
Run the commands in bootstrap manually, but ignore the error code returned from automake:
% aclocal -I .
% autoheader
% libtoolize --automake --copy
% automake --add-missing --copy
## Ignore these errors:
automake: libfaad/Makefile.am: not supported: source file `codebook/hcb.h' is in subdirectory
etc...
% autoconf
Then configure, make and make install:
% ./configure --with-xmms --with-mp4v2
% make
## Ignore xmms plugin errors, see below.
% make install
Chances are you'll have errors making the xmms plugin because it won't find libmp4v2 or else it won't find the gtk headers, but go ahead and make install anyways. If you don't want the xmms plugin, then you're done. Otherwise we'll build the plugin by hand. Go there:
% cd plugins/xmms/src
And create a file called makefile.manual (do 'save as..' on this link) (Thanks to Michael Klein for compilation help)

I have gcc-2.95 and gcc-3.0.4 installed, and gcc-3.0.4 didn't work because the 3.0.4 libs are missing a symbol, so I specified gcc-2.95 in the makefile. If you don't have the gcc-2.95 link installed but you have gcc-2.95 or similar, then just uncomment the second line in the file.

Before making, there's a bug in the code that clips off the last two seconds of songs. The plugin has a buffer that it fills, and once it's done loading the buffer then it thinks it's done with the song. Not too clever. Matthew Klahn sent me a fix. Just save this patch and run:

% patch < libmp4.c.patch
You can see more info about the patch at the audiocoding forum

Finally you can make with the makefile.manual:

% make -f makefile.manual
And that should do it. You can install it into your xmms plugins directory manually, find where your other plugins are kept and do something like:
% mv libmp4.so /usr/lib/xmms/Input/
Quit and restart xmms and select preferences (ctrl-p) and see if "MP4 & MPEG2/4-AAC audio player" is listed in the input plugins and is enabled.

Now try adding some (unencrypted!) aac/m4a songs. Unfortunately if the song is corrupted, the plugin will skip it sans warning, so try a few songs if you see the plugin enabled and it won't play your song.


Addendum: Mario F. tells me that he's seeing some files in DOS format when he downloads (with all the '^M' at the end of each line) which gives you weird make errors. He mentioned the rather useful one-liner (in sh):

sh% for i in `find . -type f`; do mv $i $i~; sed $i~ -e "s/^M//" > $i; rm $i~; done
Addendum #2: The mp4 plugin will crash if the playlist has any blank lines, I've submitted a bug to the author.


Back to Solutions.

DaveSource.com - Dave's geek site GetDave.com - all the current Dave Pointers. MarginalHacks - I have an elegant script for that, but it's too small to fit in the margin.