Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerating random thumbnails with PHP+FFMPEG
    primarykey
    data
    text
    <p>I'm trying to generate thumbnails from random points in a movie using FFMPEG and FFMPEG-PHP extension.</p> <p><strong>My script works OK.. however takes 20 minutes just to generate 5-10 thumbnails!!</strong></p> <p>The script works by generating random numbers which are used as frame numbers later. All numbers generated are within the movies frame count. </p> <p>Can you work out why this script is taking 20 mins to finish? If not, a better solution?</p> <pre><code>&lt;?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-&gt;getFrameCount(); //Loop 5-10 times to generate random frames 5-10 times for ($i = 1; $i &lt;= 5; ) { // Generate a number within 200 and the total number of frames. $frame = mt_rand(200,$total_frames); $getframe = $mov-&gt;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 =&gt; $getframe) { $gd_image = $getframe-&gt;toGDImage(); imagejpeg($gd_image, "images/shot_".$key.'.jpeg'); imagedestroy($gd_image); echo $key.'&lt;br/&gt;'; } ?&gt; </code></pre> <p>The script SHOULD be generating frame numbers which are valid? Anything within START - END should be valid frame numbers? Yet the loop takes ages!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload