AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] Extract/Read album art from MP3/M4A?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
notbryant



Joined: 20 Feb 2009
Posts: 36

PostPosted: Fri Feb 26, 2010 7:01 am    Post subject: [SOLVED] Extract/Read album art from MP3/M4A? Reply with quote

Greetings!

So I'm just tinkering around, and I'm fiddling with a type of music library analyzer, and I'd love to include the album art for albums in the Listview row for that album. I already know how to add images to a Listview, and how to adjust the row size (though I haven't tried the bigger row size extensively yet).

So now, all I need is how to either (A) Read the embedded album art into memory, or (B) Save the art to a file.

I've searched the forum and can't find a surefire way to do it. I've seen tag reading and tag editing, but not art. I realize that AAC is probably a bit more tricky, so even MP3 would be grand.

-Pie

PS - Might be a stupid question, but what type of file would it be? Isn't it an embedded jpg?

PSS - If there's no real way to do this in AHK, I'd love suggestions for small programs that could accept MP3 files as arguments.


Last edited by notbryant on Fri Apr 02, 2010 8:22 pm; edited 1 time in total
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3910
Location: Bremen, Germany

PostPosted: Fri Feb 26, 2010 3:06 pm    Post subject: Reply with quote

Hi,

I had asked a similar question and it got solved with AudioGenie. Please see post http://www.autohotkey.com/forum/viewtopic.php?t=38346

I'll post a AudioGenie wrapper soon. Than tag reading and writting including album art will be easy.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
notbryant



Joined: 20 Feb 2009
Posts: 36

PostPosted: Fri Feb 26, 2010 8:17 pm    Post subject: Reply with quote

Thanks, I have no idea how I missed that.

I can't find where AudioGenie supports cover art, but I think I'm going to try MediaInfo instead, since I'm only going to be reading, and MediaInfo isn't nagware.

I can't seem to a valid jpg image though. I've got my test MP3, and I run "mediainfo song.mp3", and it says that 'Yes', it has album art, and it's an 'image/jpeg'.

I'm really a novice when it comes to ANSI/Unicode, tags, DLLs, and all this, but I think I might be on the right track. Here's my code so far:

Code:
PathToMediaInfoDLL := "C:\Bry\MediaInfo\MediaInfo.dll"
PathToMp3File := "C:\Bry\MediaInfo\Song.mp3"

hModule := DllCall("LoadLibrary", "str", PathToMediaInfoDLL)
handle := dllcall("mediainfo\MediaInfo_New")

GetUnicodeString(PathToMp3FileUni,PathToMp3File)
dllcall("mediainfo\MediaInfo_Open", "UInt", handle, "str", PathTomp3FileUni)

Info_GetPtr:=DllCall("mediainfo\MediaInfoA_Get", "UInt", handle, "int", 0, "int", 0, "str", "Cover_Data", "int", 1, "int", 0)
Info_Get := ExtractData(Info_GetPtr)

FileAppend, %Info_Get%,Test.jpeg


It seems to run without a problem, but the JPG can't be opened. Am I just missing something blatantly obvious here?

EDIT: Durr, I feel dumb. The image is stored in Base64. I got a Base64 Decoder here, decoded the file, and it's now a perfect JPEG cover art. I would love to use a Decoder in AHK, but I tried using one that I found on the forum by Laszlo, and it took like literally 5 minutes to process the entire file. So I think that might be it.

Well, problem solved, I guess. The only annoying thing is that it takes a few seconds to extract the Cover_data, and since I kind of plan on doing it for dozens or hundreds of albums, I might have to rethink my plan.

-Pie
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group