php获取视频封面图

原创 admin  2019-07-02 17:35  阅读 50 次
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;
}
本文地址:http://www.z1988.com/1703.html
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!

发表评论


表情