123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|468|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> get album art from an MP3 (APIC frame?)

Wed, 11 Apr 2007, 05:07
oscar
I'm writing a simple little mp3 player in c# and i've searched google and code sites for a few weeks now but i can't find anything to help me open an mp3 file, get the album art from inside the file and save it as a separate image file... Can anyone help me at all?

thanks a buncheroo
Wed, 11 Apr 2007, 05:12
mike_g
Well for C there is Bass which is free as long as you dont use it for commercial purposes.

Dont if it works with C# but if it dosent theres probably a wrapper around for it.
Wed, 11 Apr 2007, 05:19
oscar
Bass doesn't seem to have any sort of ID3 functionality... I've got the play the mp3 part down... it's just getting the album artfrom the file i can't do


I might change to using Bass though... theres a .Net version too!!! thanks
Wed, 11 Apr 2007, 05:38
JL235
You could use Amazon's web tools to search and retrieve the album art from online, from their site. I can't remember what the tool or service is called, but I do believe that one is free.
Thu, 12 Apr 2007, 21:11
oscar
I could probably do that... but mp3's can actually have the album art stored inside the ID3 tag (which i've done) so all i have to do is figure out a way to retrieve that particular part of the tag and i have the album art.
Fri, 13 Apr 2007, 06:23
Blitz3Dman
How is the data stored and where? If you can give me three things I think I can write a quick program to extract an image.

1. The file's signature
2. The file layout (what stuff is saved how and where)
and 3. If pixel data is stored like a bmp or not. If it's bmp this'll be easy as pie if not I'll have to think a bit.

-=-=-
There are 10 kinds of people in this world -

( Insert 16 remarks about to what extent people know hex here )
Fri, 13 Apr 2007, 07:21
oscar
so far as i know the pixture is stored in PNG format and is denoted by the text APIC in the file followed by the image itself... my main problem is figuring out how long the image is... I can't find any coherant information on the APIC frame in the ID3V2 standard to help


in the mp3 file is the ID3 info and inside the ID3 info is the APIC tag (which signifies the start of the album art) I'm pretty sure the image is always stored as PNG (it is PNG in all of my mp3's)

thanks

i <3 you!!!
Fri, 13 Apr 2007, 07:30
mike_g
Would the file size not be stored in the PNG file header or something?
Fri, 13 Apr 2007, 07:31
Blitz3Dman
<3 ??

Erm, if it's in jpeg how exactly is the image stored?



-=-=-
There are 10 kinds of people in this world -

( Insert 16 remarks about to what extent people know hex here )
Fri, 13 Apr 2007, 08:18
oscar
i am pretty sure the image is encoded into png and just appended somewhere into the mp3 file so you the format is something like this

<mp3 is here><album art png file plonked in here><mp3 again>
Fri, 13 Apr 2007, 09:45
oscar
i think i know what i have to do... it's basically.. openthe file.... regex out the APIC bit to the end of the PNG picture (I just have to figure out a way to get the pictures size)


I'll post my solution after i fix my dodgy symtax highlighter (i'm writing a notepad type program)

thanks for the help though
Fri, 13 Apr 2007, 10:04
Blitz3Dman
Are the pictures always a uniform size? You may expiriment and see if, right at the beginning of the picture read a short for width and a short for height and if that seems weird then try seeing if they're stored as integers.

-=-=-
There are 10 kinds of people in this world -

( Insert 16 remarks about to what extent people know hex here )
Fri, 13 Apr 2007, 15:29
JL235
If you can find where the png starts, would you not be able to read the header file of the png to find it's size?
Fri, 13 Apr 2007, 18:50
HoboBen
Hi Oscar,

When ever I need to know anything about I file format, I check Wotsit.org

This Page has some files which might be useful. (and even if they're not useful in this particular case, might be useful later)

Cheers

-=-=-
blog | work | code | more code