/** * Create screenshot from uploaded video * @param \App\Models\Video $video The object we created * @return boolean Always true */ private function capture(\App\Models\Video $video) { //that's easier $video_path = public_path('/videos/' . $video->video); //find duration $ffprobe = \FFMpeg\FFProbe::create(); $duration = $ffprobe->format($video_path)->get('duration'); //take the shot $ffmpeg = \FFMpeg\FFMpeg::create(); $capture = $ffmpeg->open($video_path); $capture->frame(\FFMpeg\Coordinate\TimeCode::fromSeconds($duration > 5 ? 5 : (int) ($duration / 2)))->save(public_path('/previews/' . $video->getKey() . '.jpg')); return true; }