Browse Source

add sleep code

feature/new_bilibili_and_instagram_sxs20191126
shixuesen 2 years ago
parent
commit
498a928707
1 changed files with 18 additions and 6 deletions
  1. +18
    -6
      app/Services/FfmpegService.php

+ 18
- 6
app/Services/FfmpegService.php View File

@ -127,10 +127,14 @@ class FfmpegService
public function processVideo($pathFile) public function processVideo($pathFile)
{ {
while (date("H") >= 22 || date("H") < 8) {
Log::info("now is " . date("Y-m-d H:i:s") . " sleep 5 minutes");
sleep(5 * 60);
$slowFlag = false;
if (date("H") >= 22 || date("H") < 8) {
$slowFlag = true;
} }
// while () {
// Log::info("now is " . date("Y-m-d H:i:s") . " sleep 5 minutes");
// sleep(5 * 60);
// }
Log::info("current process pathFile " . $pathFile); Log::info("current process pathFile " . $pathFile);
try { try {
$mime = mime_content_type($pathFile); $mime = mime_content_type($pathFile);
@ -189,11 +193,19 @@ class FfmpegService
} }
dump("targetFile", [$targetFile]); dump("targetFile", [$targetFile]);
Log::info("process target file : $targetFile"); Log::info("process target file : $targetFile");
if (filesize($pathFile) > 10 * 1024 * 1024 * 1024 || $this->getDimension($pathFile)->getWidth() > 1920) {
if ($this->getDimension($pathFile)->getWidth() > 3840) {
// $result = shell_exec("/Users/shixuesen/Downloads/ffmpeg -threads 16 -i ". escapeshellarg($pathFile) ." -preset ultrafast -crf 25 -c:v libx265 -x265-params pools=8 -vtag hvc1 " . escapeshellarg($targetFile) . " && echo 'ok'"); // $result = shell_exec("/Users/shixuesen/Downloads/ffmpeg -threads 16 -i ". escapeshellarg($pathFile) ." -preset ultrafast -crf 25 -c:v libx265 -x265-params pools=8 -vtag hvc1 " . escapeshellarg($targetFile) . " && echo 'ok'");
$result = shell_exec("/Users/shixuesen/Downloads/ffmpeg -i ". escapeshellarg($pathFile) ." -c:v libx265 -x265-params pools=8 -vtag hvc1 -vf \"scale=4096:-1\" " . escapeshellarg($targetFile) . " && echo 'ok'");
if ($slowFlag) {
$result = shell_exec("/Users/shixuesen/Downloads/ffmpeg -i ". escapeshellarg($pathFile) ." -c:v libx265 -x265-params pools=2 -vtag hvc1 -vf \"scale=4096:-1\" " . escapeshellarg($targetFile) . " && echo 'ok'");
} else {
$result = shell_exec("/Users/shixuesen/Downloads/ffmpeg -i ". escapeshellarg($pathFile) ." -c:v libx265 -x265-params pools=8 -vtag hvc1 -vf \"scale=4096:-1\" " . escapeshellarg($targetFile) . " && echo 'ok'");
}
} else { } else {
$result = shell_exec("/Users/shixuesen/Downloads/ffmpeg -threads 16 -i ". escapeshellarg($pathFile) ." -preset fast -c:v libx265 -x265-params pools=8 -vtag hvc1 " . escapeshellarg($targetFile) . " && echo 'ok'");
if ($slowFlag) {
$result = shell_exec("/Users/shixuesen/Downloads/ffmpeg -threads 2 -i ". escapeshellarg($pathFile) ." -preset fast -c:v libx265 -x265-params pools=2 -vtag hvc1 " . escapeshellarg($targetFile) . " && echo 'ok'");
} else {
$result = shell_exec("/Users/shixuesen/Downloads/ffmpeg -threads 8 -i ". escapeshellarg($pathFile) ." -preset fast -c:v libx265 -x265-params pools=8 -vtag hvc1 " . escapeshellarg($targetFile) . " && echo 'ok'");
}
} }
// echo $result; // echo $result;
// return; // return;


Loading…
Cancel
Save