Generate thumbnail video in php

Asked

Viewed 762 times

2

I wanted to take the thumbnail of a video after the video was uploaded on the site, I already searched a lot and only what I think is about ffmpeg and the "tutorials" basically tell you the commands (do not teach or how to install). Would have some other way than the ffmpeg?

1 answer

1


According to this reply in the English OS, you must install the FFMPEG. Once installed, just use the following code:

<?php

$frame = 10;
$movie = 'test.mp4';
$thumbnail = 'thumbnail.png';

$mov = new ffmpeg_movie($movie);
$frame = $mov->getFrame($frame);
if ($frame) {
    $gd_image = $frame->toGDImage();
    if ($gd_image) {
        imagepng($gd_image, $thumbnail);
        imagedestroy($gd_image);
        echo '<img src="'.$thumbnail.'">';
    }
}

?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.