How do I generate images from a video?

1

I wonder if there is any way to generate images from a video, this video can be local or youtube.

Basically I have a video and I would like it through a routine "strip prints" of the video.

    
asked by anonymous 25.10.2016 / 20:29

1 answer

1

You need to install ffmpeg

Once installed, use the code below.

<?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.'">';
    }
}
?>

Follow this link to better understand the use of ffmpeg

    
25.10.2016 / 20:40