From: Aleksey Filippov Date: Tue, 24 Feb 2026 21:50:37 +0000 (+0300) Subject: Изменение формирования списка файлов на удаление до одного месяца. Старше одного... X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=4c3a864963b718e36eb7848fb1d1858a7c248b2a;p=erp24_rep%2Fyii-erp24%2F.git Изменение формирования списка файлов на удаление до одного месяца. Старше одного месяца файлы удаляются. --- diff --git a/erp24/commands/ConvertVideoController.php b/erp24/commands/ConvertVideoController.php index 4763489c..7c7ce17d 100644 --- a/erp24/commands/ConvertVideoController.php +++ b/erp24/commands/ConvertVideoController.php @@ -182,19 +182,22 @@ class ConvertVideoController extends Controller continue; } - // Конвертация + // Конвертация (вывод в лог-файл, чтобы не переполнять буфер exec) + $logFile = Yii::getAlias('@runtime') . '/ffmpeg_last.log'; $cmd = sprintf( - 'nice -n 19 timeout 600 ffmpeg -y -i %s -c:v libx264 -preset fast -crf 23 -c:a aac -movflags +faststart %s 2>&1', + 'nice -n 19 timeout 1800 ffmpeg -y -i %s -c:v libx264 -preset fast -crf 23 -c:a aac -movflags +faststart %s >%s 2>&1', escapeshellarg($sourcePath), - escapeshellarg($mp4Path) + escapeshellarg($mp4Path), + escapeshellarg($logFile) ); $startTime = microtime(true); - exec($cmd, $cmdOutput, $returnCode); + $returnCode = 0; + system($cmd, $returnCode); $elapsed = round(microtime(true) - $startTime, 1); if ($returnCode !== 0 || !file_exists($mp4Path)) { - $error = implode("\n", array_slice($cmdOutput, -5)); + $error = is_file($logFile) ? implode("\n", array_slice(file($logFile, FILE_IGNORE_NEW_LINES), -5)) : ''; $this->stderr(" — ОШИБКА ({$elapsed}s, code={$returnCode})\n"); Yii::error("ConvertVideo: ошибка #{$file->id}: {$error}", 'video'); if (file_exists($mp4Path)) { @@ -216,8 +219,6 @@ class ConvertVideoController extends Controller } } - $cmdOutput = []; - // Пауза между файлами if ($this->sleep > 0 && $i < $total - 1) { sleep($this->sleep);