加入收藏 | 设为首页 | 会员中心 | 我要投稿 网站开发网_安阳站长网 (https://www.0518zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

PHP调用ffmpeg对视频截图并拼接脚本

发布时间:2021-04-03 04:02:07 所属栏目:站长百科 来源:网络整理
导读:副标题#e# PHP脚本调用ffmpeg对视频截图并拼接,供大家参考,具体内容如下 目前支持MKV,MPG,MP4等常见格式的视频,其他格式有待测试 12P 一张截图平均生成时间 1.64s 100个视频,大概需要2分半左右 9P 一张截图平均生成时间 1.13s 100个视频,大概需要2分钟

imagettftext($image,32,100,2000+30,"FZLTHJW.ttf","FileName:".basename($videoInfo["file"]));
imagettftext($image,1600,"Size:".$videoInfo["width"]."x".$videoInfo["height"]);
imagettftext($image,2000+120,"Duration:".$videoInfo["duration"]);
imagettftext($image,"Bitrate:".$videoInfo["bitrate"]);
return $image;
}

/**

  • 屏幕截图
    */
    public function getScreenShoot($fileName)
    {
    $fi = pathinfo($fileName);
    $this->videoInfo = $this->getVideoInfo($this->rootdir.DS.$this->source.DS.$fileName);
    if($this->videoInfo)
    {
    $this->setShootSecends($this->videoInfo["secends"]);

    for ($i=0; $i< count($this->timeArray); $i++ )
    {
    $cmd=".".DS."ffmpeg -ss ". $this->timeArray[$i] ." -i ". $this->rootdir.DS.$this->source.DS.$fileName ." -y -f image2 -s 720*480 -vframes 1 ".$this->rootdir.DS.$this->fileArray[$i];
    exec($cmd,$out,$status);
    }
    $this->getFixedPhoto($fileName);

    $str = sprintf("[%s]:OK...........[%s][%2dP]%-30sn",date("y-m-d h:i:s",time()),$this->videoInfo["duration"],count($this->timeArray),$fileName);
    file_put_contents("log.txt",FILE_APPEND);
    $this->successCount += 1;
    }else
    {
    $str = sprintf("[%s]:FAILED.................................[%s][%2dP]%-30sn",FILE_APPEND);
    $this->failedCount += 1;
    }
    }

(编辑:网站开发网_安阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!