php获取视频封面图

[php]
function getVideoImages($file, $times = array(), $resolution = '640x360'){
$result = array();

$pathParts = pathinfo($file);
$filename = $pathParts['dirname']."/".$pathParts['filename']."_";

foreach ($times as $k => $v) {
$destFilePath = $filename.$v.".jpg";
$command = "/usr/bin/ffmpeg -i {$file} -y -f image2 -ss {$v} -vframes 1 -s {$resolution} {$destFilePath}";
exec($command);
//chmod($filename.$v."jpg",0644);
$destUrlPath = str_replace(ROOT_PATH, "", $destFilePath);
$selected = $k == 0 ? "1" : "0";//默认将第一张图片作为封面图
array_push($result,array($destUrlPath,$selected));
}
return $result;
}
[/php]

阅读剩余
THE END