mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-22 23:28:43 +00:00
fix(transcode): match target long sides exactly and dynamic resolution mapping
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user