Jump to content

Create Thumbnail from video


papaface

Recommended Posts

  • 2 years later...

The original thread was started and not answered some time ago,,, so...

since I actually surfed in here looking for a similar question...

Maybe this will help some one.

 

This is how you do it with ffmpeg and php:

 

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!)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.