|
@@ -4550,6 +4550,13 @@ function upgrade480pTo720p($videoSource, $prefix = 'video', $isContent = false)
|
|
|
$width = isset($matches[1]) ? (int)$matches[1] : 0;
|
|
$width = isset($matches[1]) ? (int)$matches[1] : 0;
|
|
|
$height = isset($matches[2]) ? (int)$matches[2] : 0;
|
|
$height = isset($matches[2]) ? (int)$matches[2] : 0;
|
|
|
|
|
|
|
|
|
|
+ dLog('video_upgrade')->info('FFmpeg探测结果', [
|
|
|
|
|
+ 'probe_output' => substr($probeOutput, 0, 500),
|
|
|
|
|
+ 'matches' => $matches,
|
|
|
|
|
+ 'width' => $width,
|
|
|
|
|
+ 'height' => $height
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
// 根据视频方向决定缩放参数,确保短边达到720
|
|
// 根据视频方向决定缩放参数,确保短边达到720
|
|
|
// 计算缩放比例,使短边至少为720
|
|
// 计算缩放比例,使短边至少为720
|
|
|
if ($width > 0 && $height > 0) {
|
|
if ($width > 0 && $height > 0) {
|
|
@@ -4566,19 +4573,31 @@ function upgrade480pTo720p($videoSource, $prefix = 'video', $isContent = false)
|
|
|
$targetLongSide += 1;
|
|
$targetLongSide += 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ dLog('video_upgrade')->info('缩放计算详情', [
|
|
|
|
|
+ 'original' => "{$width}x{$height}",
|
|
|
|
|
+ 'short_side' => $shortSide,
|
|
|
|
|
+ 'long_side' => $longSide,
|
|
|
|
|
+ 'scale_ratio' => $scale,
|
|
|
|
|
+ 'target_short' => $targetShortSide,
|
|
|
|
|
+ 'target_long' => $targetLongSide,
|
|
|
|
|
+ 'is_portrait' => $width < $height ? 'yes' : 'no'
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
if ($width < $height) {
|
|
if ($width < $height) {
|
|
|
// 竖屏:宽度是短边
|
|
// 竖屏:宽度是短边
|
|
|
$scaleFilter = "scale={$targetShortSide}:{$targetLongSide}:flags=lanczos";
|
|
$scaleFilter = "scale={$targetShortSide}:{$targetLongSide}:flags=lanczos";
|
|
|
dLog('video_upgrade')->info('检测到竖屏视频,短边(宽)设为720', [
|
|
dLog('video_upgrade')->info('检测到竖屏视频,短边(宽)设为720', [
|
|
|
'original_size' => "{$width}x{$height}",
|
|
'original_size' => "{$width}x{$height}",
|
|
|
- 'target_size' => "{$targetShortSide}x{$targetLongSide}"
|
|
|
|
|
|
|
+ 'target_size' => "{$targetShortSide}x{$targetLongSide}",
|
|
|
|
|
+ 'scale_filter' => $scaleFilter
|
|
|
]);
|
|
]);
|
|
|
} else {
|
|
} else {
|
|
|
// 横屏:高度是短边
|
|
// 横屏:高度是短边
|
|
|
$scaleFilter = "scale={$targetLongSide}:{$targetShortSide}:flags=lanczos";
|
|
$scaleFilter = "scale={$targetLongSide}:{$targetShortSide}:flags=lanczos";
|
|
|
dLog('video_upgrade')->info('检测到横屏视频,短边(高)设为720', [
|
|
dLog('video_upgrade')->info('检测到横屏视频,短边(高)设为720', [
|
|
|
'original_size' => "{$width}x{$height}",
|
|
'original_size' => "{$width}x{$height}",
|
|
|
- 'target_size' => "{$targetLongSide}x{$targetShortSide}"
|
|
|
|
|
|
|
+ 'target_size' => "{$targetLongSide}x{$targetShortSide}",
|
|
|
|
|
+ 'scale_filter' => $scaleFilter
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
@@ -4641,6 +4660,18 @@ function upgrade480pTo720p($videoSource, $prefix = 'video', $isContent = false)
|
|
|
|
|
|
|
|
chmod($outputFile, 0664);
|
|
chmod($outputFile, 0664);
|
|
|
|
|
|
|
|
|
|
+ // 验证输出视频的分辨率
|
|
|
|
|
+ $verifyCmd = "$ffmpegPath -i \"$outputFile\" 2>&1";
|
|
|
|
|
+ $verifyOutput = shell_exec($verifyCmd);
|
|
|
|
|
+ preg_match('/Stream.*Video.*?(\d+)x(\d+)/', $verifyOutput, $verifyMatches);
|
|
|
|
|
+ $outputWidth = isset($verifyMatches[1]) ? (int)$verifyMatches[1] : 0;
|
|
|
|
|
+ $outputHeight = isset($verifyMatches[2]) ? (int)$verifyMatches[2] : 0;
|
|
|
|
|
+
|
|
|
|
|
+ dLog('video_upgrade')->info('输出视频分辨率验证', [
|
|
|
|
|
+ 'expected' => isset($targetShortSide) ? ($width < $height ? "{$targetShortSide}x{$targetLongSide}" : "{$targetLongSide}x{$targetShortSide}") : '未知',
|
|
|
|
|
+ 'actual' => "{$outputWidth}x{$outputHeight}"
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
$outputFileSize = filesize($outputFile);
|
|
$outputFileSize = filesize($outputFile);
|
|
|
$sizeRatio = round($outputFileSize / $inputFileSize, 2);
|
|
$sizeRatio = round($outputFileSize / $inputFileSize, 2);
|
|
|
|
|
|