Skip to content

Commit 38e90cc

Browse files
committed
Dynamically calculate --sc-downscale-height
1 parent 747bb4a commit 38e90cc

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

ff-utils-winforms/UI/Tasks/Av1an.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static async Task Run(bool resume = false, string overrideTempDir = "", s
7373
string c = GetConcatMethod();
7474
string thr = Program.mainForm.av1anThreadsUpDown.Value.ToString();
7575

76-
args = $"-i {inPath.Wrap()} -y --verbose --log-level debug --keep --split-method {s} -m {m} -c {c} --set-thread-affinity {thr} --sc-downscale-height 900 {cust} {v} -f \" {vf} \" -a \" {a} \" -w {w} -o {outPath.Wrap()}";
76+
args = $"-i {inPath.Wrap()} -y --verbose --log-level debug --keep --split-method {s} -m {m} -c {c} --set-thread-affinity {thr} {GetScDownscaleArg()} {cust} {v} -f \" {vf} \" -a \" {a} \" -w {w} -o {outPath.Wrap()}";
7777

7878
if (vmaf)
7979
{
@@ -150,6 +150,24 @@ public static async Task Run(bool resume = false, string overrideTempDir = "", s
150150
Program.mainForm.SetWorking(false);
151151
}
152152

153+
private static string GetScDownscaleArg ()
154+
{
155+
if (TrackList.current.File == null || TrackList.current.File.VideoStreams.Count < 1)
156+
return "";
157+
158+
int h = TrackList.current.File.VideoStreams[0].Resolution.Height;
159+
float mult = 1f;
160+
161+
if (h >= 720) mult = 0.7500f;
162+
if (h >= 900) mult = 0.7083f;
163+
if (h >= 1080) mult = 0.6667f;
164+
if (h >= 1440) mult = 0.5000f;
165+
if (h >= 2160) mult = 0.4166f;
166+
if (h >= 4320) mult = 0.3333f;
167+
168+
return $"--sc-downscale-height {(h * mult).RoundToInt().Clamp(360, 2160)}"; // Apply multiplicator but clamp to sane values
169+
}
170+
153171
private static void SaveJson(string inputFilePath, string tempFolderName, string args, string creationTimestamp, string lastRunTimestamp)
154172
{
155173
try

0 commit comments

Comments
 (0)