The script below should generate a thumbnail from the middle of the video, however, it instead creates thumbnails from seemingly random frames of the video.
Furthermore, depending on the video, the following PHP error sometimes occurs:
"Fatal error: Call to a member function toGDImage() on a non-object..."
Any ideas?
PHP Code:
<?php
$media = new ffmpeg_movie('video.mp4');
$frame_count = $media->getFrameCount();
$frame = $media->getFrame(round($frame_count / 2));
$thumbnail_image = $frame->toGDImage();
header('Content-type: image/jpeg');
imagejpeg($thumbnail_image);
?>
Bookmarks