diff --git a/VSGUI/API/EncoderApi.cs b/VSGUI/API/EncoderApi.cs index 299a718..03b95dc 100644 --- a/VSGUI/API/EncoderApi.cs +++ b/VSGUI/API/EncoderApi.cs @@ -75,7 +75,15 @@ public static string GetEncoderPath(string type, int encoderid) { var encoderJson = GetEncoderJson(); JsonObject thisJobj = encoderJson[type][encoderid].AsObject(); - return thisJobj["encoderpath"].ToString(); + if (thisJobj.ContainsKey("encoderpath")) + { + return thisJobj["encoderpath"].ToString(); + } + else + { + string codepath = EncoderWindow.GetEncoderPathByCode(type, GetEncoderName(type, encoderid)); + return codepath; + } } public static string GetName(string type, int encoderid) diff --git a/VSGUI/API/QueueApi.cs b/VSGUI/API/QueueApi.cs index 43297be..9deb13d 100644 --- a/VSGUI/API/QueueApi.cs +++ b/VSGUI/API/QueueApi.cs @@ -120,7 +120,7 @@ public static string ProcessCommandStr(int queueid, string type, int encoderid, string encoderpath; if (!thisJobj.ContainsKey("encoderpath")) { - encoderpath = "\"" + Directory.GetCurrentDirectory() + GetDefaultEncoderP(type, pEncoderName, "encoderpath") + "\"" + " "; + encoderpath = "\"" + GetDefaultEncoderP(type, pEncoderName, "encoderpath") + "\"" + " "; } else { @@ -800,52 +800,25 @@ public static void VpyFileInputCheck(string videoinputboxText, out string cuttex //获取fps fpstextboxText = x[1].Groups[2].Value; //cut检测 - string autoGenCutConfig = IniApi.IniReadValue("AutoGenerateCut"); - if (autoGenCutConfig == "") autoGenCutConfig = "true"; - if (bool.Parse(autoGenCutConfig)) + try { - //获取vpy脚本及每行内容 - string vpyfilestr = File.ReadAllText(inputpath); - string[] vpyfilestrlist = vpyfilestr.Replace("\r\n", "\n").Split("\n"); - //获取最终输出 - string finaloutVar = ""; - var xo0 = Regex.Matches(vpyfilestr, @"(.*?)\.set_output"); - if (xo0.Count > 0) - { - finaloutVar = xo0[0].Groups[1].Value; - } - //创建键值对 - Dictionary cutmap = new Dictionary(); - //定义最终str - string finalcutstr = ""; - //错误标记 - bool isCutError = false; - //遍历每一行 - foreach (var listitem in vpyfilestrlist) + string autoGenCutConfig = IniApi.IniReadValue("AutoGenerateCut"); + if (autoGenCutConfig == "") autoGenCutConfig = "true"; + if (bool.Parse(autoGenCutConfig)) { - //判断非注释 - if (!listitem.TrimStart().StartsWith("#")) + //改成简单版本的判断 + string vpyfilestr = File.ReadAllText(inputpath); + string[] vpyfilestrlist = vpyfilestr.Replace("\r\n", "\n").Split("\n"); + string finalcutstr = ""; + foreach (string listitem in vpyfilestrlist) { - //获取被赋值变量 - string assigned = ""; - var x0 = Regex.Matches(listitem, @"(.*?)\s*?="); - if (x0.Count > 0) + if (!listitem.TrimStart().StartsWith("#")) { - if (x0[0].Groups.Count > 0) + var x1 = Regex.Matches(listitem, @".*?\.std\.Trim\((.*?),(.*?)\)|([0-9a-zA-Z]*?)\[(\d+(?:\:|\,|\s)*\d+)\]"); + string linecutstr = ""; + if (x1.Count > 0) { - assigned = x0[0].Groups[1].Value; - } - } - //获取裁剪参数 - var x1 = Regex.Matches(listitem, @".*?\.std\.Trim\((.*?),(.*?)\)|([0-9a-zA-Z]*?)\[(\d+(?:\:|\,|\s)*\d+)\]"); - string linecutstr = ""; - if (x1.Count > 0) - { - for (int i = 0; i < x1.Count; i++) - { - string assign = x1[i].Groups[1].Value; - if (assign == "") assign = x1[i].Groups[3].Value; - if (assigned == assign) // ?最简单的保护,如果是复合变量直接放弃 + for (int i = 0; i < x1.Count; i++) { string cutmessagestr = x1[i].Groups[2].Value; if (cutmessagestr == "") cutmessagestr = x1[i].Groups[4].Value; @@ -856,32 +829,103 @@ public static void VpyFileInputCheck(string videoinputboxText, out string cuttex linecutstr += "+"; } } - else + if (finalcutstr != "") { - isCutError = true; + finalcutstr += "&"; } - } - //处理变量map - if (cutmap.ContainsKey(assigned)) - { - cutmap[assigned] = cutmap[assigned] + @"&" + linecutstr; - } - else - { - cutmap.Add(assigned, linecutstr); + finalcutstr += linecutstr; } } } + cuttextboxText = finalcutstr; + if (finalcutstr != "") + { + cutischeckedIsChecked = true; + } + + ////获取vpy脚本及每行内容 + //string vpyfilestr = File.ReadAllText(inputpath); + //string[] vpyfilestrlist = vpyfilestr.Replace("\r\n", "\n").Split("\n"); + ////获取最终输出 + //string finaloutVar = ""; + //var xo0 = Regex.Matches(vpyfilestr, @"(.*?)\.set_output"); + //if (xo0.Count > 0) + //{ + // finaloutVar = xo0[0].Groups[1].Value; + //} + ////创建键值对 + //Dictionary cutmap = new Dictionary(); + ////定义最终str + //string finalcutstr = ""; + ////错误标记 + //bool isCutError = false; + ////遍历每一行 + //foreach (var listitem in vpyfilestrlist) + //{ + // //判断非注释 + // if (!listitem.TrimStart().StartsWith("#")) + // { + // //获取被赋值变量 + // string assigned = ""; + // var x0 = Regex.Matches(listitem, @"(.*?)\s*?="); + // if (x0.Count > 0) + // { + // if (x0[0].Groups.Count > 0) + // { + // assigned = x0[0].Groups[1].Value; + // } + // } + // //获取裁剪参数 + // var x1 = Regex.Matches(listitem, @".*?\.std\.Trim\((.*?),(.*?)\)|([0-9a-zA-Z]*?)\[(\d+(?:\:|\,|\s)*\d+)\]"); + // string linecutstr = ""; + // if (x1.Count > 0) + // { + // for (int i = 0; i < x1.Count; i++) + // { + // string assign = x1[i].Groups[1].Value; + // if (assign == "") assign = x1[i].Groups[3].Value; + // if (assigned == assign) // ?最简单的保护,如果是复合变量直接放弃 + // { + // string cutmessagestr = x1[i].Groups[2].Value; + // if (cutmessagestr == "") cutmessagestr = x1[i].Groups[4].Value; + // string[] cutmessagelist = cutmessagestr.Replace(":", ",").Replace(" ", "").Replace("(", "").Replace(")", "").Replace("[", "").Replace("]", "").Split(",");//获得cut的前后帧 + // linecutstr += "[" + cutmessagelist[0] + ":" + cutmessagelist[1] + "]"; + // if (i != x1.Count - 1) + // { + // linecutstr += "+"; + // } + // } + // else + // { + // isCutError = true; + // } + // } + // //处理变量map + // if (cutmap.ContainsKey(assigned)) + // { + // cutmap[assigned] = cutmap[assigned] + @"&" + linecutstr; + // } + // else + // { + // cutmap.Add(assigned, linecutstr); + // } + // } + // } + //} + //if (!isCutError && cutmap.Count > 0) + //{ + // finalcutstr = cutmap[finaloutVar]; + //} + //cuttextboxText = finalcutstr; + //if (finalcutstr != "") + //{ + // cutischeckedIsChecked = true; + //} } - if (!isCutError && cutmap.Count > 0) - { - finalcutstr = cutmap[finaloutVar]; - } - cuttextboxText = finalcutstr; - if (finalcutstr != "") - { - cutischeckedIsChecked = true; - } + } + catch (Exception) + { + //cut判断失败 } } else diff --git a/VSGUI/MainWindow.xaml.cs b/VSGUI/MainWindow.xaml.cs index 30039b8..c59ab0e 100644 --- a/VSGUI/MainWindow.xaml.cs +++ b/VSGUI/MainWindow.xaml.cs @@ -25,7 +25,7 @@ public partial class MainWindow { public static string binpath = Directory.GetCurrentDirectory() + @"\bin"; private bool forcedStop = false; - private string coreversion = "v1.0.4"; + private string coreversion = "v1.0.5"; public static string logBoxStr = ""; private string[] videoMultiInputLists, audioMultiInputLists; diff --git a/VSGUI/Properties/Langs/en.xaml b/VSGUI/Properties/Langs/en.xaml index 410f254..4894970 100644 --- a/VSGUI/Properties/Langs/en.xaml +++ b/VSGUI/Properties/Langs/en.xaml @@ -133,7 +133,7 @@ No More Prompts The profile is NetEncoder. Editing is not allowed. When entering the vpy script, automatically read the Cuts information - In advanced Encode mode, when inputting a vpy script, the clip script is automatically read from the script and filled in the audio information area (only single variable is supported). + In advanced Encode mode, when inputting a vpy script, the clip script is automatically read from the script and filled in the audio information area (Complex scripts are not supported). The following temporary files exist in the task. Do you want to delete them? Not Installed Use system environment diff --git a/VSGUI/Properties/Langs/zh-cn.xaml b/VSGUI/Properties/Langs/zh-cn.xaml index c6e8b28..c2969d3 100644 --- a/VSGUI/Properties/Langs/zh-cn.xaml +++ b/VSGUI/Properties/Langs/zh-cn.xaml @@ -133,7 +133,7 @@ 不再提示 该配置为网络配置,不允许修改 输入vpy脚本时,自动读取Cuts信息 - 在高级压制模式下,输入vpy脚本时,自动从脚本中读取剪辑脚本,并填写到音频信息区(仅支持单变量)。 + 在高级压制模式下,输入vpy脚本时,自动从脚本中读取剪辑脚本,并填写到音频信息区(不支持复杂脚本)。 任务存在如下临时文件,是否删除? 未安装 使用系统环境 diff --git a/VSGUI/Windows/EncoderWindow.xaml.cs b/VSGUI/Windows/EncoderWindow.xaml.cs index a87044d..1fbf2c3 100644 --- a/VSGUI/Windows/EncoderWindow.xaml.cs +++ b/VSGUI/Windows/EncoderWindow.xaml.cs @@ -284,6 +284,18 @@ private string GetEncoderPath(string encodername) return ""; } + public static string GetEncoderPathByCode(string type,string name) + { + for (int i = 0; i < encoders.GetLength(0); i++) + { + if (encoders[i, 0].Equals(type) && encoders[i, 1].Equals(name)) + { + return encoders[i, 3]; + } + } + return ""; + } + private string GetEncoderPipeinputformat(string encodername) {