zoukankan      html  css  js  c++  java
  • 关于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:HwsHostMasterphpwebphp56"; 
    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 不处理声音 ,用不到
    其他参数自己百度搜下,这里只是用到的参数。
  • 相关阅读:
    ros 录制
    shell 截取字符串
    Linux 关机
    shell获取字符串长度
    ubuntu14.04 设置开机自启动脚本
    获取本机ip的shell脚本
    shell 杀掉指定进程的服务
    html 绘制矩形轨迹,选中区域
    shell模拟ctrl c停止
    shell 字符串提取数字
  • 原文地址:https://www.cnblogs.com/dongmodify/p/9441917.html
Copyright © 2011-2022 走看看