Gentoo Linux tutorial: Playing m4a song files in Amarok

Several years ago, I bought many albums from the iTunes Music Store. I know, it was a stupid thing to do, and I regret it. But back then, I had a PowerBook (which has since broken), so everything “just worked”. Well, I have a new laptop now that I’m running GNU/Linux on, so it no longer “just works”. Luckily, I’ve found a solution that does work.

The first step is stripping the abysmal “FairPlay” DRM (that’s Digital Restrictions Management to those in the know) off of the encrypted m4p song files that I purchased. This was fairly easy using a program called QTFairUse — unfortunately, it only runs on Windows. You won’t find anything to do it under GNU/Linux because it needs to use iTunes to work.

So once I stripped the encryption off the .m4p files, I was left with these .m4a song files. They’re not encrypted, but they’re also not a very widely used format, and aren’t supported by most audio player software. The simplest solution would just be to transcode them to ogg or mp3, but that’s a bad idea. You shouldn’t ever convert from one lossy format to another. It’s like making a xerox copy of a xerox copy; the quality loss accumulates. Now if you have a non-iPod portable digital music player, you don’t really have many choices, because none of them support m4a. Personally, I don’t see anything ethically wrong with downloading nice quality mp3s of songs you’ve already purchased just to avoid the transcoding quality loss, but I’m sure the law disagrees with me there.

Anyway, I digress. This tutorial is about playing m4a files natively under Gentoo GNU/Linux, without having to transcode them and suffer a loss of quality. It works perfectly for me, since I don’t even use my portable digital music player anymore. I just play everything on my computers. I’ll be using my favorite Free Software audio player program in this tutorial, Amarok. Luckily, everything necessary for the playback of m4a files is already in the source code — it just isn’t compiled in by default. So we’ll have to modify the USE flags to get it to work. But don’t fret; this is a very common procedure in Gentoo GNU/Linux.

First off, Amarok doesn’t actually do any of the music decoding on its own. It’s just a front-end. It uses xine-lib for the actual decoding. So we’re going to modify the use flags of xine-lib to support the m4a file format. Add the following line to /etc/portage/package.use using the text editor of your choice (I prefer GNU emacs):

media-libs/xine-lib aac

The aac USE flag adds support for MPEG-4 AAC Audio, which is what we want. That’s all you need for the playback of m4a files. But wait, we’re not done. There’s another USE flag that we probably want to set. This one is for Amarok itself. It enables write support for tags in m4a files. It isn’t strictly necessary, but if you like keeping your collection organized by fixing errors whenever you find a missing track number or incorrect album name or what not, you’ll want this. Add the following line to your /etc/portage/package.use:

media-sound/amarok mp4

Now, all we have left to do is recompile Amarok with the new USE flags. So run this command at a command-line prompt:

emerge --ask --deep --newuse media-sound/amarok

Verify that everything looks good. It should be merging media-sound/amarok, media-libs/libmp4v2, and media-libs/xine-lib. There may be additional dependencies if you haven’t installed Amarok before. Then, once you’re satisfied, enter Yes to begin the merging, go enjoy a leisurely caffeinated beverage break, and when compilation is finished, you’ll now enjoy the ability to play all of your m4a song files from within Amarok.

That’s the end of the Amarok tutorial. But if Amarok isn’t your favorite music player software, don’t despair, there’s probably a way to get m4a files playing in whatever your favorite player happens to be. Use the equery program to get a list of all possible USE flags for the software you’re interested in, figure out the one(s) that enable playback of m4a files (it’s probably along the lines of m4a, aac, or faad), and add them to your /etc/portage/package.use. For instance, to see the USE flags that mplayer supports, run equery uses -a media-video/mplayer. You’ll find aac in that list, so if you want to enable m4a support under mplayer, be sure to enable that USE flag.

8 Responses to “Gentoo Linux tutorial: Playing m4a song files in Amarok”

  1. William Says:

    What’s with the spam-shaped things?

  2. Cyde Weys Says:

    What spam-shaped things?

  3. Will (Green) Says:

    There were comments listed that looked like they were pulled from other another blogs main posts.
    There was something similar that seems to have disappeared on the “Culture Jamming Christmas Lights” post from a few days ago. It said something akin to “Christmas blogs aggregator”.
    I’ll copy down the next one I see, if there are more.

  4. Cyde Weys Says:

    Will, if you’re referring to the spam trackbacks from splogs, don’t bother. Yup, I’ve been seeing them, and the reason they’ve been disappearing is because I’ve been deleting them. They’ve been getting really bad lately — this post and the Facebook post were hit with several within fifteen minutes of posting. I’ve installed a new WordPress plugin that should deal with the problem.

  5. William Says:

    This is the only blog I read, so I’m not really up on terminology. I didn’t realize spam blogs even existed until I looked up “splogs”.

  6. Easwar Hariharan Says:

    Um,m4a playback support in Amarok in Ubuntu is already enabled and I can listen to them fine but there’s no tag editing support,could you help with compiling Amarok with support for editing m4a tags in Ubuntu?
    I am using version 7.04. Amarok version: 1.4.5

  7. kornwalios Says:

    Thanks man! That was really helpfull! :) have a nice day!

  8. friend Says:

    Thanks for your blog, helped a lot!