From 0c3c22703460f30e9f2bce5c898c816205c6fb17 Mon Sep 17 00:00:00 2001 From: Daniel Neto Date: Mon, 20 Jan 2025 14:12:52 -0300 Subject: [PATCH] https://github.com/WWBN/AVideo/issues/9817#issuecomment-2599133126 --- objects/MP4Processor.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/objects/MP4Processor.php b/objects/MP4Processor.php index 38ecd43b..a115f374 100644 --- a/objects/MP4Processor.php +++ b/objects/MP4Processor.php @@ -10,8 +10,14 @@ public static function createMP4MaxResolutionFromQueueId($pathFileName, $encoder if($inputResolution> $maxResolution){ $inputResolution = $maxResolution; } - $destinationFile = Encoder::getTmpFileName($encoder_queue_id, 'mp4', $inputResolution); - return self::createMP4($pathFileName, $destinationFile, $encoder_queue_id, $inputResolution); + // Get allowed resolutions from Format::ENCODING_SETTINGS + $allowedResolutions = array_keys(Format::ENCODING_SETTINGS); + // Determine the target resolution + $targetResolution = self::getClosestResolution($inputResolution, $allowedResolutions); + + $destinationFile = Encoder::getTmpFileName($encoder_queue_id, 'mp4', $targetResolution); + _error_log("MP4Processor::createMP4MaxResolutionFromQueueId [$pathFileName, $encoder_queue_id, $maxResolution ] [{$inputResolution}p] => [{$targetResolution}p] $destinationFile"); + return self::createMP4($pathFileName, $destinationFile, $encoder_queue_id, $targetResolution); } public static function createMP4MaxResolution($pathFileName, $destinationFile, $maxResolution = 1080){