php-如何在没有ffmpeg的情况下制作视频缩略图

php-如何在没有ffmpeg的情况下制作视频缩略图,php,ffmpeg,Php,Ffmpeg,我正在使用php(Phalcon框架) 我尝试使用ffmpeg来实现这一点,但它花费了太多的时间 我需要一个缩略图作为屏幕截图从视频 是否有其他解决方案(仅PHP) 这是我的代码: // where ffmpeg is located, such as /usr/sbin/ffmpeg $ffmpeg = '/usr/bin/ffmpeg'; // the input video file $video = BASE_PATH . "/public/uploa

我正在使用php(Phalcon框架)

我尝试使用ffmpeg来实现这一点,但它花费了太多的时间

我需要一个缩略图作为屏幕截图从视频

是否有其他解决方案(仅PHP)

这是我的代码:

    // where ffmpeg is located, such as /usr/sbin/ffmpeg
    $ffmpeg = '/usr/bin/ffmpeg';

    // the input video file
    $video  = BASE_PATH . "/public/uploads/video/" . $fileName;

    // where you'll save the image
    $image  = BASE_PATH . "/public/uploads/image/" . "thumbnail-".$fileName .".jpg";

    // default time to get the image
    $second = 1;

    // get the duration and a random place within that
    $cmd = "$ffmpeg -i $video 2>&1";
    if (preg_match('/Duration: ((\d+):(\d+):(\d+))/s', `$cmd`, $time)) {
        $total = ($time[2] * 3600) + ($time[3] * 60) + $time[4];
        $second = rand(1, ($total - 1));
    }

    // get the screenshot
    $cmd = "$ffmpeg -i $video -deinterlace -an -ss $second -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg $image 2>&1";
    `$cmd`;

@user3783243我在主题中添加了代码。你是对的,但它花费太多。@user3783243不,它工作正常,没有任何错误。已成功生成缩略图。但是在很长一段时间内(大约两个月),哦,所以你在寻找更好的表现,而不仅仅是一些可以完成工作的东西。这是很重要的补充。这个文件有多大?您已经验证了时间延迟在
`$cmd`