0

How to a create thumb image while uploading a video, am using the following code

if ((!empty($vdo))) {
    $ext1 = explode('.', $_FILES['tut_video']['name']);
    $vname = "T_" . $ext1['0'] . '.' . $ext1['1'];
    $vdo_name1 = "../images/tut_vid/" . basename($vname);
    move_uploaded_file($_FILES['tut_video']['tmp_name'], $vdo_name1);
    $vdo_name1c = "../images/tut_vid/" . basename($vname);
    $vdopath_old1 = "../" . $vdo_name1;
}

please help..

Natasha
  • 980
  • 4
  • 16
  • 33
  • which video is this ? I think you need to use some Video library package to extract the images from video. Try using ffmpeg. http://stackoverflow.com/questions/4983327/ffmpegx-extract-frames-from-video – Arfeen Mar 06 '12 at 11:06
  • Nice searching... http://stackoverflow.com/questions/9053048/need-to-create-thumbnail-for-video-uploading-very-simple-code – MakuraYami Mar 06 '12 at 11:07

2 Answers2

1

You need some tool like ffmpeg for creating thumb images from a video, use :

ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240

( http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/ )

tetuje
  • 279
  • 3
  • 9
0

Depends on the platform you're on, but on linux the answer usually revolves around ffmpeg:

Btw, your extension checking does not handle well files with multiple dots in them. This does:

$in_filename = $_FILES['tut_video']['name'];

$pos = strrpos($in_filename, '.');

$ext1 = '';
if ($pos !== false) {
  $ext1 = substr($in_filename, $pos + 1);
}
Community
  • 1
  • 1
jous
  • 835
  • 7
  • 20