ffmpeg生成视频封面图

时间:2019-10-23 15:31:49   收藏:0   阅读:511

ffmpeg 是一个视频处理软件

php-ffmpeg 是一个让 php 可以操作 ffmpeg 的 php插件,封装好了各种操作视频的名命令。直接调用对应的方法即可。

- 使用过程只需一条命令,几个参数即可
- 不仅可以对视频也可以对图片生成缩略图,传入的文件名是图片即生成图片的缩略图。
/**
     * 获取视频封面图片,与视频在相同文件夹下
     * @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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!