/** * Converts one frame of a video to an image using FFMPEG. * * @param string $content * * @return string * * @throws OriginalFileNotFoundException */ private function convertVideoToImage($content) { $temporaryFilePath = $this->createTemporaryFile($content); $this->videoThumbnail->generate($temporaryFilePath, '00:00:02:01', $temporaryFilePath); $extractedImage = file_get_contents($temporaryFilePath); unlink($temporaryFilePath); return $extractedImage; }
/** * get file from namespace. * * @param string $uri * @param string $mimeType * * @return string * * @throws OriginalFileNotFoundException */ protected function getFile($uri, $mimeType) { if (fnmatch('video/*', $mimeType)) { $tempFile = tempnam(sys_get_temp_dir(), 'media_original') . '.jpg'; $this->videoThumbnailService->generate($uri, '00:00:02:01', $tempFile); $uri = $tempFile; } $file = @file_get_contents($uri); if (!$file) { throw new OriginalFileNotFoundException($uri); } return $file; }