- 使用过程只需一条命令,几个参数即可
- 不仅可以对视频也可以对图片生成缩略图,传入的文件名是图片即生成图片的缩略图。
/**
* 获取视频封面图片,与视频在相同文件夹下
* @param string $inFile 视频文件地址
* @param int $time 截图的秒数
* @param int $width 图片宽度
* @param int $height 图片高度
* @return string
* User: LiZheng 271648298@qq.com
* Date: 2019/10/12
*/
public function getVideoCover($inFile, $time = 1, $width = 320, $height = 240)
{
//输出文件名
$outFileName = substr($inFile, 0, strpos($inFile,'.')).'_cover.jpg';
//运行命令
$command = "ffmpeg -i " . $inFile . " -y -f image2 -t {$time} -s {$width}x{$height} " . $outFileName;
system($command);
return $outFileName;
}
原文:https://www.cnblogs.com/lz0925/p/11726128.html