小编MrG*_*ost的帖子

使用PHP + FFMPEG生成随机缩略图

我正在尝试使用FFMPEG和FFMPEG-PHP扩展从电影中的随机点生成缩略图.

我的脚本工作正常..但是需要20分钟才能生成5-10个缩略图!

该脚本通过生成随机数来工作,该随机数稍后用作帧编号.生成的所有数字都在电影帧数内.

你能弄清楚为什么这个剧本需要20分钟才能完成吗?如果没有,更好的解决方案?

<?php

//Dont' timeout
set_time_limit(0);

//Load the file (This can be any file - still takes ages) 
$mov = new ffmpeg_movie('1486460.mp4');

//Get the total frames within the movie
$total_frames = $mov->getFrameCount();

//Loop 5-10 times to generate random frames 5-10 times
for ($i = 1; $i <= 5; ) {
    // Generate a number within 200 and the total number of frames.
 $frame = mt_rand(200,$total_frames);
 $getframe = $mov->getFrame($frame);
 // Check if the frame exists within the movie
 // …
Run Code Online (Sandbox Code Playgroud)

php ffmpeg

6
推荐指数
1
解决办法
6775
查看次数

标签 统计

ffmpeg ×1

php ×1