public function Html5::downloadThumbnail in Video Embed HTML5 8
File
- src/
Plugin/ video_embed_field/ Provider/ Html5.php, line 97
Class
- Html5
- A Html5 provider plugin.
Namespace
Drupal\video_embed_html5\Plugin\video_embed_field\ProviderCode
public function downloadThumbnail() {
if ($this->phpFFMpeg) {
$local_uri = $this
->getLocalThumbnailUri();
if (!file_exists($local_uri)) {
$this->fileSystem
->prepareDirectory($this->thumbsDirectory, FileSystemInterface::CREATE_DIRECTORY);
try {
// Thumb does not exist yet. Generate it.
$video = $this->phpFFMpeg
->open($this->videoUrl);
$video
->frame(TimeCode::fromSeconds(1))
->save($this->fileSystem
->realpath($this->thumbsDirectory) . '/' . $this->filename . '.jpg');
} catch (\Exception $e) {
}
}
}
}