The 0,5 MB of nothing in all Apple Music files | Ctrl blog
Daniel Aleksandersen
Daniel Aleksandersen
2020-10-14
8–10-minute read
Share
Have you ever bought a storage upgrade for your iPod, iPhone, or Mac to have more room for your Apple Music (formerly iTunes) digital music collection? You may have been filling it with gigabytes worth of empty space.
The music files you purchase from the Apple Music Store (AMS; formerly the iTunes Music Store) contain approximately 6 % of the digital equivalent of nothingness. I’m not referring to silence, but continuous blocks of empty space set aside inside the files. It serves no purpose other than to pad the files to make them 0,5 MB larger. So, why is Apple making music files unnecessarily large? and how do you recover the wasted space?
This article is fairly technical, and the topics in it require a fair bit of explanation. You can skip the first 14 paragraphs if you’re only interested in the “why”, or skip the first 17 paragraphs for the “how.”
Music files purchased from AMS is encoded with the Advanced Audio Codec (AAC) using the Apple AAC Encoder. The files are delivered in an ISOBMFF (ISO 14496-1) container. This container format is used for different media files including audio, pictures, and movies. The container format has lots of room for implementations to develop their own weird quirks.
ISOM containers are broken up into different data blocks including the actual multimedia stream, metadata (encoding details, artist name, album art, volume normalization hints, etc.), and empty space. There are other blocks too, but these three are the ones we care about in this article.
These sections can technically be arranged in any order in the file However, the exact order causes various side effects in some situations. For example, placing the metadata block at the end of the file means you must download (or read from local storage) the entire song before you can play it. To avoid this, encoders tend to place it before the much larger multimedia stream block. The metadata block refers to absolute positions inside the multimedia stream block measured as an offset from the start of the file. You can’t make changes to the metadata (e.g. change the spelling of an artist’s name) without reassembling the entire file to recalculate the offsets.
To get around this, encoders tend to set aside some empty space between the metadata and multimedia stream blocks. In ISOM containers, this block is known as a “free” block. These blocks contain nothing but null-bytes. If you change the title of an album, Apple Music can expand the metadata block and shrink the free block without having to move the multimedia stream block. So far, so good.
If you rip a CD with Apple Music using the Apple AAC Encoder (the default option), it will reserve approximately 5 kB of free space inside each file for this purpose. That’s enough for you to add about 1250 emojis to the metadata of each of your songs. It should be plenty of room for you to make whatever changes you find necessary to the metadata. If you really need to add more data, the music file can be reassembled later to grow the metadata space. The operation would take slightly longer, but this would be an acceptable compromise as to not waste too much storage space.
However, the music files you’ve purchased from the Apple Music Store contains approximately 500 kB (0,5 MB) of free space. That’s 100 times more than Apple Music sets aside inside songs you’ve ripped yourself. It’s also a lot more space for metadata than anyone will ever need.
My Apple Music library consists of 2500 songs that I’ve purchased from AMS, and about the same number of home-rips. They’re encoded with the same quality settings. After analyzing my collection, I found that AMS purchased songs are on average 7 % larger than my home-rips. 6 % of that difference is empty space (1,25 GB in total.) Only 0,005 % of the storage space for home-rips is empty space.
I’ve analyzed samples of iTunes Store music files purchased in 2010 and 2020, and they’re all structured in the same way with the same amount of wasted space. Broadband speeds and storage was more expensive ten years ago, so this would have been an even bigger issue back then.
Apple’s classic HFS+ file system didn’t support sparse storage. Sparse storage is a file system storage technique that can be used to compact consecutive chunks of null bytes when writing files. The file system records how many repeating null-bytes there are instead of writing the individual null-bytes to the drive.
The new Apple File System (APFS) does support sparse storage, but Apple Music doesn’t take advantage of it and writes all the null-bytes out on the drive. I tried rewriting my music collection in a sparse-aware fashion, and was able to shrink my music collection by 5,2 %. Sparse storage can reduce storage requirements on your local computer. However, it won’t lower the bill from your online backup provider, or help...