How do you get the metadata of media files using getid3?

i need to get the metadata of media files and then add them to a mysql database. in research i came across something called getid3, but have no idea how that works or how to use. the general consensus is that it seems to work very well. could someone explain how to do this. and the ascribe the data to a variable to be inserted into a database. it is for my major work at school (year 12). all help is appreciated

There are many file formats, and getID3 allows to extract different information from media files. Just download it from sourceforge, unzip and load to server. There are many examples that come with getID3 library distribution, you can find them in /demos folder. To try them, just upload some media file (mp3, wav, etc.) to this directory and open in your browser

thanks, wow it works really well. would you know how to i can integrate the getid3 library into my current code so i can then insert the information into my mysql database?

Sure. Again, based on code examples from the demo folder, you can create this quick script:
$getID3 = new getID3;
$file = ‘myfile.mp3’;

$ThisFileInfo = $getID3->analyze($file);

echo ‘File name: ‘.$ThisFileInfo[‘filenamepath’].’
echo ‘Artist: ‘.(!empty($ThisFileInfo[‘comments_html’][‘artist’]) ? implode(’
’, $ThisFileInfo[‘comments_html’][‘artist’]) : ’ ‘).’
echo ‘Title: ‘.(!empty($ThisFileInfo[‘comments_html’][‘title’]) ? implode(’
’, $ThisFileInfo[‘comments_html’][‘title’]) : ’ ‘).’
echo ‘Bitrate: ‘.(!empty($ThisFileInfo[‘audio’][‘bitrate’]) ? round($ThisFileInfo[‘audio’][‘bitrate’] / 1000).’ kbps’ : ’ ‘).’
echo 'Play time: ‘.(!empty($ThisFileInfo[‘playtime_string’]) ? $ThisFileInfo[‘playtime_string’] : ’ ‘).’

Oh Thank You soooo muuuuchhh. ive been stuck on this for days. i really appreciate it. ;D

additionally using this method, is it possible to get the file size and type? thanks for your help once again.

Yes it is possible. Add these lines to the code above:
[php] echo ‘File size: ‘.(!empty($ThisFileInfo[‘filesize’]) ? $ThisFileInfo[‘filesize’] : 0).’
echo ‘File type: ‘.(!empty($ThisFileInfo[‘fileformat’]) ? $ThisFileInfo[‘fileformat’] : ‘n/a’).’

Also, to check all available information returned by getID3() about given file, you can do this:
[php] echo ‘

echo ‘
Sponsor our Newsletter | Privacy Policy | Terms of Service