From 5833c2db2ca05ed0b1ec9149a1d9eb19485b5bcd Mon Sep 17 00:00:00 2001 From: Daniel Neto Date: Thu, 16 Jan 2025 16:07:41 -0300 Subject: [PATCH] https://github.com/WWBN/AVideo/issues/9813#issuecomment-2594381098 --- objects/Format.php | 15 +++++++++++---- objects/HLSProcessor.php | 2 -- objects/MP4Processor.php | 10 +++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/objects/Format.php b/objects/Format.php index 14661510..0ce621c8 100644 --- a/objects/Format.php +++ b/objects/Format.php @@ -1,6 +1,8 @@ singleResolution->value)){ + _error_log("AVideo-Encoder Format::exec line=" . __LINE__); + if (!empty($advancedCustom->singleResolution->value)) { + _error_log("AVideo-Encoder Format::exec MP4Processor::createMP4MaxResolutionFromQueueId($pathFileName, $encoder_queue_id, {$advancedCustom->singleResolution->value})"); return MP4Processor::createMP4MaxResolutionFromQueueId($pathFileName, $encoder_queue_id, $advancedCustom->singleResolution->value); - }else{ + } else { + _error_log("AVideo-Encoder Format::exec line=" . __LINE__); $fc = self::getDynamicCommandFromMP4($pathFileName, $encoder_queue_id); } } elseif ($format_id == 32) { // it is WebM diff --git a/objects/HLSProcessor.php b/objects/HLSProcessor.php index 1cacf91d..87e2ee6d 100644 --- a/objects/HLSProcessor.php +++ b/objects/HLSProcessor.php @@ -9,7 +9,6 @@ static function createMP3AndPM4IfNeed($pathFileName, $destinationFile){ $advancedCustom = getAdvancedCustomizedObjectData(); //_error_log('createMP3AndPM4IfNeed '.json_encode($advancedCustom)); if($advancedCustom->autoConvertToMp4){ - require_once __DIR__.'/MP4Processor.php'; try { MP4Processor::createMP4($pathFileName, $destinationFile.'index.mp4'); } catch (Exception $e) { @@ -18,7 +17,6 @@ static function createMP3AndPM4IfNeed($pathFileName, $destinationFile){ } if($advancedCustom->autoConvertVideosToMP3){ - require_once __DIR__.'/MP3Processor.php'; // Usage example try { MP3Processor::createMP3($pathFileName, $destinationFile.'index.mp3'); diff --git a/objects/MP4Processor.php b/objects/MP4Processor.php index 554e4c4c..38ecd43b 100644 --- a/objects/MP4Processor.php +++ b/objects/MP4Processor.php @@ -4,6 +4,8 @@ class MP4Processor { public static function createMP4MaxResolutionFromQueueId($pathFileName, $encoder_queue_id, $maxResolution = 1080){ + _error_log("MP4Processor::createMP4MaxResolutionFromQueueId [$pathFileName, $encoder_queue_id, $maxResolution ] "); + $inputResolution = self::getResolution($pathFileName); if($inputResolution> $maxResolution){ $inputResolution = $maxResolution; @@ -23,6 +25,7 @@ public static function createMP4MaxResolution($pathFileName, $destinationFile, $ public static function createMP4($pathFileName, $destinationFile, $encoder_queue_id = 0, $inputResolution = null) { + _error_log("MP4Processor::createMP4 [$pathFileName, $destinationFile, $encoder_queue_id, $inputResolution ] "); global $global; // Get allowed resolutions from Format::ENCODING_SETTINGS $allowedResolutions = array_keys(Format::ENCODING_SETTINGS); @@ -52,7 +55,7 @@ public static function createMP4($pathFileName, $destinationFile, $encoder_queue if(!empty($encoder_queue_id)){ $progressFile = "{$global['systemRootPath']}videos/{$encoder_queue_id}_tmpFile_progress.txt"; - $command = "{$command} > 1 $progressFile 2>&1"; + $command = "{$command} 1> $progressFile 2>&1"; } // Execute the FFmpeg command @@ -60,8 +63,9 @@ public static function createMP4($pathFileName, $destinationFile, $encoder_queue exec($command, $output, $resultCode); if ($resultCode !== 0) { - _error_log("MP4Processor: FFmpeg failed with output: " . json_encode($output)); - throw new Exception("Failed to create MP4 file."); + _error_log("MP4Processor: FFmpeg failed with output: $resultCode $command" . json_encode($output)); + var_dump($resultCode, $output, $command); + throw new Exception("Failed to create MP4 file. $resultCode $command " . json_encode($output)); } _error_log("MP4Processor: MP4 file created successfully at $destinationFile");