/** * Extract file meta data * * @param File $file file instance * @return Meta */ protected function extractInformation(File $file) { $meta = new Meta(); $meta->id = $file->getId(); $meta->originId = $file->getOriginId(false); $tmpPathname = $this->temp->getTempPathname(); $this->temp->createFile($tmpPathname, $this->storage->read($file)); $info = $this->reader->analyze($tmpPathname); $this->temp->remove($tmpPathname); if (isset($info['audio']['streams'])) { unset($info['audio']['streams']); } $meta->audio = $info['audio']; $meta->playtime = $info['playtime_seconds']; $meta->bitrate = $info['bitrate']; return $meta; }
/** * 영상에서 snapshot 추출 * * @param string $content media content * @param int $fromSecond 영상에서의 시간(초 단위) * @return string */ public function getSnapshot($content, $fromSecond = 10) { $tmpPathname = $this->temp->getTempPathname(); $tmpImgPathname = $this->temp->getTempPathname(); $this->temp->createFile($tmpPathname, $content); $video = $this->ffmpeg->open($tmpPathname); $video->frame(TimeCode::fromSeconds($fromSecond))->save($tmpImgPathname); $imageContent = file_get_contents($tmpImgPathname); $this->temp->remove($tmpPathname); $this->temp->remove($tmpImgPathname); return $imageContent; }