Extracting album art from mp3, mp4 aiff, etc...

Scott Findley's icon

Hello friends!

Im building a music 'player' application with max, which builds/queries from a database of songs using the awesome metatag object and the max dictionary system.

Ive been able to successfully extract any ID3 type metadata from each track, length, and build a waveform overview, writing said wave data as an array of floats, also stored in the aforementioned dictionary.

The thing I have *not* been able to do is read or store any embedded album cover art in any type of audio file. There must be a clever way to do this that I have not yet found... Im teaching myself max for the purpose of building this prototype, so Im no guru, though I have been able to find my way around pretty well so far.. Im still astounded at what a non programmer can get to work with max.

But alas, my quandry remains unsolved. Can anyone point me to a solution? ?

Thanx in advanced,

Scott

volker böhm's icon

hi -
I don't think you will manage to do this with max only. taglib seems to be able to do it, though.
so, with some additions/changes to metatag, which is based on taglib, this should be feasible.
which metatag are you using? the original one by j.bernstein or the newer hack that I provided some time ago?
vb

Scott Findley's icon

Volker, Thanks kindly for your response..

I was not actually aware of an alternative/modified version of metatag, only the j.bernstein version, though I see here that you helped create a version that properly writes metadata to AIFFS (or at least corrects the existing; broken behavior) nice!

Truth told, my C++ knowledge is minimal at best, though Id love to remedy that., and I would say the ability to manipulate album art would be the icing on an already very sweet cake, that is the metatag object. :) Sadly though, Id say the act of modifying a max external in C++ is probablly a schoshe beyond my limited traditional-programming scope.

Do you recon that would be a relatively easy endevour?

volker böhm's icon

actually the only thing i did was to simply compile metatag with a new version of taglib.
so, if you look into the original sources, you can see that a method to handle the album art (of mp3 files only) is already sketched out by j.bernstein.
In my own experiments at that time, I managed to export potential cover art as image files to disk. But the whole business is kind of confusing as taglib supports a lot of different file formats, and every file container handles images differently. If you don't want to try yourself, I might have another look over the weekend, but I can't promise it.

Scott Findley's icon

Hey Volker, I dont suppose you had a chance to take a gander at that source code? I did myself, but sadly my knowledge of C++ is too limited to figure out why the commented-out code doesnt work - presumably why it had not been implemented.

Oh, I would owe you so many virtual beers if you did.. :) Anyone else following this thread / have any input?

Best.s

volker böhm's icon

hi - sorry, I didn't spend much time on this, but here is something to try out.

it should work ok with most mp3 or mp4 files. no support for other formats, yet. if some coverart is found, the picture data is extracted from the file and saved to /tmp, from where you can load it into max.
let me know if that works for you.
all the best, vb

Scott Findley's icon

Volker, first of all Thank you my man, your help is sincerely appreciated. More than you know. If youre ever in the LA area, oh the beers that shall be bestowed upon you. In other words, if you come round me, you can forget all about your beer needs. If anything, youll have TOO much beer.

With that said, and I hate to temper that with nit-pick, but it only 'sorta' worked on my end. Looks like the external object had an issue with ascii symbol conversion - basically if I look in the temp directory, The image is there, and saved, but has a name that looks like:

coverart.%EA%83jpg

instead of
coverart. (whatever) . jpg

so it gets neither the intended ascii symbols nor the dot in the right place to inherit file type association. Furthermore max does not interpret this newly saved file, expecting something more like:

/tmp/coverart.jpg

HOWEVER cutting and pasting the file path and copying it to a message box prepended by 'read' did indeed create a viewable image in fpic... COOL.

So it looks like a symbol generation issue within the c++ code. Im running OS X 10.11.6 and Max 7.2.4. 32 bit.

Thanx again a million times Volker. If youre tired of this, maybe you could send your modified code and I can take a gander?

metamax's icon

Until there is an update, you can parse and convert the names without much trouble Max.

volker böhm's icon

In other words, if you come round me, you can forget all about your beer needs. If anything, youll have TOO much beer.

hm, seems I really need to come over some time, to check out what's going on there!

coverart.%EA%83jpg

it should have simply been /tmp/coverart.jpg - oh, the joys of string manipulation in c...
does this fix it?

rubén's icon

Hi, great update of the metadata object!! many thanks!
this possibility of extracting the covers is gonna save me a lot of work ;)