public function getVideoCover($file_info, $time, $dir_video, $size, $dir)
{
try {
$time = $time ? $time : 8; //默认截取第一秒第一帧
$size = $size ? $size : '450*300';
$fileName = $file_info['md5'];
//临时视频路径,生成截图后删除
// $tempfiles = $dir.$fileName.'.mp4';
// $bool = move_uploaded_file($file, $tempfiles);
$file_path = $file_info['realpath'];
//视频完整路径
$video_complete_path = $dir_video . $fileName . '.jpg';
$str = "ffmpeg -i " . $file_path . " -y -f image2 -ss " . $time . " -t 0.001 -s $size " . $dir_video . $fileName . '.jpg';
exec("/usr/local/ffmpeg/bin/" . $str, $out, $status);
if ($status == 0) {
qCloudCosUpload('/uploads/' . $dir . '/' . pathinfo($file_info['savename'], PATHINFO_DIRNAME) . '/', $fileName . '.jpg', $video_complete_path);
if (file_exists($video_complete_path)) {
unlink($video_complete_path);
}
}
// exec("/usr/local/ffmpeg/bin/".$str.'ls 2>&1',$out,$status);
return '/uploads/' . $dir . '/' . pathinfo($file_info['savename'], PATHINFO_DIRNAME) . '/' . $fileName . '.jpg';
} catch (ReturnException $e) {
return $e->returnMessage();
} catch (\Throwable $e) {
Helper::logError('getVideoCover: ' . $e->getMessage(), $e->getTrace());
return Messages::errorMsg(MessagesContent::EXCEPTION);
}
}