Skip to content

Commit 1b33195

Browse files
committed
av1an path checks, use -y instead of manually deleting output file before running
1 parent b5a7769 commit 1b33195

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public static async Task Run(bool resume = false, string overrideTempDir = "", s
4949
Program.mainForm.SetWorking(true);
5050
string args = "";
5151
string inPath = "";
52+
string outPath = "";
5253
string timestamp = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString();
5354

5455
try
@@ -59,7 +60,7 @@ public static async Task Run(bool resume = false, string overrideTempDir = "", s
5960
CodecUtils.AudioCodec aCodec = GetCurrentCodecA();
6061
bool vmaf = IsUsingVmaf();
6162
inPath = TrackList.current.File.ImportPath;
62-
string outPath = GetOutPath();
63+
outPath = GetOutPath();
6364
string cust = Program.mainForm.av1anCustomArgsBox.Text.Trim();
6465
string custEnc = Program.mainForm.av1anCustomEncArgsBox.Text.Trim();
6566
CodecArgs codecArgs = CodecUtils.GetCodec(vCodec).GetArgs(GetVideoArgsFromUi(), TrackList.current.File, Data.Codecs.Pass.OneOfOne);
@@ -71,21 +72,31 @@ public static async Task Run(bool resume = false, string overrideTempDir = "", s
7172
string m = GetChunkGenMethod();
7273
string c = GetConcatMethod();
7374

74-
args = $"-i {inPath.Wrap()} --verbose --keep --split-method {s} -m {m} -c {c} {cust} {v} -f \" {vf} \" -a \" {a} \" -w {w} -o {outPath.Wrap()}";
75+
args = $"-i {inPath.Wrap()} -y --log-level debug --verbose --keep --split-method {s} -m {m} -c {c} {cust} {v} -f \" {vf} \" -a \" {a} \" -w {w} -o {outPath.Wrap()}";
7576

7677
if (vmaf)
7778
{
7879
int q = (int)Program.mainForm.av1anQualityUpDown.Value;
7980
string filters = vf.Length > 3 ? $"--vmaf-filter \" {vf.Split("-vf ").LastOrDefault()} \"" : "";
8081
args += $" --target-quality {q} --vmaf-path {Paths.GetVmafPath(false).Wrap()} {filters} --vmaf-threads 2";
8182
}
82-
83-
IoUtils.TryDeleteIfExists(outPath);
8483
}
8584
else
8685
{
8786
inPath = overrideArgs.Split("-i \"")[1].Split("\"")[0].Trim();
88-
IoUtils.TryDeleteIfExists(overrideArgs.Split(" -o \"").Last().Remove("\"").Trim());
87+
outPath = overrideArgs.Split(" -o \"").Last().Remove("\"").Trim();
88+
}
89+
90+
if(outPath == inPath)
91+
{
92+
Logger.Log($"Output path can't be the same as the input path!");
93+
return;
94+
}
95+
96+
if (Path.GetExtension(outPath) == null)
97+
{
98+
Logger.Log($"Output path must have a valid file extension!");
99+
return;
89100
}
90101

91102
string tempDirName = !string.IsNullOrWhiteSpace(overrideTempDir) ? overrideTempDir : timestamp;

0 commit comments

Comments
 (0)