RE: [PHP] Find out how long an MP3 is

From: Date: Wed, 22 Nov 2000 05:57:06 +0000
Subject: RE: [PHP] Find out how long an MP3 is
Groups: php.general 
Request: Send a blank email to php-general+get-26586@lists.php.net to get a copy of this message
Lo and behold, look what google found: http://www.egr.uri.edu/~kovacsp/code.html A Perl Library which calculates MP3 length (albeit for fixed lengths') His algorithm is basically. length = (filesize) / (bitrate * 125) So, something in php might look like (UNTESTED) <?php function MP3Length ($filename) { $f = fopen ($filename,"r"); if ($f) { $x=fread ($f,,1024) while (($temp != hex "FFE") && ($i < $readsize)) { $i++; $temp = ((ord(substr($buffer,$i,1)) << 4) & hex("FF0")) | ((ord(substr($buffer,$i+1,1)) >> 4) & hex("E")); } $bitrate = ( (ord(substr($buffer, 2, 1))) >> 4) & hex ("0F"); } return (sizeof($f)/ (($bitrate) * 125)); } MP3Length ("my.mp3"); ?>

« previous php.general (#26586) next »