PDA

View Full Version : Patch for faster AAC/MP4/M4A tags retrieval speed


Arnie Pie
2005-06-04, 14:50
hi,
a week or so ago i posted up this (http://www.xboxmediaplayer.de/cgi-bin/forums/ikonboard.pl?act=st;f=2;t=13257) question in the support forum. given the lack of any comments, i guess it wasn't the best place for it, so apologies for that if that was the case.

anyway, i thought i'd look at this some more, and come up with a patch for it. the problem is that aac tag retrieval currently involves pulling the *entire* file over into memory so that libmp4 can be used to parse the tags. i don't have any really large aacs (say, > 20mb), but pulling all that data across just to get the metadata seemed a little excessive.. :)

after looking at a number of mp4 tag parsing modules on the web, i've written a replacement for musicinfotagloadermp4.cpp, which rather than reading the entire file, seeks through the atoms present in the mp4 file to pull out the stuff that's needed (artist, genre, track name, album name etc).

my tests here with approximately 4500 aacs show that rather than the 20 to 60+ seconds per track retrieval overhead (on an 802.11g network, with files accessed via samba), the tag retrieval now takes in the order of < 0.25 seconds. regardless of how big the file is. i was able to do a full scan of my itunes music directory over samba in just a few minutes. as a consequence of this change, musicinfotagloadermp4.cpp doesn't use libmp4 either (reducing the memory footprint a little).

i still need to tidy up the code a little, and i've yet to test extraction/caching of the 'covr' atom data (cover art), but i was after some opinions as to whether i should look at making this faster tag processing optional (in which case, what is the best way of doing this), or just submit the patch as is..

cheers,
arnie pie

spiff
2005-06-04, 15:51
as long as you test it properly i can't see any reason to make it optional. nice work btw

jmarshall
2005-06-04, 15:57
submit as-is is probably best, then we can take a look at it and see whether it's suitable or not (and improve on it together if necessary)

cheers,
jonathan

Arnie Pie
2005-06-05, 14:36
i've added it to sourceforge as patch 1215111. hope this is ok..?

it's nice to be able to contribute to the project (albeit in a minor way), after benefitting from it for so long.. :)

cheers,
arnie

spiff
2005-06-05, 17:33
hi,

i had a look. looks fine, except for one little thing.

could you please update it to use the id3 genre tags from lib/libid3/globals.h

unnecessary dupes is no favourite of mine :)

spiff

Arnie Pie
2005-06-05, 18:10
hi,

i had a look. looks fine, except for one little thing.

could you please update it to use the id3 genre tags from lib/libid3/globals.h

unnecessary dupes is no favourite of mine :)

spiff
crikey..! i never thought to check that these were already in the codebase. although thinking about it, it seems pretty obvious that they would be.. :)

i'll get it fixed now, and update the patch on sf.

[edit: code on sf is now updated.. also found a bug in genre code while i was applying this change, which is now fixed]

thanks!
arnie

spiff
2005-06-05, 19:51
hi,

thanks. will test 'n' apply when i get home tonight

spiff

spiff
2005-06-06, 02:29
commited. thanks alot!

Gamester17
2005-06-08, 13:16
is it possible to do something like this for mp3 tags too (id3 id3v1/id3v2)?, (and what about other tag formats which xbmc support like wma, ogg, flac, ape, etc)?

jmarshall
2005-06-08, 14:09
as far as i'm aware, ogg/flac tag reading etc. is already pretty fast. id3 reading is the slowest of the current lot i believe. we use libid3 for this due to the vast number of different options in id3 tags.

not sure whether it can be improved at all.

the main issue with aac (as far as i can ascertain) was that libmp4 had an inefficient tag reading method.

spiff
2005-06-08, 14:51
actually, the main issue with libmp4 was that it only supported reading from local files..