4 ms·
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. Split th
by userbinator 5y ago
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.
Split the file after the metadata block; change the data inside the metadata block (possibly changing its size); add the difference between the old and new size to all the offsets in it; recat the two pieces together.
You could even do this "streamingly", to inject album art etc., since you know what size the added content will be. Simply add the diff-offsets to the right fields as they get streamed out.
The above solutions didn't take much thought to come up with. I wonder why no one at Apple thought of that (especially the latter)?
- rootusrootus 5y ago> The above solutions didn't take much thought to come up with. I wonder why no one at Apple thought of that (especially the latter)? The quintessential HN comment!
- cogman10 5y agoThis is the sort of thing that also seems crazy rare to need to fix. Ok, so you need to reassemble a file and recalculate offsets when an artist changes their names... so what? How often does that actually happen? Do people that download your music CARE that the meta data reflects an old/wrong spelling? Even the argument of "Well, they need to download the whole file before they can see the metadata" seems really weak. If someone is streaming the music, why not stream the metadata separately from the data? Why do those two things HAVE to be together? Heck, why not have a metadata "db" (ala plex) instead of insisting that stuff be bundled on the media itself? Just seems like a bad solution all around.
- iggldiggl 5y ago> Heck, why not have a metadata "db" (ala plex) instead of insisting that stuff be bundled on the media itself? Because that isn't portable and then a different faction will be screaming "vendor lock-in". The metadata inside the media file itself is in a standard format that anybody can read, and storing it inside the file also ensures that it cannot become separated from the file it's belonging to. Besides, any reasonable kind of software involving any kind of media library will already be keeping its own metadata database (and that includes iTunes/Apple Music), because rescanning the whole library on each program startup would be ridiculously inefficient (all the more so historically when hard disks were more common). But it can't be the sole source of truth because see above – people who still keep a local library of music around might want their media file collection to be interoperable with other software, too.
- ARandumGuy 5y agoI would guess the original file structure was designed for hard drives, and was never changed. When storing on a hard drive, you want the data in a single file to be located physically close together, which becomes more difficult if you're splitting up the file when you make metadata changes. Or, if the article's speculation is correct, Apple designed their formats assuming only 5kb of empty space would be allocated, which was insignificant even for the 1st Gen iPod's 5 GB hard drive. No reason to do more complicated stuff if a simple solution works. It only becomes a problem when people don't bother to keep track of how much empty space is being added automatically.