I encountered a similar problem not so long ago and looked around. The simplest and most effective method (in my opinion) is to use the exec command for additional information about multimedia.
I based my code on a forum post on longtailvideo http://www.longtailvideo.com/support/forums/jw-player/setup-issues-and-embedding/9448/how-to-get-video-duration-with- ffmpeg-and-php
<?php $videofile="/var/video/user_videos/partofvideo.avi"; ob_start(); passthru("/usr/bin/ffmpeg -i \"{$videofile}\" 2>&1"); $duration = ob_get_contents(); ob_end_clean(); $search='/Duration: (.*?),/'; $duration=preg_match($search, $duration, $matches, PREG_OFFSET_CAPTURE, 3); echo $matches[1][0]; <-- Duration ?>
This script can handle everything that ffmpeg is ready to handle (that's a lot!). I know that the above example illustrates a video file, but it works great with audio as well
source share