Revision: 288
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 8, 2006 13:56 by velinea
Initial Code
function wavDur($file) { $fp = fopen($file, 'r'); if (fread($fp,4) == "RIFF") { fseek($fp, 20); $rawheader = fread($fp, 16); $header = unpack('vtype/vchannels/Vsamplerate/Vbytespersec/valignment/vbits',$rawheader); $pos = ftell($fp); while (fread($fp,4) != "data" && !feof($fp)) { $pos++; fseek($fp,$pos); } $rawheader = fread($fp, 4); $data = unpack('Vdatasize',$rawheader); $sec = $data[datasize]/$header[bytespersec]; $minutes = intval(($sec / 60) % 60); $seconds = intval($sec % 60); return str_pad($minutes,2,"0", STR_PAD_LEFT).":".str_pad($seconds,2,"0", STR_PAD_LEFT); } }
Initial URL
Initial Description
Use unpack() to decode header information. Return duration in format mm:ss
Initial Title
Read wav header and calculate duration
Initial Tags
Initial Language
PHP