Using getid3 to extract MP3 bitrate info

The place for "I can't figure out how to..." questions.
Post Reply
Jason28
User
Posts: 3
Joined: Tue Jun 24, 2008 3:42 pm

Using getid3 to extract MP3 bitrate info

Post by Jason28 » Tue Jun 24, 2008 3:46 pm

Hello, I am creating a new music type script using php. I really do not understand how to use getid3 to extract the bitrate information from an MP3 to prevent users from uploading disallowed bitrates. Any step by step instruction would be great. I know that the Jamroom author uses it somehow so I know that it works but do not know how to integrate it into a script of my own. Thanks :)

James Heinrich
getID3() v1 developer
Posts: 1477
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Post by James Heinrich » Wed Jun 25, 2008 1:31 am

Adapted from http://getid3.org/source/demo.basic.phps

Code: Select all

require_once('../getid3/getid3.php');
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($filename);
switch (@$ThisFileInfo['audio']['bitrate']) {
  case 128000:
  case 160000:
     echo 'this is ok';
     break;
  default:
     echo 'your bitrate is not allowed';
     break;
}

Jason28
User
Posts: 3
Joined: Tue Jun 24, 2008 3:42 pm

Post by Jason28 » Wed Jun 25, 2008 4:44 am

Thanks a lot it works. Only two more simple questions please if I only use this for MP3s can I delete all of those files besides getid3.php and write.php? Also, what are the tag names to write to the "more info" and "copyright" to appear in the media player? Would it be something like:

Code: Select all

$TagData['info][]     = 'blah';
I tried 'copyright' but that didn't seem to work so I assume it uses another name.

Thanks again.

Allan Hansen
getID3() v2 developer
Posts: 445
Joined: Sun May 04, 2003 2:22 pm
Location: Holmegaard, Denmark

Post by Allan Hansen » Thu Jun 26, 2008 3:45 am

For normal MP3 support you can delete all modules except id3v1, id3v2 and mp3.

For slightly more exotic MP3 support keep riff and apetag.


Regarding the tag name: Find a file that has this info and analyse it with getID3()...

Post Reply