关于ffmpeg /iis 8.5 服务器下,视频截取第一帧参数配置

ffmpeg 视频截取第一帧参数配置: 网站找了很多资料,但是都不能满足要求,然后自己写下解决过程。

首先看自己PHP 版本,安全选项里面 php5.4  跟php5.6 是不一样的。去除里面的system 函数限制。

然后,继续调整 system 函数的参数。做到cmd里面不报错误。

方法:

 1 /**
 2 * 获得视频文件的缩略图
 3 * 接口编号 : T1807-07-01
 4 * 
 5 * @param $file : 视频的位置
 6 * @param $time : 截取时间
 7 * @param $name : 截取之后的文件名称
 8 */
 9 public function getVideoCover($file,$time =1) {
10 if(empty($time))$time = 1 ;//默认截取第一秒第一帧
11 $strLen = strlen($file); // 函数返回字符串的长度
12 $videoCover = substr($file,0,$strLen-4);
13 $videoCoverName = $videoCover.'.png';//缩略图命名
14 
15 
16 //exe 文件在 项目的上两级目录
17 $path = "D:\HwsHostMaster\phpweb\php56"; 
18 
19 $str =$path . "/ffmpeg -ss ".$time." -i ".$file." -y -f mjpeg -vframes ".$time." -s 320x170 ".$videoCoverName;
20 
21 $result = system($str);
22 }

$path 为php环境跟目录,因为 iis 8.5 服务器 不支持在web/跟目录运行系统函数。 -s 后面的 320*170 为所要截取的图片的大小,单位为像素。

如果系统函数不能运行,先输出$str 字符串,在cmd命令行窗口 直接运行。

另外如果需要 ffmpeg.exe 这个 文件,可以邮箱找我 。
        //-i:输入文件名  
            //-r:设定帧 此处设为1帧  
       // -y:覆盖 //-f:设定输出格式 //-ss 从指定时间截图
       //-s 图片宽高比例 //-vframes 设置转换多少桢(frame)的视频 //-an 不处理声音 ,用不到
其他参数自己百度搜下,这里只是用到的参数。

$str="d:/php/ffmpeg -ss 1 -i D:\www\public\content\video\20180803/df4da985a22d053070f4df478feb01aa.mp4  -y  -f mjpeg  -vframes 1 -s 320x170 D:\www\public\content\video\20180803/df4da985a22d053070f4df478feb01aa.png"

猜你喜欢

转载自www.cnblogs.com/dongmodify/p/9441917.html
8.5