Ben FFMPEG ve FFMPEG-PHP uzantısı kullanarak bir film rastgele noktalarda gelen küçük oluşturmak için çalışıyorum.
My script works OK.. however takes 20 minutes just to generate 5-10 thumbnails!!
Komut daha sonra kare sayılar olarak kullanılan rastgele sayılar üreterek çalışır. Üretilen tüm sayılar filmler kare sayısı vardır.
Can you work out why this script is taking 20 mins to finish? If not, a better solution?
<?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
// If it does, place the frame number inside an array and break the current loop
if($getframe){
$frames[$frame] = $getframe ;
$i++;
}
}
//For each frame found generate a thumbnail
foreach ($frames as $key => $getframe) {
$gd_image = $getframe->toGDImage();
imagejpeg($gd_image, "images/shot_".$key.'.jpeg');
imagedestroy($gd_image);
echo $key.'<br/>';
}
?>
Komut geçerli çerçeve numaralarını getirici OLMALIDIR? BAŞLANGIÇ içinde bir şey - SONUNDA geçerli çerçeve numaraları olmalıdır? Yine döngü yaşları alır!