Fixed single quote in filename not working

This commit is contained in:
N00MKRAD
2021-01-14 14:52:21 +01:00
parent 63ef217e31
commit 2a9c7a79a9
3 changed files with 3 additions and 15 deletions

View File

@@ -29,7 +29,6 @@ namespace Flowframes
public static async Task RunFfmpeg(string args, string workingDir, LogMode logMode, TaskType taskType = TaskType.Other) public static async Task RunFfmpeg(string args, string workingDir, LogMode logMode, TaskType taskType = TaskType.Other)
{ {
args = args.TrimWhitespacesSafe();
lastOutputFfmpeg = ""; lastOutputFfmpeg = "";
currentLogMode = logMode; currentLogMode = logMode;
Process ffmpeg = OSUtils.NewProcess(true); Process ffmpeg = OSUtils.NewProcess(true);

View File

@@ -108,7 +108,7 @@ namespace Flowframes
public static string StripBadChars(this string str) public static string StripBadChars(this string str)
{ {
string outStr = Regex.Replace(str, @"[^\u0020-\u007E]", string.Empty); string outStr = Regex.Replace(str, @"[^\u0020-\u007E]", string.Empty);
outStr = outStr.Replace("(", "").Replace(")", "").Replace("[", "").Replace("]", "").Replace("{", "").Replace("}", "").Replace("%", ""); outStr = outStr.Remove("(").Remove(")").Remove("[").Remove("]").Remove("{").Remove("}").Remove("%").Remove("'");
return outStr; return outStr;
} }
@@ -124,17 +124,6 @@ namespace Flowframes
return str.Replace(stringToRemove, ""); return str.Replace(stringToRemove, "");
} }
public static string TrimWhitespacesSafe (this string str) // Trim whitespaces, unless they are "quoted" (to avoid trimming file paths)
{
var result = str.Split('"').Select((element, index) => index % 2 == 0 ? element.TrimWhitespaces() : element.Wrap());
string resultJoined = string.Join("", result);
result = resultJoined.Split('\'').Select((element, index) => index % 2 == 0 ? element.TrimWhitespaces() : "'" + element + "'");
resultJoined = string.Join("", result);
return resultJoined;
}
public static string TrimWhitespaces(this string str) public static string TrimWhitespaces(this string str)
{ {
if (str == null) return str; if (str == null) return str;

View File

@@ -86,7 +86,7 @@ namespace Flowframes
Process rifePy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd()); Process rifePy = OSUtils.NewProcess(!OSUtils.ShowHiddenCmd());
AiStarted(rifePy, 3500, Interpolate.current.interpFactor); AiStarted(rifePy, 3500, Interpolate.current.interpFactor);
rifePy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeCuda).Wrap()} & " + rifePy.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeCuda).Wrap()} & " +
$"set CUDA_VISIBLE_DEVICES={Config.Get("torchGpus")} & {Python.GetPyCmd()} {script} {args}".TrimWhitespacesSafe(); $"set CUDA_VISIBLE_DEVICES={Config.Get("torchGpus")} & {Python.GetPyCmd()} {script} {args}";
Logger.Log($"Running RIFE {(InterpolateUtils.UseUHD() ? "(UHD Mode)" : "")} ({script})...".TrimWhitespaces(), false); Logger.Log($"Running RIFE {(InterpolateUtils.UseUHD() ? "(UHD Mode)" : "")} ({script})...".TrimWhitespaces(), false);
Logger.Log("cmd.exe " + rifePy.StartInfo.Arguments, true); Logger.Log("cmd.exe " + rifePy.StartInfo.Arguments, true);
if (!OSUtils.ShowHiddenCmd()) if (!OSUtils.ShowHiddenCmd())
@@ -161,7 +161,7 @@ namespace Flowframes
string uhdStr = InterpolateUtils.UseUHD() ? "-u" : ""; string uhdStr = InterpolateUtils.UseUHD() ? "-u" : "";
rifeNcnn.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeNcnn).Wrap()} & rife-ncnn-vulkan.exe " + rifeNcnn.StartInfo.Arguments = $"{OSUtils.GetCmdArg()} cd /D {PkgUtils.GetPkgFolder(Packages.rifeNcnn).Wrap()} & rife-ncnn-vulkan.exe " +
$" -v -i {inPath.Wrap()} -o {outPath.Wrap()} -m {mdl.ToLower()} {uhdStr} -g {Config.Get("ncnnGpus")} -f {InterpolateUtils.GetOutExt()} -j {GetNcnnThreads()}".TrimWhitespacesSafe(); $" -v -i {inPath.Wrap()} -o {outPath.Wrap()} -m {mdl.ToLower()} {uhdStr} -g {Config.Get("ncnnGpus")} -f {InterpolateUtils.GetOutExt()} -j {GetNcnnThreads()}";
Logger.Log("cmd.exe " + rifeNcnn.StartInfo.Arguments, true); Logger.Log("cmd.exe " + rifeNcnn.StartInfo.Arguments, true);