Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get cover art from mp3 files through PHP and display it

So I'm building a podcast website, I'd like to be able to upload songs and have the cover art appear next to the play button. I have jPlayer setup and the music part is all done, but how can I use - preferably PHP, but if not, javascript or jQuery - to grab the cover art that's embedded with the mp3 file and show it?

Thanks!

like image 456
alt Avatar asked Jun 15 '12 07:06

alt


1 Answers

Album art is a data frame identified as “Attached picture” due ID3v2 specification, and getID3() now is only one way to write all possible data frames in ID3v2 with pure PHP.

Look at this source: http://getid3.sourceforge.net/source/write.id3v2.phps

Search for this text in the source:

// 4.14  APIC Attached picture

there's a piece of code responsible for writing album art.

Another way, that seems to be not as slow as pure PHP, is to use some external application, that will be launched by PHP script. If your service designed to work under a high load, binary compiled tool will be a better solution.

A better (faster) way to do this would be through an external application and the PHP exec() function to fun a command. I would recommend eyeD3.

like image 61
sumitkanoje Avatar answered Sep 28 '22 07:09

sumitkanoje