|
|
@ -15,13 +15,36 @@ class QueuedFfmpegService { |
|
|
|
|
|
|
|
|
private $ffmpegService; |
|
|
private $ffmpegService; |
|
|
|
|
|
|
|
|
|
|
|
private $fileService; |
|
|
|
|
|
|
|
|
|
|
|
private $destinationDirectory; |
|
|
|
|
|
|
|
|
public function __construct() |
|
|
public function __construct() |
|
|
{ |
|
|
{ |
|
|
$this->ffmpegService = new FfmpegService(); |
|
|
$this->ffmpegService = new FfmpegService(); |
|
|
$this->ffmpegService->setNeedRemoveAfterEncode(true); |
|
|
$this->ffmpegService->setNeedRemoveAfterEncode(true); |
|
|
$this->ffmpegService->setNeedRemoveExistFiles(false); |
|
|
$this->ffmpegService->setNeedRemoveExistFiles(false); |
|
|
|
|
|
$this->fileService = new FileService(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @return mixed |
|
|
|
|
|
*/ |
|
|
|
|
|
public function getDestinationDirectory() |
|
|
|
|
|
{ |
|
|
|
|
|
return $this->destinationDirectory; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param mixed $destinationDirectory |
|
|
|
|
|
*/ |
|
|
|
|
|
public function setDestinationDirectory($destinationDirectory): void |
|
|
|
|
|
{ |
|
|
|
|
|
$this->destinationDirectory = $destinationDirectory; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function processDir($path) |
|
|
public function processDir($path) |
|
|
{ |
|
|
{ |
|
|
$files = scandir($path); |
|
|
$files = scandir($path); |
|
|
@ -43,7 +66,7 @@ class QueuedFfmpegService { |
|
|
{ |
|
|
{ |
|
|
// BilibiliEncode::dispatch($file);
|
|
|
// BilibiliEncode::dispatch($file);
|
|
|
Log::info("add $file to ffmpeg process queue"); |
|
|
Log::info("add $file to ffmpeg process queue"); |
|
|
Redis::connection()->rpush("file_to_encode", $file); |
|
|
|
|
|
|
|
|
Redis::connection()->lpush("file_to_encode", $file); |
|
|
// $result = Redis::publish("file_to_process", $file);
|
|
|
// $result = Redis::publish("file_to_process", $file);
|
|
|
// echo $result;
|
|
|
// echo $result;
|
|
|
} |
|
|
} |
|
|
@ -57,8 +80,10 @@ class QueuedFfmpegService { |
|
|
while ($item != null) { |
|
|
while ($item != null) { |
|
|
echo $item . "\n"; |
|
|
echo $item . "\n"; |
|
|
$empty = false; |
|
|
$empty = false; |
|
|
$item = Redis::connection()->rpop("file_to_encode"); |
|
|
|
|
|
$this->ffmpegService->processVideo($item); |
|
|
$this->ffmpegService->processVideo($item); |
|
|
|
|
|
$this->fileService->mvFile($item, $this->getDestinationDirectory()); |
|
|
|
|
|
$item = Redis::connection()->rpop("file_to_encode"); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
if ($empty) { |
|
|
if ($empty) { |
|
|
Log::info("process end sleep 300 seconds"); |
|
|
Log::info("process end sleep 300 seconds"); |
|
|
|