欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP中使用FFMPEG獲取視頻縮略圖和視頻總時(shí)長(zhǎng)實(shí)例

 更新時(shí)間:2014年05月04日 09:21:07   作者:  
這篇文章主要介紹了PHP中使用FFMPEG獲取視頻縮略圖和視頻總時(shí)長(zhǎng)實(shí)例,需要的朋友可以參考下
復(fù)制代碼 代碼如下:

//獲得視頻文件的縮略圖
function getVideoCover($file,$time,$name) {
     if(empty($time))$time = '1';//默認(rèn)截取第一秒第一幀
     $strlen = strlen($file);
     // $videoCover = substr($file,0,$strlen-4);
     // $videoCoverName = $videoCover.'.jpg';//縮略圖命名
     //exec("ffmpeg -i ".$file." -y -f mjpeg -ss ".$time." -t 0.001 -s 320x240 ".$name."",$out,$status);
     $str = "ffmpeg -i ".$file." -y -f mjpeg -ss 3 -t ".$time." -s 320x240 ".$name;
     //echo $str."</br>";
     $result = system($str);
     }

//獲得視頻文件的總長(zhǎng)度時(shí)間和創(chuàng)建時(shí)間
function getTime($file){
     $vtime = exec("ffmpeg -i ".$file." 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//");//總長(zhǎng)度
     $ctime = date("Y-m-d H:i:s",filectime($file));//創(chuàng)建時(shí)間
     //$duration = explode(":",$time);
     // $duration_in_seconds = $duration[0]*3600 + $duration[1]*60+ round($duration[2]);//轉(zhuǎn)化為秒
     return array('vtime'=>$vtime,
     'ctime'=>$ctime
     );
}

相關(guān)文章

最新評(píng)論