Saturday, 9 June 2007

PutPinfInItsPlace: An iTunes Plus fixer for Nokia mobile phones

I have a Mac.
I have iTunes.
I have a Nokia E61.

So you would think... perfect! Everything is wonderful now that iTunes Plus is out, but...

As is described by following the link above, there is an incompatibility between iTunes and Nokia mobile phones (and potentially other devices on and beyond the Symbian platform).

Update #1: A means of syncing these files to the phone.
Update #2: I have uploaded a version of PutPinfInItsPlace that is compatible with Mac OS X Panther 10.3.9/Java 1.4. Everyone should be covered now, sorry about that.
Update #3: An alternative option for doing the conversion on the phone instead is now available. (Hint: I prefer it this way.)

While there is a simple workaround, again described in the link, which involves re-wrapping the iTunes Plus file in a new AAC file, I wasn't happy with that so I kept investigating.

Turns out there is a single byte that makes all of the difference to such devices, as is borne out by the output of Atomic Parsley (v0.9.0,
An iTunes Plus song has the following apparent structure:
Atom stsd @ 450 of size: 32871, ends @ 33321
Atom mp4a @ 466 of size: 32855, ends @ 33321
Atom esds @ 502 of size: 51, ends @ 553
Atom pinf @ 553 of size: 32768, ends @ 33321 ~
Atom stts @ 33321 of size: 24, ends @ 33345
~ denotes an unknown atom

Whereas the re-wrapped container (that works on the devices) has the following structure:
Atom stsd @ 442 of size: 32871, ends @ 33313
Atom mp4a @ 458 of size: 32855, ends @ 33313
Atom esds @ 494 of size: 32819, ends @ 33313
Atom stts @ 33313 of size: 24, ends @ 33337

Note that the unknown atom pinf (that's where your iTunes account information appears to be by the way) doesn't appear in the QuickTime Pro-containered file.

I tried to trivially strip out the pinf atom using Atomic Parsley, but no joy, and this is seemingly a red herring - as a hex editor examination of the files will attest to. The re-wrapped version of the file still has my account name in it, yet it doesn't cause the device to baulk!
The only difference in that area of the file is one byte - it's in the size of the esds atom. It appears that QuickTime Pro writes the pinf atom out as a child of esds (and Atomic Parsley and other tools don't parse the file that deeply to care), whereas the iTunes Store/iTunes 7.2 writes the pinf atom out as a sibling instead. It is only this difference (not any metadata) that prevents the file from playing on my phone.
Note that changing this byte means iTunes 7.2 no longer sees the file as a "Purchased AAC audio file", instead Get Info reports simply an "AAC audio file" kind. The Account Name is still visible.

So on to fixing this. You can simply find the byte (get a hex editor, I used the free 0xED - which is in the atom size field immediately before 'esds' appears) and change it to include the pinf size. But this would obviously get tedious.

I've already got 27 iTunes Plus songs and I'm bound to get more, so to help me and you out, here's a very simple tool to change the byte for you.

I named it "PutPinfInItsPlace" since the problem is a misplaced pinf atom (smart hey?). This is a Java application, purely so that iTunes Windows and iTunes Mac users can use it (Windows users - install Java from

It will accept a list of files either on the command line, or if no files are given, it will ask you for them with a simple file chooser window. You can select as many files as you like at a time.

It will first back up your file as is in the same folder (renaming it to song name.purchased.m4a), and it won't continue if it can't back up your song, so it should be safe to use.

Then it will walk through the file looking for the misplaced pinf atom, copying the file out as it goes, changing the byte when it finds it then finishing off the file. Messages will let you know of its progress.

You can use the file directly on your iTunes Music folder because the tool preserves the original file names and metadata so iTunes should keep your ratings. If the conversion is successful you can manually delete or move the backups away.

There is more information on the tool in the README.txt file, and I'd appreciate some success or failure comments here. Thanks!

I hope this information (so someone can fix the issue or make a better tool) and tool is useful in the meantime.

You can download the tool from the link on

Update 12/08/2010: Changed link to GeoCities mirror.