Natasha
Natasha

Reputation: 980

How to create thumb image while uploading video

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..

Upvotes: 0

Views: 3097

Answers (2)

jous
jous

Reputation: 845

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);
}

Upvotes: 0

tetuje
tetuje

Reputation: 289

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

Upvotes: 1

Related Questions