获取媒体文件持续时间(服务器端)

I'm looking for a way to get an accurate duration of media files. I've researched many solutions online including the getID3 library but ID3 tags are too easily edited or may not be populated in certain cases. I'm on a shared host at the moment so the ffmpeg library isn't an option either as I can't install anything on this host (GoDaddy).

I'm primarily looking at MP3, WMV, WAV, MP4, MPEG, AVI, and MOV files at the moment. Is there a way to get their duration using, preferably, PHP? I'd be happy with any solution that works though.

Will truly appreciate help.

Thanks

This one looks like it supports multiple media formats.

http://www.daniweb.com/web-development/php/threads/428301/getting-video-duration-without-ffmpeg

    function getDuration($file){
        if (file_exists($file)){
            ## open and read video file
            $handle = fopen($file, "r");

            ## read video file size
            $contents = fread($handle, filesize($file));
            fclose($handle);
            $make_hexa = hexdec(bin2hex(substr($contents,strlen($contents)-3)));
            if (strlen($contents) > $make_hexa){
                $pre_duration = hexdec(bin2hex(substr($contents,strlen($contents)-$make_hexa,3))) ;
                $post_duration = $pre_duration/1000;
                $timehours = $post_duration/3600;
                $timeminutes =($post_duration % 3600)/60;
                $timeseconds = ($post_duration % 3600) % 60;
                $timehours = explode(".", $timehours);
                $timeminutes = explode(".", $timeminutes);
                $timeseconds = explode(".", $timeseconds);
                $duration = $timehours[0]. ":" . $timeminutes[0]. ":" . $timeseconds[0];}
                return $duration;
            } else {
                return false;
            }
        }

In order to use it just do the following:

## first, define video file and location
$video_file = "somedirectory/video.flv";
## call out the function
echo getDuration($video_file);

I copped that from the link above. I tried it on a couple of media types that you mentioned and it seemed to work fine.