虽然我试图获得一个flv视频文件的长度,我得到0秒,因为它只发生在一些视频,否则我的功能工作正常。得到flv视频长度
下面是我的代码。
<?php
function mbmGetFLVDuration($file){
// read file
if (file_exists($file)){
$handle = fopen($file, "r");
$contents = fread($handle, filesize($file));
fclose($handle);
//
if (strlen($contents) > 3){
if (substr($contents,0,3) == "FLV"){
$taglen = hexdec(bin2hex(substr($contents,strlen($contents)-3)));
if (strlen($contents) > $taglen){
$duration = hexdec(bin2hex(substr($contents,strlen($contents)-$taglen,3))) ;
return $duration;
}
}
}
}
}
// not working video file
$result = ceil(mbmGetFLVDuration('not_working_copy.flv')/1000);
// working video file
//$result = ceil(mbmGetFLVDuration('working_copy.flv')/1000);
echo date('H:i:s',mktime(0,0,$result))
?>
我附上两个工作和不工作的FLV视频链接如下:
工作视频: http://blog.developeronhire.com/wp-content/uploads/downloads/2011/06/working_copy.flv
不工作视频: http://blog.developeronhire.com/wp-content/uploads/downloads/2011/06/not_working_copy.flv
任何想法将不胜感激。
谢谢
可能的重复http://stackoverflow.com/questions/3282273/calculate-flv-video-file-length-using-pure-php – 2011-06-02 13:19:16
@Mr。黑色:对不起,它没有重复。请先阅读我的问题并发表评论。 – Sujeet 2011-06-02 17:32:57
工作在一个文件上而其他不工作,是为获取flv文件的视频长度的重复问题? – 2011-06-03 04:07:01