]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Изменение формирования списка файлов на удаление до одного месяца. Старше одного...
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Tue, 24 Feb 2026 21:50:37 +0000 (00:50 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Tue, 24 Feb 2026 21:50:37 +0000 (00:50 +0300)
erp24/commands/ConvertVideoController.php

index 4763489c4ac0db7d40eb0dddaab6498d43e4448d..7c7ce17dd2b0d3b826c553b5c5fc2452f4b2ee57 100644 (file)
@@ -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);