Create Thumbnail from video

Started on the old forum in January 2011 · view the original in the archive · old links redirect here

No replies · 527 views · started 15 years ago · 1 min read

subzero Super moderator Fellow · 3,954 posts #1
function makeThumbnails($dir){
   if (is_dir($dir))
   {
      if ($dh = opendir($dir))
      {
         while (($file = readdir($dh)) !== false)         
         {
            if($file != "." && $file != ".." && eregi(".mp4", $file))
            {
               $file='/'.$file;
               $command = "ffmpeg -i " . $dir . $file . " -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 -ss 00:00:10 " .  $dir . str_replace(".mp4", ".jpg", $file) ;
               return exec("$command");
            }//end if
         }//end while
      closedir($dh);
      }//end if handle $dh
   }//end if dir
   return TRUE;
}//end function makeThumnails()

This of course will make a 320x240 jpg from a mp4 file from the frame 10sec into the movie ffmpeg is quite powerful it will use pretty much any video container/codec, just change those parts.

(oh yeah the function returns a boolean and the while loop means it keeps doing it while there is another movie in the dir to make a thumbnail for! I guess that's pretty obvious. If you take the "command" out and run it in a terminal with the variables $dir and $file changed to indicate the movie, etc. it will just make one!)

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close