fix(transcode): match target long sides exactly and dynamic resolution mapping

This commit is contained in:
yiling
2026-05-30 14:21:55 +08:00
parent 5073651721
commit 5a60e175b1
2 changed files with 20 additions and 6 deletions
+5 -2
View File
@@ -265,9 +265,12 @@ const TARGET_RESOLUTIONS = [
{ name: '360p', longSide: 640 },
]
function getBestMatchResolution(originalWidth: number, originalHeight: number): { name: string; longSide: number } {
function getBestMatchResolution(
originalWidth: number,
originalHeight: number,
): { name: string; longSide: number } {
const rawLongSide = Math.max(originalWidth, originalHeight)
const lower = TARGET_RESOLUTIONS.filter((r) => r.longSide < rawLongSide)
const lower = TARGET_RESOLUTIONS.filter((r) => r.longSide <= rawLongSide)
if (lower.length > 0) {
lower.sort((a, b) => b.longSide - a.longSide)
return lower[0]